TFormVector.bb 870 B

1234567891011121314151617181920212223242526272829303132333435
  1. ; TFormVector example
  2. Graphics3D 640, 480
  3. p = CreatePivot()
  4. PositionEntity p, 10, 20, 30 ; easy to visualize
  5. TurnEntity p, -5, -15, 25 ; hard to visualize
  6. ; Question: what would happen if we took one step 'forward'?
  7. ; The local vector corresponding to one step forward is (0,0,1)
  8. ; in the pivot's local space. We need the global version.
  9. TFormVector 0,0,1, p,0 ; transform from pivot to world
  10. message$ = "'One step forward' vector is ( "
  11. message = message + TFormedX() + ", " + TFormedY() + ", " + TFormedZ() + " )"
  12. Text 70, 180, message
  13. ; Now actually take the step. The new location should be
  14. ; (10,20,30) plus the vector we just computed.
  15. MoveEntity p, 0,0,1
  16. message$ = "New location of pivot is ( "
  17. message = message + EntityX(p) + ", "
  18. message = message + EntityY(p) + ", " + EntityZ(p) + " )"
  19. Text 100, 210, message
  20. Flip
  21. WaitKey()
  22. End