fMegaCubeC.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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
  16. cSize = 5;
  17. //---------------------------------------------------------------------------
  18. __fastcall TFormMegacube::TFormMegacube(TComponent* Owner)
  19. : TForm(Owner)
  20. {
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TFormMegacube::FormCreate(TObject *Sender)
  24. {
  25. int x, y, z;
  26. TGLCube *cube;
  27. float factor, cubeSize;
  28. // bench only creation and 1st render (with lists builds, etc...)
  29. factor = 70 / (cSize * 2 + 1);
  30. cubeSize = 0.4 * factor;
  31. for (x = -cSize; x< cSize; x++)
  32. for (y = -cSize; y< cSize; y++)
  33. for (z = -cSize; z< cSize; z++)
  34. {
  35. cube = (TGLCube *) (DummyCube1->AddNewChild(__classid(TGLCube)));
  36. cube->Position->AsVector = PointMake(factor * x, factor * y, factor * z);
  37. cube->CubeWidth = cubeSize;
  38. cube->CubeHeight = cubeSize;
  39. cube->CubeDepth = cubeSize;
  40. cube->Material->FrontProperties->Diffuse->Color =
  41. VectorLerp(clrYellow, clrRed, (float)(x * x + y * y + z * z)/(cSize * cSize * 3));
  42. // uncomment following lines to stress OpenGL with more color changes calls
  43. //cube->Material->FrontProperties->Ambient->Color=VectorLerp(clrYellow, clrRed, (x*x+y*y+z*z)/(cSize*cSize*3));
  44. //cube->Material->FrontProperties->Emission->Color=VectorLerp(clrYellow, clrRed, (x*x+y*y+z*z)/(cSize*cSize*3));
  45. //cube->Material->FrontProperties->Specular->Color=VectorLerp(clrYellow, clrRed, (x*x+y*y+z*z)/(cSize*cSize*3));
  46. }
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TFormMegacube::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  50. const double newTime)
  51. {
  52. DummyCube1->TurnAngle = 90 * newTime; // 90° per second
  53. }
  54. //---------------------------------------------------------------------------