| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>TranslateEntity entity,x#,y#,z#,[,global]</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- entity - name of entity to be translated
<br />
- x# - x amount that entity will be translated by
<br />
- y# - y amount that entity will be translated by
<br />
- z# - z amount that entity will be translated by
<br />
- global (optional) -
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- Translates an entity relative to its current position and not its orientation.
<br />
-
<br />
- 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.
- <br>
- <br>
- See also: <a class=small href=MoveEntity.htm>MoveEntity</a>, <a class=small href=PositionEntity.htm>PositionEntity</a>, <a class=small href=PositionMesh.htm>PositionMesh</a>.
- </td>
- </tr>
- </table>
- <h1><a href=../3d_examples/TranslateEntity.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; TranslateEntity Example
<br />
- ; -----------------------
<br />
-
<br />
- Graphics3D 640,480
<br />
- SetBuffer BackBuffer()
<br />
-
<br />
- camera=CreateCamera()
<br />
- light=CreateLight()
<br />
-
<br />
- cone=CreateCone( 32 )
<br />
-
<br />
- ; Rotate cone by random amount to demonstrate that TranslateEntity is independent of entity orientation
<br />
- RotateEntity cone,Rnd( 0,360 ),Rnd( 0,360 ),Rnd( 0,360 )
<br />
-
<br />
- ; Translate cone in front of camera, so we can see it to begin with
<br />
- TranslateEntity cone,0,0,10
<br />
-
<br />
- While Not KeyDown( 1 )
<br />
-
<br />
- ; Reset translation values - otherwise, the cone will not stop!
<br />
- x#=0
<br />
- y#=0
<br />
- z#=0
<br />
-
<br />
- ; Change translation values depending on the key pressed
<br />
- If KeyDown( 203 )=True Then x#=-0.1
<br />
- If KeyDown( 205 )=True Then x#=0.1
<br />
- If KeyDown( 208 )=True Then y#=-0.1
<br />
- If KeyDown( 200 )=True Then y#=0.1
<br />
- If KeyDown( 44 )=True Then z#=-0.1
<br />
- If KeyDown( 30 )=True Then z#=0.1
<br />
-
<br />
- ; Translate sphere using translation values
<br />
- TranslateEntity cone,x#,y#,z#
<br />
-
<br />
- ; If spacebar pressed then rotate cone by random amount
<br />
- If KeyHit( 57 )=True Then RotateEntity cone,Rnd( 0,360 ),Rnd( 0,360 ),Rnd( 0,360 )
<br />
-
<br />
- RenderWorld
<br />
-
<br />
- Text 0,0,"Use cursor/A/Z keys to translate cone, spacebar to rotate cone by random amount"
<br />
- Text 0,20,"X Translation: "+x#
<br />
- Text 0,40,"Y Translation: "+y#
<br />
- Text 0,60,"Z Translation: "+z#
<br />
-
<br />
- Flip
<br />
-
<br />
- Wend
<br />
-
<br />
- End
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=TranslateEntity&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|