fHierarchD.pas 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. unit fHierarchD;
  2. interface
  3. uses
  4. System.Classes,
  5. System.SysUtils,
  6. System.Math,
  7. Vcl.Forms,
  8. Vcl.ComCtrls,
  9. Vcl.ExtCtrls,
  10. Vcl.StdCtrls,
  11. Vcl.Controls,
  12. GLS.Scene,
  13. GLS.Objects,
  14. GLS.Cadencer,
  15. GLS.AsyncTimer,
  16. GLS.SceneViewer,
  17. GLS.Coordinates,
  18. GLS.BaseClasses, GLS.SimpleNavigation, GLS.Material;
  19. type
  20. TFormHierarchy = class(TForm)
  21. GLScene1: TGLScene;
  22. SceneViewer: TGLSceneViewer;
  23. Camera: TGLCamera;
  24. LightSource: TGLLightSource;
  25. CBPlay: TCheckBox;
  26. dcEarth: TGLDummyCube;
  27. dcMoon: TGLDummyCube;
  28. GLCadencer1: TGLCadencer;
  29. Sun: TGLSphere;
  30. Earth: TGLSphere;
  31. Moon: TGLSphere;
  32. dcSun: TGLDummyCube;
  33. GLSimpleNavigation1: TGLSimpleNavigation;
  34. GLMaterialLibrary1: TGLMaterialLibrary;
  35. procedure FormResize(Sender: TObject);
  36. procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  37. procedure GLCadencer1Progress(Sender: TObject;
  38. const deltaTime, newTime: Double);
  39. procedure FormCreate(Sender: TObject);
  40. private
  41. public
  42. end;
  43. var
  44. FormHierarchy: TFormHierarchy;
  45. implementation
  46. {$R *.DFM}
  47. procedure TFormHierarchy.FormCreate(Sender: TObject);
  48. begin
  49. //
  50. end;
  51. procedure TFormHierarchy.GLCadencer1Progress(Sender: TObject;
  52. const deltaTime, newTime: Double);
  53. begin
  54. if CBPlay.Checked and Visible then
  55. begin
  56. // the "sun" spins slowly
  57. dcSun.Turn(deltaTime * 10);
  58. // "earth" rotates around the sun and spins
  59. dcEarth.Turn(deltaTime * 20);
  60. Earth.Turn(deltaTime * 40);
  61. // "moon" rotates around earth and spins
  62. dcMoon.Turn(deltaTime * 40);
  63. Moon.Turn(deltaTime * 80);
  64. end;
  65. SceneViewer.Invalidate;
  66. end;
  67. procedure TFormHierarchy.FormResize(Sender: TObject);
  68. begin
  69. SceneViewer.ResetPerformanceMonitor;
  70. end;
  71. procedure TFormHierarchy.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  72. begin
  73. // We need to stop playing here :
  74. // since the timer is asynchronous, if we don't stop play,
  75. // it may get triggered during the form's destruction
  76. CBPlay.Checked := False;
  77. end;
  78. end.