fBendingC.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #include <math.h>
  5. #include <string.h>
  6. #pragma hdrstop
  7. #include "fBendingC.h"
  8. //---------------------------------------------------------------------------
  9. #pragma package(smart_init)
  10. #pragma link "GLS.BaseClasses"
  11. #pragma link "GLS.Cadencer"
  12. #pragma link "GLS.Coordinates"
  13. #pragma link "GLS.Extrusion"
  14. #pragma link "GLS.Objects"
  15. #pragma link "GLS.Scene"
  16. #pragma link "GLS.SceneViewer"
  17. #pragma resource "*.dfm"
  18. TFormBending *FormBending;
  19. //---------------------------------------------------------------------------
  20. __fastcall TFormBending::TFormBending(TComponent* Owner)
  21. : TForm(Owner)
  22. {
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TFormBending::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 TFormBending::CBSplineClick(TObject *Sender)
  43. {
  44. if (CBSpline->Checked)
  45. Pipe1->SplineMode = lsmCubicSpline;
  46. else
  47. Pipe1->SplineMode = lsmLines;
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TFormBending::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button,
  51. TShiftState Shift, int X, int Y)
  52. {
  53. my = X; my = Y;
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TFormBending::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 TFormBending::Timer1Timer(TObject *Sender)
  65. {
  66. /*
  67. PanelFPS->Caption = Format("%d Triangles, %.1f FPS",
  68. ARRAYOFCONST((Pipe1->TriangleCount, GLSceneViewer1->FramesPerSecond())));
  69. */
  70. String s1 = Pipe1->TriangleCount;
  71. String s2 = GLSceneViewer1->FramesPerSecond();
  72. PanelFPS->Caption = s1 + " " + s2;
  73. GLSceneViewer1->ResetPerformanceMonitor();
  74. }
  75. //---------------------------------------------------------------------------