TFormVector.htm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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>TFormVector x#, y#, z#, source_entity, dest_entity</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. x#, y#, z# = components of a vector in 3d space <br />
  13. <br />
  14. source_entity = handle of source entity, or 0 for 3d world <br />
  15. dest_entity = handle of destination entity, or 0 for 3d world
  16. </td>
  17. </tr>
  18. </table>
  19. <h1>Description</h1>
  20. <table>
  21. <tr>
  22. <td>
  23. Transforms between coordinate systems. After using TFormVector the new <br />
  24. components can be read with TFormedX(), TFormedY() and TFormedZ(). <br />
  25. <br />
  26. <br />
  27. See EntityX() for details about local coordinates. <br />
  28. <br />
  29. <br />
  30. Similar to TFormPoint, but operates on a vector. A vector can be thought of <br />
  31. as 'displacement relative to current location'. <br />
  32. <br />
  33. For example, vector (1,2,3) means one step to the right, two steps up <br />
  34. and three steps forward. <br />
  35. <br />
  36. This is analogous to PositionEntity and MoveEntity: <br />
  37. <br />
  38. PositionEntity entity, x,y,z ; put entity at point (x,y,z) <br />
  39. <br />
  40. MoveEntity entity, x,y,z ; add vector (x,y,z) to current position
  41. </td>
  42. </tr>
  43. </table>
  44. <h1><a href=../3d_examples/TFormVector.bb>Example</a></h1>
  45. <table>
  46. <tr>
  47. <td>
  48. ; TFormVector example <br />
  49. <br />
  50. Graphics3D 640, 480 <br />
  51. <br />
  52. p = CreatePivot() <br />
  53. <br />
  54. PositionEntity p, 10, 20, 30 ; easy to visualize <br />
  55. TurnEntity p, -5, -15, 25 ; hard to visualize <br />
  56. <br />
  57. ; Question: what would happen if we took one step 'forward'? <br />
  58. ; The local vector corresponding to one step forward is (0,0,1) <br />
  59. ; in the pivot's local space. We need the global version. <br />
  60. <br />
  61. TFormVector 0,0,1, p,0 ; transform from pivot to world <br />
  62. <br />
  63. message$ = "'One step forward' vector is ( " <br />
  64. message = message + TFormedX() + ", " + TFormedY() + ", " + TFormedZ() + " )" <br />
  65. <br />
  66. Text 70, 180, message <br />
  67. <br />
  68. ; Now actually take the step. The new location should be <br />
  69. ; (10,20,30) plus the vector we just computed. <br />
  70. <br />
  71. MoveEntity p, 0,0,1 <br />
  72. <br />
  73. message$ = "New location of pivot is ( " <br />
  74. message = message + EntityX(p) + ", " <br />
  75. message = message + EntityY(p) + ", " + EntityZ(p) + " )" <br />
  76. <br />
  77. Text 100, 210, message <br />
  78. <br />
  79. Flip <br />
  80. <br />
  81. WaitKey() <br />
  82. End
  83. </td>
  84. </tr>
  85. </table>
  86. <br>
  87. <a target=_top href=../index.htm>Index</a><br>
  88. <br>
  89. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=TFormVector&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  90. </html>