; TFormVector Example ; ------------------- ; TFormVector converts a DIRECTION from one coordinate space to ; another - like TFormPoint, but ignoring position. Here we ask: ; where would one 2-unit step 'forward' take the ship? The ghost ; marker shows the answer; Space actually takes the step. Graphics3D 640,480 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,6,-8 RotateEntity camera,35,0,0 light=CreateLight() RotateEntity light,45,45,0 ; A ground plane for reference ground=CreatePlane() EntityColor ground,40,80,50 PositionEntity ground,0,-1,0 ; The ship: a cone whose MESH is rotated so its nose points along +z ship=CreateCone() RotateMesh ship,90,0,0 EntityColor ship,255,180,60 ; A ghost marker showing where a forward step would land marker=CreateSphere() ScaleEntity marker,0.2,0.2,0.2 EntityColor marker,120,220,255 EntityFX marker,1 EntityAlpha marker,0.6 While Not KeyDown(1) ; Left / Right steer the ship If KeyDown(203) Then TurnEntity ship,0,2,0 If KeyDown(205) Then TurnEntity ship,0,-2,0 ; The documented command: the ship's local 'forward' (0,0,2) ; expressed as a world-space direction TFormVector 0,0,2,ship,0 PositionEntity marker,EntityX(ship)+TFormedX(),EntityY(ship)+TFormedY(),EntityZ(ship)+TFormedZ() ; Space takes the step - the ship lands exactly on the marker If KeyHit(57) Then MoveEntity ship,0,0,2 RenderWorld Text 0,0,"Left/Right: steer Space: step forward Esc: exit" Text 0,20,"TFormVector 0,0,2,ship,0 = "+TFormedX()+", "+TFormedY()+", "+TFormedZ() Text 0,40,"The ghost marker sits one step ahead of the ship" Flip Wend End