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