Unit1.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLBaseClasses"
  9. #pragma link "GLCoordinates"
  10. #pragma link "GLCrossPlatform"
  11. #pragma link "GLExtrusion"
  12. #pragma link "GLObjects"
  13. #pragma link "GLScene"
  14. #pragma link "GLWin32Viewer"
  15. #pragma resource "*.dfm"
  16. TForm1 *Form1;
  17. //---------------------------------------------------------------------------
  18. __fastcall TForm1::TForm1(TComponent* Owner)
  19. : TForm(Owner)
  20. {
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::FormCreate(TObject *Sender)
  24. {
  25. SetGLSceneMediaDir();
  26. RotationSolid1->Material->Texture->Image->LoadFromFile("ashwood.jpg");
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::CheckBox1Click(TObject *Sender)
  30. {
  31. if (CheckBox1->Checked)
  32. RotationSolid1->SplineMode = lsmCubicSpline;
  33. else
  34. RotationSolid1->SplineMode = lsmLines;
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TForm1::CheckBox2Click(TObject *Sender)
  38. {
  39. if (CheckBox2->Checked)
  40. RotationSolid1->Normals = nsSmooth;
  41. else
  42. RotationSolid1->Normals = nsFlat;
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TForm1::CheckBox3Click(TObject *Sender)
  46. {
  47. RotationSolid1->Material->Texture->Disabled = !CheckBox3->Checked;
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TForm1::CheckBox4Click(TObject *Sender)
  51. {
  52. if (CheckBox4->Checked)
  53. RotationSolid1->Material->Texture->TextureMode = tmModulate;
  54. else
  55. RotationSolid1->Material->Texture->TextureMode = tmDecal;
  56. }
  57. //---------------------------------------------------------------------------
  58. void __fastcall TForm1::TrackBar1Change(TObject *Sender)
  59. {
  60. RotationSolid1->StopAngle = TrackBar1->Position;
  61. if (TrackBar1->Position==360)
  62. RotationSolid1->Parts = RotationSolid1->Parts<<rspStartPolygon, rspStopPolygon;
  63. else
  64. RotationSolid1->Parts = RotationSolid1->Parts<<rspStartPolygon, rspStopPolygon;
  65. }
  66. //---------------------------------------------------------------------------
  67. void __fastcall TForm1::TrackBar2Change(TObject *Sender)
  68. {
  69. RotationSolid1->Slices = TrackBar2->Position;
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TForm1::TrackBar3Change(TObject *Sender)
  73. {
  74. RotationSolid1->Division = TrackBar3->Position;
  75. }
  76. //---------------------------------------------------------------------------
  77. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  78. {
  79. LabelTri->Caption = Format("%d Triangles", ARRAYOFCONST((RotationSolid1->TriangleCount)));
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TForm1::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button,
  83. TShiftState Shift, int X, int Y)
  84. {
  85. mx = X; my = Y;
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TForm1::GLSceneViewer1MouseMove(TObject *Sender, TShiftState Shift,
  89. int X, int Y)
  90. {
  91. if (Shift.Contains(ssLeft))
  92. GLCamera1->MoveAroundTarget(my-Y, mx-X);
  93. mx = X; my = Y;
  94. }
  95. //---------------------------------------------------------------------------