Unit1.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 "GLS.BaseClasses"
  9. #pragma link "GLS.Behaviours"
  10. #pragma link "GLS.BitmapFont"
  11. #pragma link "GLS.Blur"
  12. #pragma link "GLS.Cadencer"
  13. #pragma link "GLS.Coordinates"
  14. #pragma link "GLS.HUDObjects"
  15. #pragma link "GLS.Navigator"
  16. #pragma link "GLS.Objects"
  17. #pragma link "GLS.ParticleFX"
  18. #pragma link "GLS.PerlinPFX"
  19. #pragma link "GLS.Scene"
  20. #pragma link "GLS.SpaceText"
  21. #pragma link "GLS.SceneViewer"
  22. #include "GLS.Keyboard.hpp"
  23. #pragma resource "*.dfm"
  24. TForm1 *Form1;
  25. int cRunBoost = 10;
  26. int cWalkStep = 20;
  27. int cStrafeStep =20;
  28. //---------------------------------------------------------------------------
  29. __fastcall TForm1::TForm1(TComponent* Owner)
  30. : TForm(Owner)
  31. {
  32. }
  33. //---------------------------------------------------------------------------
  34. void __fastcall TForm1::FormCreate(TObject *Sender)
  35. {
  36. chkFloorClick(Sender);
  37. }
  38. //---------------------------------------------------------------------------
  39. void __fastcall TForm1::chkFloorClick(TObject *Sender)
  40. {
  41. GLPlane1->Visible = chkFloor->Checked;
  42. }
  43. //---------------------------------------------------------------------------
  44. void __fastcall TForm1::chkBlurClick(TObject *Sender)
  45. {
  46. GLBlur1->Visible = chkBlur->Checked;
  47. }
  48. //---------------------------------------------------------------------------
  49. void __fastcall TForm1::chkMouseLookClick(TObject *Sender)
  50. {
  51. GLUserInterface1->MouseLookActive = chkMouseLook->Checked;
  52. }
  53. //---------------------------------------------------------------------------
  54. void __fastcall TForm1::Timer1Timer(TObject *Sender)
  55. {
  56. Caption = "PFXGallery FPS - " + IntToStr(Round(GLSceneViewer1->FramesPerSecond()));
  57. GLSceneViewer1->ResetPerformanceMonitor();
  58. }
  59. //---------------------------------------------------------------------------
  60. void __fastcall TForm1::GLCadencer1Progress(TObject *Sender, const double deltaTime,
  61. const double newTime)
  62. {
  63. HandleKeys(deltaTime);
  64. GLUserInterface1->MouseLook();
  65. GLSceneViewer1->Invalidate();
  66. GLUserInterface1->MouseUpdate();
  67. GLSceneViewer1->Invalidate();
  68. }
  69. //---------------------------------------------------------------------------
  70. void __fastcall TForm1::HandleKeys(double deltaTime)
  71. {
  72. float boost;
  73. if (IsKeyDown(vkEscape)) {
  74. chkMouseLook->Checked = false;
  75. chkMouseLookClick(this);
  76. }
  77. if (IsKeyDown(vkShift))
  78. boost = cRunBoost*deltaTime;
  79. else
  80. if (IsKeyDown(vkControl))
  81. boost = cRunBoost*0.01*deltaTime;
  82. else
  83. boost = deltaTime;
  84. if (IsKeyDown('W'))
  85. GLCamera1->Move(cWalkStep*boost);
  86. if (IsKeyDown('S'))
  87. GLCamera1->Move(-cWalkStep*boost);
  88. if (IsKeyDown('A'))
  89. GLCamera1->Slide(-cStrafeStep*boost);
  90. if (IsKeyDown('D'))
  91. GLCamera1->Slide(cStrafeStep*boost);
  92. }
  93. //---------------------------------------------------------------------------