fPathControlC.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // ---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "fPathControlC.h"
  5. // ---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLS.BaseClasses"
  8. #pragma link "GLS.Cadencer"
  9. #pragma link "GLS.Coordinates"
  10. #pragma link "GLS.Objects"
  11. #pragma link "GLS.Scene"
  12. #pragma link "GLS.SimpleNavigation"
  13. #pragma link "GLS.SceneViewer"
  14. #pragma resource "*.dfm"
  15. TFormPathControl *FormPathControl;
  16. // ---------------------------------------------------------------------------
  17. __fastcall TFormPathControl::TFormPathControl(TComponent* Owner) : TForm(Owner) {
  18. }
  19. void TFormPathControl::PathTravelStop(TObject *Sender, TGLMovementPath *Path, bool Looped)
  20. {
  21. if (!Application->Terminated)
  22. InformationDlg("Path Travel Stopped");
  23. }
  24. void TFormPathControl::PathAllTravelledOver(TObject *Sender) {
  25. if (!Application->Terminated)
  26. InformationDlg("All Path(es) Traveled Over");
  27. }
  28. // ---------------------------------------------------------------------------
  29. void __fastcall TFormPathControl::FormActivate(TObject *Sender) {
  30. TGLMovement *Movement;
  31. TGLMovementPath *Path;
  32. TGLPathNode *Node;
  33. // Create a movement, a path and the first node of the path.
  34. Movement = GetOrCreateMovement(Cube2);
  35. // Movement->OnPathTravelStop = PathTravelStop();
  36. // Movement->OnAllPathTravelledOver = PathAllTravelledOver();
  37. Path = Movement->AddPath();
  38. Path->ShowPath = True;
  39. // Path.StartTime := 2;
  40. // Path.Looped := True;
  41. Node = Path->AddNodeFromObject(Cube2);
  42. Node->Speed = 4.0;
  43. // Add a node.
  44. Node = Path->AddNode();
  45. Node->Speed = 4.0;
  46. Node->PositionAsVector = VectorMake(-10, 0, 0, 1);
  47. Node->RotationAsVector = VectorMake(0, 0, 0);
  48. // Add a node.
  49. Node = Path->AddNode();
  50. Node->Speed = 4.0;
  51. Node->PositionAsVector = VectorMake(0, 5, -5);
  52. Node->RotationAsVector = VectorMake(0, 90, 0);
  53. // Add a node.
  54. Node = Path->AddNode();
  55. Node->Speed = 4.0;
  56. Node->PositionAsVector = VectorMake(6, -5, 2);
  57. Node->RotationAsVector = VectorMake(0, 180, 0);
  58. // Add a node.
  59. Node = Path->AddNode();
  60. Node->Speed = 4.0;
  61. Node->PositionAsVector = VectorMake(-6, 0, 0);
  62. Node->RotationAsVector = VectorMake(0, 259, 0);
  63. // Activatived the current path.
  64. Movement->ActivePathIndex = 0;
  65. }
  66. // ---------------------------------------------------------------------------
  67. void __fastcall TFormPathControl::MoveBtnClick(TObject *Sender) {
  68. TGLMovement *Movement;
  69. Movement = GetMovement(Cube2);
  70. if (Movement) {
  71. Movement->StartPathTravel();
  72. GLCadencer1->Enabled = true;
  73. }
  74. }
  75. // ---------------------------------------------------------------------------