fMegaCubeC.cpp 2.4 KB

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