1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "GLS.BaseClasses"
- #pragma link "GLS.Cadencer"
- #pragma link "GLS.Coordinates"
- #pragma link "GLS.ExplosionFx"
- #pragma link "GLS.Scene"
- #pragma link "GLS.VectorFileObjects"
- #pragma link "GLS.SceneViewer"
- #pragma link "GLS.File3DS"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- SetGLSceneMediaDir();
- //load mesh
- mesh->LoadFromFile("mushroom.3ds");
- //cache information
- Cache = new TGLMeshObjectList;
- Cache->Assign(mesh->MeshObjects);
- //default settings
- expl = (TGLBExplosionFX *)(mesh->Effects->Items[0]);
- expl->MaxSteps = 0;
- expl->Speed = 0.1;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CheckOnClick(TObject *Sender)
- {
- //turn on/off
- expl->Enabled = CheckOn->Checked;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- //reset simulation
- expl->Reset();
- CheckOn->Checked = false;
- //restore the mesh
- mesh->MeshObjects->Assign(Cache);
- mesh->StructureChanged();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ViewerMouseMove(TObject *Sender, TShiftState Shift, int X,
- int Y)
- {
- if (Shift.Contains(ssLeft))
- {
- Camera1->MoveAroundTarget(Y - vy, X - vx);
- vx = X; vy = Y;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::ViewerMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
- int X, int Y)
- {
- vx = X; vy = Y;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
- const double newTime)
- {
- Viewer->Invalidate();
- StepBar->Position = expl->Step;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::SpeedBarChange(TObject *Sender)
- {
- expl->Speed = (float) SpeedBar->Position / 10;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::MaxStepsBarChange(TObject *Sender)
- {
- expl->MaxSteps = MaxStepsBar->Position;
- StepBar->Max = MaxStepsBar->Position;
- }
- //---------------------------------------------------------------------------
|