The coords are skewed by perspective - ie you can move a mouse pointer overhead and place a cube - but it doesn't appear at the point of the mouse pointer:
Graphics3D 800,600,16,2 Global entity Global ent Global world_pos_x# Global world_pos_z# ground=CreatePlane() EntityColor ground,0,200,0 Global cube1=CreateCube() ScaleEntity cube1,.5,.5,.5 PositionEntity cube1,-2,1,-2 EntityPickMode cube1,2 Global cube2=CreateCube() ScaleEntity cube2,.5,.5,.5 PositionEntity cube2,2,1,-2 EntityPickMode cube2,2 Global cube3=CreateCube() ScaleEntity cube3,.5,.5,.5 PositionEntity cube3,0,1,0 EntityPickMode cube3,2 Global cube4=CreateCube() ScaleEntity cube4,.5,.5,.5 PositionEntity cube4,-2,1,2 EntityPickMode cube4,2 Global cube5=CreateCube() ScaleEntity cube5,.5,.5,.5 PositionEntity cube5,2,1,2 EntityPickMode cube5,2 light=CreateLight() PositionEntity light,100,100,-100 PointEntity light,cube1 Global cam=CreateCamera() CameraViewport cam,10,90,500,500 CameraProjMode cam,1 CameraZoom cam,2.5 CameraRange cam,.01,1000 PositionEntity cam,0,10,0 RotateEntity cam,90,0,0 Repeat Cls If MouseHit(1) And entity<>0 ; something had to have been picked End If If MouseDown(1) And entity=0 ; basically picking empty space cube=CreateSphere() ScaleEntity cube,.25,.25,.25 PositionEntity cube,world_pos_x,1,world_pos_z EndIf If entity EntityColor entity,255,0,0 EndIf ; overhead camera If KeyDown(16) Then TurnEntity cam,0,0,1 ; rotate cam left If KeyDown(18) Then TurnEntity cam,0,0,-1 ; rotate cam right If KeyDown(12) Then MoveEntity cam,0,0,.1 ; zoom in If KeyDown(13) Then MoveEntity cam,0,0,-.1 ; zoom out If KeyDown(17) Then MoveEntity cam,0,.1,0 ; forward If KeyDown(31) Then MoveEntity cam,0,-.1,0 ; back If KeyDown(30) MoveEntity cam,-.1,0,0 ; strafe left If KeyDown(32) MoveEntity cam,.1,0,0 ; strafe right UpdateWorld() RenderWorld() Project2DTo3DOrtho( MouseX() , MouseY() ) Text 10,10,"Entity Highlighted: "+entity Flip Until KeyDown(1)=1 ClearWorld() End Function Project2DTo3DOrtho(mx,my) ;Check the mouse is in the 3d window If mx>=10 And mx<=509 And my=>90 And my<=589 ;Get mouse position in relation to the 3d viewport vx=mx-10; 100 vy=my-90; 100 ; draw the rectangle here as it relies on the mx and my coords Rect mx,my-3,1,7 Rect mx-3,my,7,1 ;Get the 2d position of the origin CameraProject cam,0,0,0 xx#=ProjectedX() yy#=ProjectedY() ;Get the 2d position of 1,1,1 CameraProject cam,1,1,1 xx2#=ProjectedX() yy2#=ProjectedY() ;Take one from the other to find the distance dx#=xx2-xx dy#=yy2-yy ;World position is : world_pos_x#=(vx-xx)/dx world_pos_z#=(vy-yy)/dy ent=CameraPick(cam,vx,vy) If ent<>entity If entity Then EntityColor entity,255,255,255 entity=ent EndIf Text 10,50,"Cursor is at World position X : "+world_pos_x Text 10,60," Z : "+world_pos_z EndIf End Function