; TFormPoint Example ; ------------------ ; TFormPoint converts a position from one entity's coordinate space ; to another's (use 0 for world space). The muzzle tip of a spinning ; turret is a fixed LOCAL point (0,0,1.5); TFormPoint maps it into ; world space so a marker sphere can track it as the turret turns. Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,3,-6 RotateEntity camera,20,0,0 light=CreateLight() RotateEntity light,30,40,0 ; A base and a long turret barrel on top of it base=CreateCylinder() ScaleEntity base,1,0.4,1 EntityColor base,110,110,130 turret=CreateCube() ScaleMesh turret,0.25,0.25,1.5 ; barrel runs from local z -1.5 to 1.5 PositionEntity turret,0,1,0 EntityColor turret,90,180,90 ; The marker lives in WORLD space and follows the muzzle tip marker=CreateSphere() ScaleEntity marker,0.15,0.15,0.15 EntityColor marker,255,255,0 EntityFX marker,1 While Not KeyDown(1) TurnEntity turret,0,1.5,0 ; The documented command: local muzzle point -> world coordinates TFormPoint 0,0,1.5,turret,0 PositionEntity marker,TFormedX(),TFormedY(),TFormedZ() ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"TFormPoint 0,0,1.5,turret,0 (muzzle tip into world space)" Text 0,40,"World position: "+TFormedX()+", "+TFormedY()+", "+TFormedZ() Flip Wend End