|
entity - entity handle global (optional) - true to return the world z coordinate, false to return the coordinate relative to the entity's parent; false (default) |
|
Returns the z coordinate of an entity. With global false (the default) the coordinate is in the entity's parent's local space; pass true to get the entity's actual position in the world. If the entity has no parent, local and global are the same. Blitz3D is left-handed, so Z+ is forward, into the screen. See EntityX for an overview of local and global coordinates. See also: EntityX, EntityY, PositionEntity, EntityDistance. |
; EntityZ Example
; ---------------
Graphics3D 640,480,0,2
SetBuffer BackBuffer()
camera=CreateCamera()
PositionEntity camera,0,3,-10
RotateEntity camera,15,0,0
light=CreateLight()
RotateEntity light,45,45,0
; A satellite parented to a pivot, offset 2 units along the pivot's z axis
pivot=CreatePivot()
satellite=CreateCube(pivot)
ScaleEntity satellite,0.5,0.5,0.5
PositionEntity satellite,0,0,2
EntityColor satellite,255,100,255
While Not KeyDown(1)
; The pivot spins, so the satellite's GLOBAL z changes constantly,
; while its LOCAL z (relative to its parent pivot) stays fixed at 2
TurnEntity pivot,0,1,0
; 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"
; EntityZ with the global flag True returns the world-space z coordinate
Text 0,20,"EntityZ(satellite,True) global = "+EntityZ(satellite,True)
Text 0,40,"EntityZ(satellite) local = "+EntityZ(satellite)
Flip
Wend
End