dxTranslateEntity(entity,x#,y#,z#,global)

Parameters

entity - name of entity to be translated
x# - x amount that entity will be translated by
y# - y amount that entity will be translated by
z# - z amount that entity will be translated by
global (optional) -

Description

Translates an entity relative to its current position and not its orientation.

What this means is that an entity will move in a certain direction despite where it may be facing. Imagine that you have a game character that you want to make jump in the air at the same time as doing a triple somersault. Translating the character by a positive y amount will mean the character will always travel directly up in their air, regardless of where it may be facing due to the somersault action.

See also: dxMoveEntity, dxPositionEntity, dxPositionMesh.

Example

; dxTranslateEntity Example
; -----------------------

dxGraphics3D 640,480
dxSetBuffer dxBackBuffer()

camera=dxCreateCamera()
light=dxCreateLight()

cone=dxCreateCone( 32 )

; Rotate cone by random amount to demonstrate that dxTranslateEntity is independent of entity orientation
dxRotateEntity cone,dxRnd( 0,360 ),dxRnd( 0,360 ),dxRnd( 0,360 )

; Translate cone in front of camera, so we can see it to begin with
dxTranslateEntity cone,0,0,10

While Not dxKeyDown( 1 )

; Reset translation values - otherwise, the cone will not stop!
x#=0
y#=0
z#=0

; Change translation values depending on the key pressed
If dxKeyDown( 203 )=True Then x#=-0.1
If dxKeyDown( 205 )=True Then x#=0.1
If dxKeyDown( 208 )=True Then y#=-0.1
If dxKeyDown( 200 )=True Then y#=0.1
If dxKeyDown( 44 )=True Then z#=-0.1
If dxKeyDown( 30 )=True Then z#=0.1

; Translate sphere using translation values
dxTranslateEntity cone,x#,y#,z#

; If spacebar pressed then rotate cone by random amount
If dxKeyHit( 57 )=True Then dxRotateEntity cone,dxRnd( 0,360 ),dxRnd( 0,360 ),dxRnd( 0,360 )

dxRenderWorld

dxText 0,0,"Use cursor/A/Z keys to translate cone, spacebar to rotate cone by random amount"
dxText 0,20,"X Translation: "+x#
dxText 0,40,"Y Translation: "+y#
dxText 0,60,"Z Translation: "+z#

dxFlip

Wend

End

Index