Unit1.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 "GLWin32Viewer"
  14. #pragma resource "*.dfm"
  15. TForm1 *Form1;
  16. //---------------------------------------------------------------------------
  17. __fastcall TForm1::TForm1(TComponent* Owner)
  18. : TForm(Owner)
  19. {
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TForm1::TrackBarChange(TObject *Sender)
  23. {
  24. int t;
  25. t = TrackBar->Position;
  26. // the "sun" turns slowly around Y axis
  27. Cube1->TurnAngle = t/4;
  28. // "earth" rotates around the sun on the Y axis
  29. Cube2->Position->X =3*cos(DegToRad((float)t));
  30. Cube2->Position->Z =3*sin(DegToRad((float)t));
  31. // "moon" rotates around earth on the X axis
  32. Cube3->Position->X = Cube2->Position->X;
  33. Cube3->Position->Y = Cube2->Position->Y+1*cos(DegToRad((float)3*t));
  34. Cube3->Position->Z = Cube2->Position->Z+1*sin(DegToRad((float)3*t));
  35. // update FPS count
  36. StaticText1->Caption = IntToStr(Trunc(GLSceneViewer1->FramesPerSecond()))+" FPS";
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  40. const double newTime)
  41. {
  42. if (CBPlay->Checked && Visible)
  43. // simulate a user action on the trackbar...
  44. TrackBar->Position = ((TrackBar->Position+1) % 360);
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::FormResize(TObject *Sender)
  48. {
  49. GLSceneViewer1->ResetPerformanceMonitor();
  50. }
  51. //---------------------------------------------------------------------------