CameraProject Limits

Blitz3D Forums/Blitz3D Programming/CameraProject Limits

fall_x(Posted 2004) [#1]
Hi,

I want to make some kind of indicators on the screen that shows me the exact positions of the players. If the players are on the screen, these indicators are above their heads. If they're off screen, these indicators should be on the side of the screen in the right direction. I tried with this code :

(for each player :)
CameraProject e_cam\cam,EntityX(pl\entity),EntityY(pl\entity)+1.8,EntityZ(pl\entity)
cx#=ProjectedX#()
cy#=ProjectedY#()
If cx<0 Then cx=0
If cx>GraphicsWidth() Then cx=GraphicsWidth()
If cy<0 Then cy=0
If cy>GraphicsHeight() Then cy=GraphicsHeight()
DrawImage pl\cross,cx-16,cy-16


The problem with this is, if the value of ProjectedY() gets too big, then both ProjectedY() and ProjectedX() return 0. I can't seem to think of another way to get the exact 2d positions of my 3D characters, so a little help would be appreciated. Thanks.


DJWoodgate(Posted 2004) [#2]
Temporarily adjust the camera range. Cameraproject cuts off at camera far, so make the far value further away, then set it back to what it was after the call to Cameraproject.

From what you say though it could be they are behind the camera, in which case tform their positions to the front of the camera and then project and move to nearest screen edge. Perhaps add some indication to show they are behind you.

Also if they are exactly on the plane of the camera, then you may need to adjust the positions forward slightly


fall_x(Posted 2004) [#3]
You're right, it's when they are behind the camera. Tforming it did the trick. Thank you!