fMegaCubeC.cpp 2.2 KB

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