Blitz3D+ Command Reference

TFormedX# ( )

Parameters

None.

Description

Returns the x 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: TFormedY, TFormedZ, TFormPoint, TFormVector, TFormNormal.

Example

; TFormedX Example
; ----------------

; The TForm commands (TFormPoint, TFormVector, TFormNormal) store
; their result internally; TFormedX reads back the x component.
; Here TFormPoint tracks the muzzle tip of a spinning turret, and
; TFormedX supplies the marker's world x 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)

    TurnEntity turret,0,1.5,0

    ; Transform the local muzzle point (0,0,1.5) into world space
    TFormPoint 0,0,1.5,turret,0

    ; Read back the result - TFormedX is the documented command
    x#=TFormedX()
    PositionEntity marker,x,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,"TFormedX() = "+x
    Text 0,40,"The marker's world x swings as the turret spins"

    Flip

Wend

End

Index