fManualD.pas 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. unit fManualD;
  2. interface
  3. uses
  4. System.SysUtils,
  5. System.Math,
  6. System.Classes,
  7. Vcl.Controls,
  8. Vcl.Dialogs,
  9. Vcl.Forms,
  10. Vcl.ComCtrls,
  11. Vcl.ExtCtrls,
  12. Vcl.StdCtrls,
  13. GLS.Scene,
  14. GLScene.VectorTypes,
  15. GLS.Objects,
  16. GLS.Cadencer,
  17. GLS.SceneViewer,
  18. GLS.Coordinates,
  19. GLS.BaseClasses;
  20. type
  21. TFormManual = class(TForm)
  22. Scene: TGLScene;
  23. SceneViewer: TGLSceneViewer;
  24. TrackBar: TTrackBar;
  25. CubeSun: TGLCube;
  26. CubeMoon: TGLCube;
  27. CubeEarth: TGLCube;
  28. Camera: TGLCamera;
  29. LightSource: TGLLightSource;
  30. CBPlay: TCheckBox;
  31. StaticText1: TStaticText;
  32. Cadencer: TGLCadencer;
  33. procedure TrackBarChange(Sender: TObject);
  34. procedure FormResize(Sender: TObject);
  35. procedure CadencerProgress(Sender: TObject;
  36. const deltaTime, newTime: Double);
  37. private
  38. public
  39. end;
  40. var
  41. FormManual: TFormManual;
  42. implementation
  43. {$R *.DFM}
  44. procedure TFormManual.TrackBarChange(Sender: TObject);
  45. var
  46. t: Integer;
  47. begin
  48. t := TrackBar.Position;
  49. // the "sun" turns slowly around Y axis
  50. CubeSun.TurnAngle := t / 4;
  51. // "earth" rotates around the sun on the Y axis
  52. CubeEarth.Position.X := 3 * cos(DegToRad(t));
  53. CubeEarth.Position.Z := 3 * sin(DegToRad(t));
  54. // "moon" rotates around earth on the X axis
  55. CubeMoon.Position.X := CubeEarth.Position.X;
  56. CubeMoon.Position.Y := CubeEarth.Position.Y + 1 * cos(DegToRad(3 * t));
  57. CubeMoon.Position.Z := CubeEarth.Position.Z + 1 * sin(DegToRad(3 * t));
  58. // update FPS count
  59. StaticText1.Caption := IntToStr(Trunc(SceneViewer.FramesPerSecond)) + ' FPS';
  60. end;
  61. procedure TFormManual.CadencerProgress(Sender: TObject;
  62. const deltaTime, newTime: Double);
  63. begin
  64. if CBPlay.Checked and Visible then
  65. begin
  66. // simulate a user action on the trackbar...
  67. TrackBar.Position := ((TrackBar.Position + 1) mod 360);
  68. end;
  69. end;
  70. procedure TFormManual.FormResize(Sender: TObject);
  71. begin
  72. SceneViewer.ResetPerformanceMonitor;
  73. end;
  74. end.