Unit1.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <tchar.h>
  4. #pragma hdrstop
  5. #include "Unit1.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "GLBaseClasses"
  9. #pragma link "GLCadencer"
  10. #pragma link "GLCoordinates"
  11. #pragma link "GLCrossPlatform"
  12. #pragma link "GLObjects"
  13. #pragma link "GLScene"
  14. #pragma link "GLSimpleNavigation"
  15. #pragma link "GLWin32Viewer"
  16. #pragma resource "*.dfm"
  17. TForm1 *Form1;
  18. //---------------------------------------------------------------------------
  19. __fastcall TForm1::TForm1(TComponent* Owner)
  20. : TForm(Owner)
  21. {
  22. }
  23. //---------------------------------------------------------------------------
  24. const int
  25. cSize = 10;
  26. void __fastcall TForm1::FormCreate(TObject *Sender)
  27. {
  28. int x, y, z;
  29. TGLCube *cube;
  30. float factor, cubeSize;
  31. // bench only creation and 1st render (with lists builds, etc...)
  32. factor = 70 / (cSize * 2 + 1);
  33. cubeSize = 0.4 * factor;
  34. for (x = -cSize; x< cSize; x++)
  35. for (y = -cSize; y< cSize; y++)
  36. for (z = -cSize; z< cSize; z++)
  37. {
  38. cube = (TGLCube *) (DummyCube1->AddNewChild(__classid(TGLCube)));
  39. cube->Position->AsVector = PointMake(factor * x, factor * y, factor * z);
  40. cube->CubeWidth = cubeSize;
  41. cube->CubeHeight = cubeSize;
  42. cube->CubeDepth = cubeSize;
  43. cube->Material->BlendingMode = bmTransparency;
  44. cube->Material->FrontProperties->Diffuse->Color =
  45. VectorLerp(clrBlue, clrWhite, (float)(x * x + y * y + z * z)/(cSize * cSize * 3));
  46. cube->Material->FrontProperties->Diffuse->Alpha = 0.5;
  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. //---------------------------------------------------------------------------