fInvarianceD.pas 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. unit fInvarianceD;
  2. interface
  3. uses
  4. Winapi.OpenGL,
  5. System.SysUtils,
  6. System.Classes,
  7. Vcl.Graphics,
  8. Vcl.Controls,
  9. Vcl.Forms,
  10. Vcl.Dialogs,
  11. Vcl.Imaging.Jpeg,
  12. GLS.Scene,
  13. GLS.Objects,
  14. GLS.SceneViewer,
  15. GLS.Texture,
  16. GLS.GeomObjects,
  17. GLS.Material,
  18. GLS.Coordinates,
  19. GLS.BaseClasses,
  20. Stage.Utils;
  21. type
  22. TFormInvariance = class(TForm)
  23. GLScene1: TGLScene;
  24. GLSceneViewer1: TGLSceneViewer;
  25. GLCamera: TGLCamera;
  26. DCCamera: TGLDummyCube;
  27. PLGround: TGLPlane;
  28. GLLightSource1: TGLLightSource;
  29. GLMaterialLibrary: TGLMaterialLibrary;
  30. GLCube1: TGLCube;
  31. DCPositionInvariant: TGLDummyCube;
  32. GLCylinder1: TGLCylinder;
  33. GLArrowLine1: TGLArrowLine;
  34. DCOrientationInvariant: TGLDummyCube;
  35. procedure GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton;
  36. Shift: TShiftState; X, Y: Integer);
  37. procedure GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState;
  38. X, Y: Integer);
  39. procedure FormActivate(Sender: TObject);
  40. private
  41. public
  42. mx, my: Integer;
  43. end;
  44. var
  45. FormInvariance: TFormInvariance;
  46. implementation
  47. {$R *.dfm}
  48. procedure TFormInvariance.FormActivate(Sender: TObject);
  49. begin
  50. var Path: TFileName := GetCurrentAssetPath();
  51. SetCurrentDir(Path + '\texture');
  52. GLMaterialLibrary.TexturePaths := GetCurrentDir();
  53. end;
  54. procedure TFormInvariance.GLSceneViewer1MouseDown(Sender: TObject;
  55. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  56. begin
  57. mx := X;
  58. my := Y;
  59. end;
  60. procedure TFormInvariance.GLSceneViewer1MouseMove(Sender: TObject;
  61. Shift: TShiftState; X, Y: Integer);
  62. begin
  63. if ssLeft in Shift then
  64. GLCamera.MoveAroundTarget(my - Y, mx - X);
  65. if ssRight in Shift then
  66. GLCamera.MoveTargetInEyeSpace((Y - my) * 0.05, (mx - X) * 0.05, 0);
  67. mx := X;
  68. my := Y;
  69. end;
  70. end.