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