fCullingC.cpp 2.5 KB

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