TranslateEntity.htm 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>TranslateEntity entity,x#,y#,z#,[,global]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. entity - name of entity to be translated <br />
  13. x# - x amount that entity will be translated by <br />
  14. y# - y amount that entity will be translated by <br />
  15. z# - z amount that entity will be translated by <br />
  16. global (optional) -
  17. </td>
  18. </tr>
  19. </table>
  20. <h1>Description</h1>
  21. <table>
  22. <tr>
  23. <td>
  24. Translates an entity relative to its current position and not its orientation. <br />
  25. <br />
  26. 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.
  27. <br>
  28. <br>
  29. 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>.
  30. </td>
  31. </tr>
  32. </table>
  33. <h1><a href=../3d_examples/TranslateEntity.bb>Example</a></h1>
  34. <table>
  35. <tr>
  36. <td>
  37. ; TranslateEntity Example <br />
  38. ; ----------------------- <br />
  39. <br />
  40. Graphics3D 640,480 <br />
  41. SetBuffer BackBuffer() <br />
  42. <br />
  43. camera=CreateCamera() <br />
  44. light=CreateLight() <br />
  45. <br />
  46. cone=CreateCone( 32 ) <br />
  47. <br />
  48. ; Rotate cone by random amount to demonstrate that TranslateEntity is independent of entity orientation <br />
  49. RotateEntity cone,Rnd( 0,360 ),Rnd( 0,360 ),Rnd( 0,360 ) <br />
  50. <br />
  51. ; Translate cone in front of camera, so we can see it to begin with <br />
  52. TranslateEntity cone,0,0,10 <br />
  53. <br />
  54. While Not KeyDown( 1 ) <br />
  55. <br />
  56. ; Reset translation values - otherwise, the cone will not stop! <br />
  57. x#=0 <br />
  58. y#=0 <br />
  59. z#=0 <br />
  60. <br />
  61. ; Change translation values depending on the key pressed <br />
  62. If KeyDown( 203 )=True Then x#=-0.1 <br />
  63. If KeyDown( 205 )=True Then x#=0.1 <br />
  64. If KeyDown( 208 )=True Then y#=-0.1 <br />
  65. If KeyDown( 200 )=True Then y#=0.1 <br />
  66. If KeyDown( 44 )=True Then z#=-0.1 <br />
  67. If KeyDown( 30 )=True Then z#=0.1 <br />
  68. <br />
  69. ; Translate sphere using translation values <br />
  70. TranslateEntity cone,x#,y#,z# <br />
  71. <br />
  72. ; If spacebar pressed then rotate cone by random amount <br />
  73. If KeyHit( 57 )=True Then RotateEntity cone,Rnd( 0,360 ),Rnd( 0,360 ),Rnd( 0,360 ) <br />
  74. <br />
  75. RenderWorld <br />
  76. <br />
  77. Text 0,0,"Use cursor/A/Z keys to translate cone, spacebar to rotate cone by random amount" <br />
  78. Text 0,20,"X Translation: "+x# <br />
  79. Text 0,40,"Y Translation: "+y# <br />
  80. Text 0,60,"Z Translation: "+z# <br />
  81. <br />
  82. Flip <br />
  83. <br />
  84. Wend <br />
  85. <br />
  86. End
  87. </td>
  88. </tr>
  89. </table>
  90. <br>
  91. <a target=_top href=../index.htm>Index</a><br>
  92. <br>
  93. 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>
  94. </html>