TFormedY# ( )
Parameters
| None. |
Description
|
Returns the y component of the most recent TFormPoint, TFormVector or TFormNormal result. The TForm commands don't return values directly - they store their result, and TFormedX, TFormedY and TFormedZ read it back. Each new TForm call overwrites the previous result, so read all the components you need before transforming anything else. See also: TFormedX, TFormedZ, TFormPoint, TFormVector, TFormNormal. |
Example
; TFormedY Example ; ---------------- ; The TForm commands (TFormPoint, TFormVector, TFormNormal) store ; their result internally; TFormedY reads back the y component. ; Here TFormPoint tracks the muzzle tip of a nodding turret, and ; TFormedY supplies the marker's world y coordinate. 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) ; Nod the barrel up and down so the muzzle's world y keeps changing RotateEntity turret,30*Sin(MilliSecs()*0.1),0,0 ; Transform the local muzzle point (0,0,1.5) into world space TFormPoint 0,0,1.5,turret,0 ; Read back the result - TFormedY is the documented command y#=TFormedY() PositionEntity marker,TFormedX(),y,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,"TFormedY() = "+y Text 0,40,"The marker's world y rises and falls as the barrel nods" Flip Wend End
Index