PositionEntity.htm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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>PositionEntity entity,x#,y#,z#,[,global]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. entity - name of entity to be positioned <br />
  13. x# - x co-ordinate that entity will be positioned at <br />
  14. y# - y co-ordinate that entity will be positioned at <br />
  15. z# - z co-ordinate that entity will be positioned at <br />
  16. global (optional) - true if the position should be relative to 0,0,0 rather than a parent entity's position. False by default.
  17. </td>
  18. </tr>
  19. </table>
  20. <h1>Description</h1>
  21. <table>
  22. <tr>
  23. <td>
  24. Positions an entity at an absolute position in 3D space. <br />
  25. <br />
  26. Entities are positioned using an x,y,z coordinate system. x, y and z each have their own axis, and each axis has its own set of values. By specifying a value for each axis, you can position an entity anywhere in 3D space. 0,0,0 is the centre of 3D space, and if the camera is pointing in the default positive z direction, then positioning an entity with a z value of above 0 will make it appear in front of the camera, whereas a negative z value would see it disappear behind the camera. Changing the x value would see it moving sideways, and changing the y value would see it moving up/down. <br />
  27. <br />
  28. Of course, the direction in which entities appear to move is relative to the position and orientation of the camera.
  29. <br>
  30. <br>
  31. See also: <a class=small href=MoveEntity.htm>MoveEntity</a>, <a class=small href=TranslateEntity.htm>TranslateEntity</a>, <a class=small href=PositionMesh.htm>PositionMesh</a>.
  32. </td>
  33. </tr>
  34. </table>
  35. <h1><a href=../3d_examples/PositionEntity.bb>Example</a></h1>
  36. <table>
  37. <tr>
  38. <td>
  39. ; PositionEntity Example <br />
  40. ; ---------------------- <br />
  41. <br />
  42. Graphics3D 640,480 <br />
  43. SetBuffer BackBuffer() <br />
  44. <br />
  45. camera=CreateCamera() <br />
  46. light=CreateLight() <br />
  47. <br />
  48. cone=CreateCone( 32 ) <br />
  49. <br />
  50. ; Set position values so that cone is positioned in front of camera, so we can see it to begin with <br />
  51. x#=0 <br />
  52. y#=0 <br />
  53. z#=10 <br />
  54. <br />
  55. While Not KeyDown( 1 ) <br />
  56. <br />
  57. ; Change position values depending on key pressed <br />
  58. If KeyDown( 203 )=True Then x#=x#-0.1 <br />
  59. If KeyDown( 205 )=True Then x#=x#+0.1 <br />
  60. If KeyDown( 208 )=True Then y#=y#-0.1 <br />
  61. If KeyDown( 200 )=True Then y#=y#+0.1 <br />
  62. If KeyDown( 44 )=True Then z#=z#-0.1 <br />
  63. If KeyDown( 30 )=True Then z#=z#+0.1 <br />
  64. <br />
  65. ; Position cone using position values <br />
  66. PositionEntity cone,x#,y#,z# <br />
  67. <br />
  68. RenderWorld <br />
  69. <br />
  70. Text 0,0,"Use cursor/A/Z keys to change cone position" <br />
  71. Text 0,20,"X Position: "+x# <br />
  72. Text 0,40,"Y Position: "+y# <br />
  73. Text 0,60,"Z Position: "+z# <br />
  74. <br />
  75. Flip <br />
  76. <br />
  77. Wend <br />
  78. <br />
  79. End
  80. </td>
  81. </tr>
  82. </table>
  83. <br>
  84. <a target=_top href=../index.htm>Index</a><br>
  85. <br>
  86. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=PositionEntity&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  87. </html>