fPawnC.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "fPawnC.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. TFormPawn *FormPawn;
  16. //---------------------------------------------------------------------------
  17. __fastcall TFormPawn::TFormPawn(TComponent* Owner)
  18. : TForm(Owner)
  19. {
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TFormPawn::FormCreate(TObject *Sender)
  23. {
  24. TFileName PathToData = GetCurrentAssetPath();
  25. SetCurrentDir(PathToData + "\\texture");
  26. RotationSolid1->Material->Texture->Image->LoadFromFile("ashwood.jpg");
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TFormPawn::CheckBox1Click(TObject *Sender)
  30. {
  31. if (CheckBox1->Checked)
  32. RotationSolid1->SplineMode = lsmCubicSpline;
  33. else
  34. RotationSolid1->SplineMode = lsmLines;
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TFormPawn::CheckBox2Click(TObject *Sender)
  38. {
  39. if (CheckBox2->Checked)
  40. RotationSolid1->Normals = nsSmooth;
  41. else
  42. RotationSolid1->Normals = nsFlat;
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TFormPawn::CheckBox3Click(TObject *Sender)
  46. {
  47. RotationSolid1->Material->Texture->Disabled = !CheckBox3->Checked;
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TFormPawn::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 TFormPawn::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 TFormPawn::TrackBar2Change(TObject *Sender)
  68. {
  69. RotationSolid1->Slices = TrackBar2->Position;
  70. }
  71. //---------------------------------------------------------------------------
  72. void __fastcall TFormPawn::TrackBar3Change(TObject *Sender)
  73. {
  74. RotationSolid1->Division = TrackBar3->Position;
  75. }
  76. //---------------------------------------------------------------------------
  77. void __fastcall TFormPawn::Timer1Timer(TObject *Sender)
  78. {
  79. LabelTri->Caption = Format("%d Triangles", ARRAYOFCONST((RotationSolid1->TriangleCount)));
  80. }
  81. //---------------------------------------------------------------------------
  82. void __fastcall TFormPawn::GLSceneViewer1MouseDown(TObject *Sender, TMouseButton Button,
  83. TShiftState Shift, int X, int Y)
  84. {
  85. mx = X; my = Y;
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TFormPawn::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. //---------------------------------------------------------------------------