-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathGBEPlayerPosition.pas
178 lines (152 loc) · 4.79 KB
/
GBEPlayerPosition.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
unit GBEPlayerPosition;
interface
uses
System.SysUtils, System.Classes, FMX.Types, FMX.Controls3D, FMX.Objects3D, System.Math.Vectors;
type
TGBETypePosition = (firstPerson, thirdPerson, other);
TGBEPlayerPosition = class(TDummy)
private
{ Déclarations privées }
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
{ Déclarations protégées }
public
{ Déclarations publiques }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function getDummyOrientation: TDummy;
function getCamera: TCamera;
function getPositionDirection: TDummy;
published
{ Déclarations publiées }
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
procedure Register;
begin
RegisterComponents('GBE3D', [TGBEPlayerPosition]);
end;
{ 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;
end.