Unit1.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #include <math.h>
  5. #pragma hdrstop
  6. #include "Unit1.h"
  7. //---------------------------------------------------------------------------
  8. #pragma package(smart_init)
  9. #pragma link "GLS.BaseClasses"
  10. #pragma link "GLS.Cadencer"
  11. #pragma link "GLS.Coordinates"
  12. #pragma link "GLS.Extrusion"
  13. #pragma link "GLS.Objects"
  14. #pragma link "GLS.Scene"
  15. #pragma link "GLS.SceneViewer"
  16. #pragma resource "*.dfm"
  17. TForm1 *Form1;
  18. //---------------------------------------------------------------------------
  19. __fastcall TForm1::TForm1(TComponent* Owner)
  20. : TForm(Owner)
  21. {
  22. }
  23. //---------------------------------------------------------------------------
  24. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  25. const double newTime)
  26. {
  27. Pipe1->Nodes->Items[2]->X = 1*sin(newTime*5); //used 5 instead of M_PI/180 or cPIdiv180
  28. if (CBFat->Checked)
  29. {
  30. Pipe1->Nodes->Items[2]->X = 1+cos(newTime*5);
  31. Pipe1->Radius = 1;
  32. }
  33. else
  34. {
  35. // Pipe1->Nodes->RotateAroundZ(0);
  36. Pipe1->Nodes->Items[2]->X = 1*sin(newTime*5);
  37. Pipe1->Radius = 0.2;
  38. }
  39. }
  40. //---------------------------------------------------------------------------
  41. void __fastcall TForm1::CBSplineClick(TObject *Sender)
  42. {
  43. if (CBSpline->Checked)
  44. Pipe1->SplineMode = lsmCubicSpline;
  45. else
  46. Pipe1->SplineMode = lsmLines;
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TForm1::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button,
  50. TShiftState Shift, int X, int Y)
  51. {
  52. my = X; my = Y;
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject *Sender, TShiftState Shift,
  56. int X, int Y)
  57. {
  58. if (Shift.Contains(ssLeft))
  59. GLCamera1->MoveAroundTarget(my-Y, mx-X);
  60. mx = X; my = Y;
  61. }
  62. //---------------------------------------------------------------------------
  63. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  64. {
  65. PanelFPS->Caption = Format("%d Triangles, %.1f FPS",
  66. ARRAYOFCONST((Pipe1->TriangleCount, GLSceneViewer1->FramesPerSecond())));
  67. GLSceneViewer1->ResetPerformanceMonitor();
  68. }
  69. //---------------------------------------------------------------------------