fCullingC.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include <vcl.h>
  2. #pragma hdrstop
  3. #include "fCullingC.h"
  4. //---------------------------------------------------------------------------
  5. #pragma package(smart_init)
  6. #pragma link "GLS.FileMD2"
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11. : TForm(Owner)
  12. {
  13. int i, j;
  14. TGLSphere *newSphere;
  15. TGLActor *newActor;
  16. SetGLSceneMediaDir();
  17. // Spheres are used as standalone, high-polycount objects
  18. // that are highly T&L friendly
  19. for (i=-4; i<4; i++)
  20. for (j=-4; j<4; j++)
  21. {
  22. newSphere = (TGLSphere *) DCSpheres->AddNewChild(__classid(TGLSphere));
  23. newSphere->Position->SetPoint(i*5, 0, j*5);
  24. newSphere->Slices = 32;
  25. newSphere->Stacks = 32;
  26. }
  27. // Actors are used as standalone, med-polycount objects
  28. // that aren't T&L friendly (all geometry must be sent to
  29. // the hardware at each frame)
  30. GLMaterialLibrary->Materials->Items[0]->Material->Texture->Image->LoadFromFile("waste.jpg");
  31. ACReference->LoadFromFile("waste.md2");
  32. for (i=-3; i<3; i++)
  33. for (j=-3; j<3; j++)
  34. {
  35. newActor = (TGLActor *) DCActors->AddNewChild(__classid(TGLActor));
  36. newActor->Assign(ACReference);
  37. newActor->Position->SetPoint(i*10, 0, j*10);
  38. newActor->CurrentFrame = (i+2)+(j+2)*5;
  39. }
  40. ACReference->Visible = false;
  41. }
  42. //---------------------------------------------------------------------------
  43. void __fastcall TForm1::RBSpheresClick(TObject *Sender)
  44. {
  45. DCSpheres->Visible = RBSpheres->Checked;
  46. DCActors->Visible = RBActors->Checked;
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TForm1::GLCadencerProgress(TObject *Sender,
  50. const double deltaTime, const double newTime)
  51. {
  52. Viewer->Invalidate();
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  56. {
  57. LabelFPS->Caption = Format("%.1f FPS", ARRAYOFCONST((Viewer->FramesPerSecond())));
  58. Viewer->ResetPerformanceMonitor();
  59. }
  60. //---------------------------------------------------------------------------
  61. void __fastcall TForm1::RBNoneClick(TObject *Sender)
  62. {
  63. if (RBObject->Checked)
  64. GLScene->VisibilityCulling = vcObjectBased;
  65. else if (RBHierarchical->Checked)
  66. GLScene->VisibilityCulling = vcHierarchical;
  67. else GLScene->VisibilityCulling = vcNone;
  68. }
  69. //---------------------------------------------------------------------------