Unit1.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.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.SceneViewer"
  13. #pragma resource "*.dfm"
  14. TForm1 *Form1;
  15. //---------------------------------------------------------------------------
  16. __fastcall TForm1::TForm1(TComponent* Owner)
  17. : TForm(Owner)
  18. {
  19. }
  20. //---------------------------------------------------------------------------
  21. void __fastcall TForm1::TrackBarChange(TObject *Sender)
  22. {
  23. int t;
  24. t = TrackBar->Position;
  25. // the "sun" spins slowly
  26. Cube1->TurnAngle = t/4;
  27. // "earth" rotates around the sun and spins
  28. DummyCube1->TurnAngle = -t;
  29. Cube2->TurnAngle = t*2;
  30. // "moon" rotates around earth and spins
  31. DummyCube2->RollAngle = 3*t;
  32. Cube3->TurnAngle = 4*t;
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  36. const double newTime)
  37. {
  38. if (CBPlay->Checked && Visible)
  39. // simulate a user action on the trackbar...
  40. TrackBar->Position = ((TrackBar->Position+1) % 360);
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TForm1::FormResize(TObject *Sender)
  44. {
  45. GLSceneViewer1->ResetPerformanceMonitor();
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
  49. {
  50. // We need to stop playing here :
  51. // since the timer is asynchronous, if we don't stop play,
  52. // it may get triggered during the form's destruction
  53. CBPlay->Checked = false;
  54. }
  55. //---------------------------------------------------------------------------