Unit1.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLWin32Viewer"
  8. #pragma link "GLScene"
  9. #pragma link "GLCadencer"
  10. #pragma link "GLMirror"
  11. #pragma link "GLObjects"
  12. #pragma link "GLGeomObjects"
  13. #pragma link "GLExtrusion"
  14. #pragma link "GLMultiPolygon"
  15. #pragma link "GLTeapot"
  16. #pragma link "GLBaseClasses"
  17. #pragma link "GLCoordinates"
  18. #pragma link "GLCrossPlatform"
  19. #pragma resource "*.dfm"
  20. TForm1 *Form1;
  21. int mx, my;
  22. //---------------------------------------------------------------------------
  23. __fastcall TForm1::TForm1(TComponent * Owner):TForm(Owner)
  24. {
  25. }
  26. //---------------------------------------------------------------------------
  27. void __fastcall TForm1::CBOpaqueClick(TObject * Sender)
  28. {
  29. if(CBOpaque->Checked)
  30. GLMirror1->MirrorOptions << moOpaque;
  31. else
  32. GLMirror1->MirrorOptions >> moOpaque;
  33. }
  34. //---------------------------------------------------------------------------
  35. void __fastcall TForm1::CBStencilClick(TObject * Sender)
  36. {
  37. if(CBStencil->Checked)
  38. GLMirror1->MirrorOptions << moUseStencil;
  39. else
  40. GLMirror1->MirrorOptions >> moUseStencil;
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TForm1::CBClearZClick(TObject * Sender)
  44. {
  45. if(CBClearZ->Checked)
  46. GLMirror1->MirrorOptions << moClearZBuffer;
  47. else
  48. GLMirror1->MirrorOptions >> moClearZBuffer;
  49. }
  50. //---------------------------------------------------------------------------
  51. void __fastcall TForm1::CBPlaneClipClick(TObject * Sender)
  52. {
  53. if(CBPlaneClip->Checked)
  54. GLMirror1->MirrorOptions << moMirrorPlaneClip;
  55. else
  56. GLMirror1->MirrorOptions >> moMirrorPlaneClip;
  57. }
  58. //---------------------------------------------------------------------------
  59. void __fastcall TForm1::Timer1Timer(TObject * Sender)
  60. {
  61. LabelFPS->Caption = GLSceneViewer1->FramesPerSecondText(1);
  62. GLSceneViewer1->ResetPerformanceMonitor();
  63. }
  64. //---------------------------------------------------------------------------
  65. void __fastcall TForm1::GLCadencer1Progress(TObject * Sender,
  66. const double deltaTime,
  67. const double newTime)
  68. {
  69. GLSceneViewer1->Invalidate();
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TForm1::FormResize(TObject * Sender)
  73. {
  74. if(GLSceneViewer1->Width > GLSceneViewer1->Height)
  75. GLCamera1->SceneScale = (float)GLSceneViewer1->Height / 300;
  76. else
  77. GLCamera1->SceneScale = (float)GLSceneViewer1->Width / 360;
  78. }
  79. //---------------------------------------------------------------------------
  80. void __fastcall TForm1::GLSceneViewer1MouseDown(TObject * Sender,
  81. TMouseButton Button,
  82. TShiftState Shift, int X, int Y)
  83. {
  84. mx = X;
  85. my = Y;
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject * Sender,
  89. TShiftState Shift, int X, int Y)
  90. {
  91. if (Shift.Contains(ssLeft))
  92. GLCamera1->MoveAroundTarget(my-Y, mx-X);
  93. else if (Shift.Contains(ssRight))
  94. GLCamera1->RotateTarget(my-Y, mx-X, 0);
  95. mx=X; my=Y;
  96. }
  97. //---------------------------------------------------------------------------
  98. void __fastcall TForm1::FormMouseWheel(TObject *Sender, TShiftState Shift, int WheelDelta,
  99. TPoint &MousePos, bool &Handled)
  100. {
  101. GLCamera1->
  102. AdjustDistanceToTarget(Power(1.1, (WheelDelta / 120.0)));
  103. }
  104. //---------------------------------------------------------------------------