fThorC.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "fThorC.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma link "GLS.BaseClasses"
  8. #pragma link "GLS.Cadencer"
  9. #pragma link "GLS.Coordinates"
  10. #pragma link "GLS.Graph"
  11. #pragma link "GLS.Objects"
  12. #pragma link "GLS.Scene"
  13. #pragma link "GLS.SimpleNavigation"
  14. #pragma link "GLS.SkyDome"
  15. #pragma link "GLS.ThorFX"
  16. #pragma link "GLS.SceneViewer"
  17. #pragma resource "*.dfm"
  18. TForm1 *Form1;
  19. //---------------------------------------------------------------------------
  20. __fastcall TForm1::TForm1(TComponent* Owner)
  21. : TForm(Owner)
  22. {
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TForm1::FormCreate(TObject *Sender)
  26. {
  27. TFileName Path = GetCurrentAssetPath();
  28. SetCurrentDir(Path + "\\texture");
  29. HeightField1->Material->Texture->Image->LoadFromFile("marbletiles.jpg");
  30. }
  31. //---------------------------------------------------------------------------
  32. void __fastcall TForm1::GSbarChange(TObject *Sender)
  33. {
  34. GLThorFXManager1->GlowSize = (float) GSbar->Position/50;
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TForm1::GAbarChange(TObject *Sender)
  38. {
  39. GLThorFXManager1->InnerColor->Alpha = (float) GAbar->Position/50;
  40. }
  41. //---------------------------------------------------------------------------
  42. void __fastcall TForm1::WildBarChange(TObject *Sender)
  43. {
  44. GLThorFXManager1->Wildness = (float) WildBar->Position/5;
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::VibBarChange(TObject *Sender)
  48. {
  49. GLThorFXManager1->Vibrate = (float) VibBar->Position/10;
  50. }
  51. //---------------------------------------------------------------------------
  52. void __fastcall TForm1::DistanceBarChange(TObject *Sender)
  53. {
  54. float Dist = GLCamera1->DistanceToTarget();
  55. float cx = GLCamera1->Position->X;
  56. float cy = GLCamera1->Position->Y;
  57. float cz = GLCamera1->Position->Z;
  58. float NewDist = DistanceBar->Position;
  59. GLCamera1->Position->X = (float) cx/Dist*NewDist;
  60. GLCamera1->Position->Y = (float) cy/Dist*NewDist;
  61. GLCamera1->Position->Z = (float) cz/Dist*NewDist;
  62. }
  63. //---------------------------------------------------------------------------
  64. void __fastcall TForm1::CoreBoxClick(TObject *Sender)
  65. {
  66. GLThorFXManager1->Core = CoreBox->Checked;
  67. }
  68. //---------------------------------------------------------------------------
  69. void __fastcall TForm1::GLThorFXManager1CalcPoint(TObject *Sender, int PointNo, float &x,
  70. float &y, float &z)
  71. {
  72. //---------------Add user-definable formula to individual points in thor-object-------------
  73. if (SpinBox->Checked)
  74. {
  75. float Place = (float) PointNo/GLThorFXManager1->Maxpoints;
  76. float Spin = (Place*M_PI)*10+(GLCadencer1->CurrentTime*20);
  77. float Scale = (float) Sin(Place*M_PI)/2;
  78. y = y+Sin(Spin)*Scale;
  79. x = x+Cos(Spin)*Scale;
  80. }
  81. }
  82. //---------------------------------------------------------------------------
  83. void __fastcall TForm1::PauseBoxClick(TObject *Sender)
  84. {
  85. GLThorFXManager1->Disabled = PauseBox->Checked;
  86. }
  87. //---------------------------------------------------------------------------
  88. void __fastcall TForm1::HeightField1GetHeight(const float x, const float y, float &z,
  89. TVector4f &Color, TTexPoint &TexPoint)
  90. {
  91. z = 2;
  92. }
  93. //---------------------------------------------------------------------------