Unit1.cpp 2.7 KB

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