ProjectedXY

Archives Forums/Blitz3D Bug Reports/ProjectedXY

D4NM4N(Posted 2005) [#1]
Im trying to return the 2d screen coords for a picked entity and place a text lable there. For some reason the place on screen i have to pick the object is way to high. (the axis is set in center) also when the projected X coords are returned the position above the object seems to increase as i move the camera away.
I don seem to remember it behaing this way, but cannot seem to find the reason.
		If G_MH1>0 
			;get mouse picked camera entity
			G_PickedEntity=CameraPick (g_camera,g_mx,g_my)
		EndIf


and
	If g_pickedentity
		CameraProject g_camera,EntityX(g_pickedentity),EntityY (g_pickedentity),EntityZ(g_pickedentity)
		Color 255,0,255
		Text ProjectedX(),ProjectedY(),"+ Selected"
		Text 10,10,"+ Selected"
	EndIf 

i have a geforce 4 mx 440


D4NM4N(Posted 2005) [#2]
Here is some more information on this, im using

cameraviewport g_camera,0,32,g_gwidth-150,g_gheight-32

i need to do this because i have 2d drawn icons and so dont want any slowdown over 3d. Without the cameraviewport setting it works as expected. Ist odd that it only seems to affect the Y axis and not X. Is there a formula i can use using the zaxis of my entity and the pprojected Y to put it back in its right place?


big10p(Posted 2005) [#3]
You need to factor in your camera viewport coords into things because mouse coords and Text coords are absolute screen positions - they're not relative to the top-left corner of your camera viewport. Something like:
mx = MouseX() - VIEWPORT_X
my = MouseY() - VIEWPORT_Y

.
.
.

ent = CameraPick(cam,mx,my)
CameraProject cam,EntityX(ent,1),EntityY(ent,1),EntityZ(ent,1)
Text ProjectedX() + VIEWPORT_X,ProjectedY() + VIEWPORT_Y,"Here!"