fMainC.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "fMainC.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLS.BaseClasses"
  9. #pragma link "GLS.Cadencer"
  10. #pragma link "GLS.Coordinates"
  11. #pragma link "GLS.Objects"
  12. #pragma link "GLS.Scene"
  13. #pragma link "GLS.SimpleNavigation"
  14. #pragma link "GLS.SceneViewer"
  15. #pragma resource "*.dfm"
  16. TForm1 *Form1;
  17. const int
  18. cSize = 10;
  19. //---------------------------------------------------------------------------
  20. __fastcall TForm1::TForm1(TComponent* Owner)
  21. : TForm(Owner)
  22. {
  23. int x, y, z;
  24. TGLCube *cube;
  25. float factor, cubeSize;
  26. // bench only creation and 1st render (with lists builds, etc...)
  27. factor = 70 / (cSize * 2 + 1);
  28. cubeSize = 0.4 * factor;
  29. for (x = -cSize; x< cSize; x++)
  30. for (y = -cSize; y< cSize; y++)
  31. for (z = -cSize; z< cSize; z++)
  32. {
  33. cube = (TGLCube *) (DummyCube1->AddNewChild(__classid(TGLCube)));
  34. cube->Position->AsVector = PointMake(factor * x, factor * y, factor * z);
  35. cube->CubeWidth = cubeSize;
  36. cube->CubeHeight = cubeSize;
  37. cube->CubeDepth = cubeSize;
  38. cube->Material->BlendingMode = bmTransparency;
  39. cube->Material->FrontProperties->Diffuse->Color =
  40. VectorLerp(clrBlue, clrWhite, (float)(x * x + y * y + z * z)/(cSize * cSize * 3));
  41. cube->Material->FrontProperties->Diffuse->Alpha = 0.5;
  42. }
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  46. const double newTime)
  47. {
  48. DummyCube1->TurnAngle = 90 * newTime; // 90° per second
  49. }
  50. //---------------------------------------------------------------------------