| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "fColumnC.h"
- #include "Math.hpp"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "GLS.BaseClasses"
- #pragma link "GLS.Cadencer"
- #pragma link "GLS.Coordinates"
- #pragma link "GLS.Objects"
- #pragma link "GLS.Scene"
- #pragma link "GLS.SceneViewer"
- #pragma resource "*.dfm"
- TFormColumn *FormColumn;
- const int
- cNbPlanes = 30;
- const int
- cStackHeight = 8;
- //---------------------------------------------------------------------------
- __fastcall TFormColumn::TFormColumn(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormColumn::FormCreate(TObject *Sender)
- {
- int i;
- TGLPlane *plane;
- // our column is just a stack of planes
- for (i=0; i < cNbPlanes-1; i++)
- {
- // create planes as child of the dummycube
- plane = (TGLPlane *)(DummyCube1->AddNewChild(__classid (TGLPlane)));
- // default plane size is 1x1, we want bigger planes !
- plane->Width = 2;
- plane->Height = 2;
- // orient and position then planes in the stack
- plane->Position->Y = cStackHeight*(0.5-(float)i/cNbPlanes);
- plane->Direction->AsVector = YHmgVector;
- // we use the emission color, since there is no light in the scene
- // (allows 50+ FPS with software opengl on <400 Mhz CPUs ;)
- plane->Material->FrontProperties->Emission->Color = VectorLerp(clrBlue, clrYellow, i/cNbPlanes);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormColumn::GLCadencer1Progress(TObject *Sender, const double deltaTime,
- const double newTime)
- {
- int i;
- // for all planes (all childs of the dummycube)
- for (i=0; i < DummyCube1->Count-1; i++)
- // roll them accordingly to our time reference and position in the stack
- DummyCube1->Children[i]->RollAngle = 90*cos(newTime+i*M_PI/cNbPlanes);
- }
- //---------------------------------------------------------------------------
- void __fastcall TFormColumn::Timer1Timer(TObject *Sender)
- {
- // update FPS and reset counter for the next second
- StaticText1->Caption = GLSceneViewer1->FramesPerSecond();
- GLSceneViewer1->ResetPerformanceMonitor();
- }
- //---------------------------------------------------------------------------
|