123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- unit GBE.PlayerPosition;
- interface
- uses
- System.SysUtils,
- System.Classes,
- System.Math.Vectors,
- FMX.Types,
- FMX.Controls3D,
- FMX.Objects3D;
- type
- TGBETypePosition = (firstPerson, thirdPerson, other);
- TGBEPlayerPosition = class(TDummy)
- private
- fDummyOrientation, fNextPosition, fPositionDirection: TDummy;
- fCamera: TCamera;
- fTypePosition: TGBETypePosition;
- fWidth: single;
- fDepth: single;
- fHeight: single;
- function GetPositionCamera: TPoint3D;
- procedure SetPositionCamera(const Value: TPoint3D);
- function GetAngleOfView: single;
- procedure SetAngleOfView(const Value: single);
- procedure SetTypePosition(const Value: TGBETypePosition);
- procedure SetWidth(const Value: single);
- procedure SetDepth(const Value: single);
- procedure SetHeight(const Value: single);
- protected
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- function GetDummyOrientation: TDummy;
- function GetCamera: TCamera;
- function GetPositionDirection: TDummy;
- published
- property PositionCameraThirdPerson: TPoint3D read GetPositionCamera
- write SetPositionCamera;
- property AngleOfView: single read GetAngleOfView write SetAngleOfView;
- property TypePosition: TGBETypePosition read fTypePosition
- write SetTypePosition;
- property NextPosition: TDummy read fNextPosition write fNextPosition;
- property HitTest default False;
- property Width: single read fWidth write SetWidth;
- property Height: single read fHeight write SetHeight;
- property Depth: single read fDepth write SetDepth;
- end;
- procedure Register;
- implementation // --------------------------------------------------------------
- // TGBEPlayerPosition
- constructor TGBEPlayerPosition.Create(AOwner: TComponent);
- begin
- inherited;
- fDummyOrientation := TDummy.Create(Self);
- fDummyOrientation.Locked := true;
- fDummyOrientation.Stored := False;
- fDummyOrientation.Width := Self.Width;
- fDummyOrientation.Height := Self.Height;
- fDummyOrientation.Depth := Self.Depth;
- AddObject(fDummyOrientation);
- fCamera := TCamera.Create(Self);
- fCamera.Parent := fDummyOrientation;
- fNextPosition := TDummy.Create(Self);
- fNextPosition.Locked := true;
- fNextPosition.Stored := False;
- fNextPosition.Width := Self.Width;
- fNextPosition.Height := Self.Height;
- fNextPosition.Depth := Self.Depth;
- fPositionDirection := TDummy.Create(Self);
- fPositionDirection.Locked := true;
- fPositionDirection.Stored := False;
- fPositionDirection.Width := Self.Width;
- fPositionDirection.Height := Self.Height;
- fPositionDirection.Depth := Self.Depth;
- fPositionDirection.Parent := fDummyOrientation;
- fPositionDirection.position.X := 0;
- fPositionDirection.position.Y := 0;
- fPositionDirection.position.Z := -0.01;
- fTypePosition := TGBETypePosition.thirdPerson;
- end;
- destructor TGBEPlayerPosition.Destroy;
- begin
- DoDeleteChildren;
- inherited;
- end;
- function TGBEPlayerPosition.GetAngleOfView: single;
- begin
- result := fCamera.AngleOfView;
- end;
- function TGBEPlayerPosition.GetCamera: TCamera;
- begin
- result := fCamera;
- end;
- function TGBEPlayerPosition.GetPositionDirection: TDummy;
- begin
- result := fPositionDirection;
- end;
- function TGBEPlayerPosition.GetDummyOrientation: TDummy;
- begin
- result := fDummyOrientation;
- end;
- function TGBEPlayerPosition.GetPositionCamera: TPoint3D;
- begin
- result := fCamera.position.Point;
- end;
- procedure TGBEPlayerPosition.SetAngleOfView(const Value: single);
- begin
- fCamera.AngleOfView := Value;
- end;
- procedure TGBEPlayerPosition.SetDepth(const Value: single);
- begin
- fDepth := Value;
- fDummyOrientation.Depth := Value;
- fNextPosition.Depth := Value;
- fPositionDirection.Depth := Value;
- end;
- procedure TGBEPlayerPosition.SetHeight(const Value: single);
- begin
- fHeight := Value;
- fDummyOrientation.Height := Value;
- fNextPosition.Height := Value;
- fPositionDirection.Height := Value;
- end;
- procedure TGBEPlayerPosition.SetPositionCamera(const Value: TPoint3D);
- begin
- fCamera.position.Point := Value;
- end;
- procedure TGBEPlayerPosition.SetTypePosition(const Value: TGBETypePosition);
- begin
- fTypePosition := Value;
- case Value of
- firstPerson:
- begin
- fCamera.position.Point := Point3D(0, 0, 0);
- fCamera.Target := nil;
- end;
- thirdPerson:
- begin
- fCamera.position.Point := Point3D(0, -1, -3);
- fCamera.Target := Self;
- end;
- other:
- begin
- fCamera.Target := nil;
- end;
- end;
- end;
- procedure TGBEPlayerPosition.SetWidth(const Value: single);
- begin
- fWidth := Value;
- fDummyOrientation.Width := Value;
- fNextPosition.Width := Value;
- fPositionDirection.Width := Value;
- end;
- procedure Register;
- begin
- RegisterComponents('GXScene GBE', [TGBEPlayerPosition]);
- end;
- end.
|