fManual.pas 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. unit fManual;
  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. GLS.VectorTypes,
  15. GLS.Objects,
  16. GLS.Cadencer,
  17. GLS.SceneViewer,
  18. GLS.Coordinates,
  19. GLS.BaseClasses;
  20. type
  21. TFormManual = class(TForm)
  22. GLScene1: TGLScene;
  23. GLSceneViewer1: TGLSceneViewer;
  24. TrackBar: TTrackBar;
  25. Cube1: TGLCube;
  26. Cube3: TGLCube;
  27. Cube2: TGLCube;
  28. GLCamera1: TGLCamera;
  29. GLLightSource1: TGLLightSource;
  30. CBPlay: TCheckBox;
  31. StaticText1: TStaticText;
  32. GLCadencer1: TGLCadencer;
  33. procedure TrackBarChange(Sender: TObject);
  34. procedure FormResize(Sender: TObject);
  35. procedure GLCadencer1Progress(Sender: TObject; const deltaTime,
  36. newTime: Double);
  37. private
  38. { Private declarations }
  39. public
  40. end;
  41. var
  42. FormManual: TFormManual;
  43. implementation
  44. {$R *.DFM}
  45. procedure TFormManual.TrackBarChange(Sender: TObject);
  46. var
  47. t : Integer;
  48. begin
  49. t:=TrackBar.Position;
  50. // the "sun" turns slowly around Y axis
  51. Cube1.TurnAngle:=t/4;
  52. // "earth" rotates around the sun on the Y axis
  53. with Cube2.Position do begin
  54. X:=3*cos(DegToRad(t));
  55. Z:=3*sin(DegToRad(t));
  56. end;
  57. // "moon" rotates around earth on the X axis
  58. with Cube3.Position do begin
  59. X:=Cube2.Position.X;
  60. Y:=Cube2.Position.Y+1*cos(DegToRad(3*t));
  61. Z:=Cube2.Position.Z+1*sin(DegToRad(3*t));
  62. end;
  63. // update FPS count
  64. StaticText1.Caption:=IntToStr(Trunc(GLSceneViewer1.FramesPerSecond))+' FPS';
  65. end;
  66. procedure TFormManual.GLCadencer1Progress(Sender: TObject; const deltaTime,
  67. newTime: Double);
  68. begin
  69. if CBPlay.Checked and Visible then begin
  70. // simulate a user action on the trackbar...
  71. TrackBar.Position:=((TrackBar.Position+1) mod 360);
  72. end;
  73. end;
  74. procedure TFormManual.FormResize(Sender: TObject);
  75. begin
  76. GLSceneViewer1.ResetPerformanceMonitor;
  77. end;
  78. end.