Am I missing something?!

Blitz3D Forums/Blitz3D Programming/Am I missing something?!

H. T. U.(Posted 2009) [#1]
Grrr, I don't know how long I've been working at this (it's become a bit of a hack job), but it's starting to drive me nuts.

I have two functions, one is an intelligent sight while the other displays a radar:



They work fine, until I board one of the vehicles. In the sight function, the sight dissapears at (range/# of vehicles) units. In the radar function, the coordinates of the blips representing each vehicle are equivelent to (coordinate^# of vehicles). In addition, I don't see why the cutoff distance for drawing the blips is 66, each quadrant of the radar is 100x100 pixels.

I hope you can help me with just this information, the full vehicle system is quite long.


Ross C(Posted 2009) [#2]
I haven't looked at your code, but the common error is a variable that supposed to be a floating point, but is never declared one. Or, a variable that is declared as a floating point, but the calculation contains integers.

Looking at your code, i don't see anything that would suggest that, in your two functions anyway. Is there a chance the problem could lie outside these functions? Can you post a working example?


Stevie G(Posted 2009) [#3]
On the first function you don't have code to determine what to do when the line of sight does not pick something. Will the pick always return something? If not, remember that pickedx,y,z will return the last successful pick.

Also, if the entity which you pass to the function is a child then make sure x, y, z refer to the global coords rather than local.

In the second function you are disregarding anything which is further than 66 units away which is why the cutoff is >66. Is there something I'm missing?

Other than that you'll need to post the code as it's difficult to see what the issue is.


Warner(Posted 2009) [#4]
Shouldn't it be:
pkd=LinePick(x,y,z,TFormedX#()-x,TFormedY#()-y,TFormedZ#()-z)

And later on:
onscreen = CameraProject(camera,PickedX#(),PickedY#(),PickedZ#())
	sightx#=ProjectedX()
	sighty#=ProjectedY()

	If onscreen
And I think you should change 'dst' to a float.


Stevie G(Posted 2009) [#5]

Shouldn't it be:

pkd=LinePick(x,y,z,TFormedX#()-x,TFormedY#()-y,TFormedZ#()-z)



Nope.


And later on:

onscreen = CameraProject(camera,PickedX#(),PickedY#(),PickedZ#())
sightx#=ProjectedX()
sighty#=ProjectedY()

If onscreen

And I think you should change 'dst' to a float.



Eh? Cameraproject does not return anything. If the entity is offscreen then the coords are 0,0.


H. T. U.(Posted 2009) [#6]
Please wait for an update: there may be a major flaw in my code which is confusing distance calculations. This could take a while to fix.


Warner(Posted 2009) [#7]
Ah, TFormVector .. I thought it said TFormPoint. I thought CameraProject should return true or false, from the manual:

Projects the world coordinates x,y,z on to the 2D screen. Returns true if the coordinates are on-screen.




H. T. U.(Posted 2009) [#8]
Well, I've ripped apart my code to make a working demo of these two functions with the vehicle system. It may still have some unnecessary code fragments, but I'm about to leave on a vacation and I'm not certain if I'll have good internet access (my ethernet connecter is broken so I have to use wi-fi). It's still VERY long.



Some code I ripped out fixed the sight, but the radar has an unusual problem: when you "walk" around, it workes fine. In the sphere shaped aircraft, distances are shown as half of what they're supposed to be, while in the cube they are 1/3 their correct distance. This looks a lot like the "mode" is somehow interfering.


H. T. U.(Posted 2009) [#9]
On my way back, any suggestions?


Stevie G(Posted 2009) [#10]
Yes. The tform commands "correctly" take into consideration the entity scale. The cone works fine as you don't scale it. If you use scalemesh instead of scaleentity this works fine. The only alternative is to store the axis scales and apply them to the tformed results.


GIB3D(Posted 2009) [#11]
Just bringing this to your attention, but if you want to put a blip on the radar where you are, after you are parented to something else, use the global thing on the EntityX,Y,Z's

EntityX(omgmodel,1)



H. T. U.(Posted 2009) [#12]
Thanks Stevie, that solved everything! Maybe I should stop using ScaleEntity to scale meshes :)