1 | type
|
---|
2 | { TBGRAObject3D }
|
---|
3 |
|
---|
4 | TBGRAObject3D = class(TInterfacedObject,IBGRAObject3D)
|
---|
5 | private
|
---|
6 | FColor: TBGRAPixel;
|
---|
7 | FLight: Single;
|
---|
8 | FTexture: IBGRAScanner;
|
---|
9 | FMainPart: IBGRAPart3D;
|
---|
10 | FFaces: array of IBGRAFace3D;
|
---|
11 | FFaceCount: integer;
|
---|
12 | FLightingNormal : TLightingNormal3D;
|
---|
13 | FParentLighting: boolean;
|
---|
14 | FMaterial: IBGRAMaterial3D;
|
---|
15 | FScene: TBGRAScene3D;
|
---|
16 | FFaceColorsInvalidated,
|
---|
17 | FMaterialInvalidated: boolean;
|
---|
18 | procedure AddFace(AFace: IBGRAFace3D); overload;
|
---|
19 | public
|
---|
20 | constructor Create(AScene: TBGRAScene3D);
|
---|
21 | destructor Destroy; override;
|
---|
22 | procedure Clear;
|
---|
23 | procedure InvalidateColor;
|
---|
24 | procedure InvalidateMaterial;
|
---|
25 | function AddFace(const AVertices: array of IBGRAVertex3D): IBGRAFace3D; overload;
|
---|
26 | function AddFace(const AVertices: array of IBGRAVertex3D; ABiface: boolean): IBGRAFace3D; overload;
|
---|
27 | function AddFace(const AVertices: array of IBGRAVertex3D; ATexture: IBGRAScanner): IBGRAFace3D; overload;
|
---|
28 | function AddFace(const AVertices: array of IBGRAVertex3D; AColor: TBGRAPixel): IBGRAFace3D; overload;
|
---|
29 | function AddFace(const AVertices: array of IBGRAVertex3D; AColors: array of TBGRAPixel): IBGRAFace3D; overload;
|
---|
30 | function AddFaceReversed(const AVertices: array of IBGRAVertex3D): IBGRAFace3D;
|
---|
31 | procedure ComputeWithMatrix(constref AMatrix: TMatrix3D; constref AProjection: TProjection3D);
|
---|
32 | function GetColor: TBGRAPixel;
|
---|
33 | function GetLight: Single;
|
---|
34 | function GetTexture: IBGRAScanner;
|
---|
35 | function GetMainPart: IBGRAPart3D;
|
---|
36 | function GetLightingNormal: TLightingNormal3D;
|
---|
37 | function GetParentLighting: boolean;
|
---|
38 | function GetFace(AIndex: integer): IBGRAFace3D;
|
---|
39 | function GetFaceCount: integer;
|
---|
40 | function GetTotalVertexCount: integer;
|
---|
41 | function GetTotalNormalCount: integer;
|
---|
42 | function GetMaterial: IBGRAMaterial3D;
|
---|
43 | procedure SetLightingNormal(const AValue: TLightingNormal3D);
|
---|
44 | procedure SetParentLighting(const AValue: boolean);
|
---|
45 | procedure SetColor(const AValue: TBGRAPixel);
|
---|
46 | procedure SetLight(const AValue: Single);
|
---|
47 | procedure SetTexture(const AValue: IBGRAScanner);
|
---|
48 | procedure SetMaterial(const AValue: IBGRAMaterial3D);
|
---|
49 | procedure RemoveUnusedVertices;
|
---|
50 | procedure SeparatePart(APart: IBGRAPart3D);
|
---|
51 | function GetScene: TObject;
|
---|
52 | function GetRefCount: integer;
|
---|
53 | procedure SetBiface(AValue : boolean);
|
---|
54 | procedure ForEachVertex(ACallback: TVertex3DCallback);
|
---|
55 | procedure ForEachFace(ACallback: TFace3DCallback);
|
---|
56 | procedure Update;
|
---|
57 | end;
|
---|
58 |
|
---|
59 | { TBGRAVertex3D }
|
---|
60 |
|
---|
61 | TBGRAVertex3D = class(TInterfacedObject,IBGRAVertex3D)
|
---|
62 | private
|
---|
63 | FColor: TBGRAPixel;
|
---|
64 | FParentColor: boolean;
|
---|
65 | FLight: Single;
|
---|
66 | FTexCoord: TPointF;
|
---|
67 | FCoordPool: TBGRACoordPool3D;
|
---|
68 | FCoordPoolIndex: integer;
|
---|
69 | FCustomFlags: DWord;
|
---|
70 | FObject3D: TBGRAObject3D;
|
---|
71 | function GetCoordData: PBGRACoordData3D;
|
---|
72 | procedure Init(AObject3D: TBGRAObject3D; ACoordPool: TBGRACoordPool3D; ASceneCoord: TPoint3D_128);
|
---|
73 | public
|
---|
74 | constructor Create(AObject3D: TBGRAObject3D; ACoordPool: TBGRACoordPool3D; ASceneCoord: TPoint3D); overload;
|
---|
75 | constructor Create(AObject3D: TBGRAObject3D; ACoordPool: TBGRACoordPool3D; ASceneCoord: TPoint3D_128); overload;
|
---|
76 | destructor Destroy; override;
|
---|
77 | function GetColor: TBGRAPixel;
|
---|
78 | function GetLight: Single;
|
---|
79 | function GetViewNormal: TPoint3D;
|
---|
80 | function GetViewNormal_128: TPoint3D_128;
|
---|
81 | function GetCustomNormal: TPoint3D;
|
---|
82 | function GetCustomNormal_128: TPoint3D_128;
|
---|
83 | function GetSceneCoord: TPoint3D;
|
---|
84 | function GetSceneCoord_128: TPoint3D_128;
|
---|
85 | function GetTexCoord: TPointF;
|
---|
86 | function GetViewCoord: TPoint3D;
|
---|
87 | function GetViewCoord_128: TPoint3D_128;
|
---|
88 | function GetUsage: integer;
|
---|
89 | function GetCustomFlags: DWord;
|
---|
90 | procedure SetColor(const AValue: TBGRAPixel);
|
---|
91 | procedure SetLight(const AValue: Single);
|
---|
92 | procedure SetViewNormal(const AValue: TPoint3D);
|
---|
93 | procedure SetViewNormal_128(const AValue: TPoint3D_128);
|
---|
94 | procedure SetCustomNormal(AValue: TPoint3D);
|
---|
95 | procedure SetCustomNormal_128(AValue: TPoint3D_128);
|
---|
96 | procedure NormalizeViewNormal;
|
---|
97 | procedure AddViewNormal(const AValue: TPoint3D_128);
|
---|
98 | procedure SetCustomFlags(AValue: DWord);
|
---|
99 | procedure SetSceneCoord(const AValue: TPoint3D);
|
---|
100 | procedure SetSceneCoord_128(const AValue: TPoint3D_128);
|
---|
101 | procedure SetTexCoord(const AValue: TPointF);
|
---|
102 | procedure SetViewCoord(const AValue: TPoint3D);
|
---|
103 | procedure SetViewCoord_128(const AValue: TPoint3D_128);
|
---|
104 | function GetViewCoordZ: single;
|
---|
105 | function GetParentColor: Boolean;
|
---|
106 | procedure SetParentColor(const AValue: Boolean);
|
---|
107 | function GetProjectedCoord: TPointF;
|
---|
108 | procedure SetProjectedCoord(const AValue: TPointF);
|
---|
109 | procedure ComputeCoordinateAndClearNormal(const AMatrix: TMatrix3D; const AProjection: TProjection3D);
|
---|
110 | property SceneCoord: TPoint3D read GetSceneCoord write SetSceneCoord;
|
---|
111 | property SceneCoord_128: TPoint3D_128 read GetSceneCoord_128 write SetSceneCoord_128;
|
---|
112 | property ViewCoord: TPoint3D read GetViewCoord write SetViewCoord;
|
---|
113 | property ViewCoord_128: TPoint3D_128 read GetViewCoord_128 write SetViewCoord_128;
|
---|
114 | property ViewCoordZ: single read GetViewCoordZ;
|
---|
115 | property ProjectedCoord: TPointF read GetProjectedCoord write SetProjectedCoord;
|
---|
116 | property TexCoord: TPointF read GetTexCoord write SetTexCoord;
|
---|
117 | property Color: TBGRAPixel read GetColor write SetColor;
|
---|
118 | property ParentColor: Boolean read GetParentColor write SetParentColor;
|
---|
119 | property Light: Single read GetLight write SetLight;
|
---|
120 | property ViewNormal: TPoint3D read GetViewNormal write SetViewNormal;
|
---|
121 | property ViewNormal_128: TPoint3D_128 read GetViewNormal_128 write SetViewNormal_128;
|
---|
122 | property CustomNormal: TPoint3D read GetCustomNormal write SetCustomNormal;
|
---|
123 | property CustomNormal_128: TPoint3D_128 read GetCustomNormal_128 write SetCustomNormal_128;
|
---|
124 | property Usage: integer read GetUsage;
|
---|
125 | property CoordData: PBGRACoordData3D read GetCoordData;
|
---|
126 | function GetAsObject: TObject;
|
---|
127 | end;
|
---|
128 |
|
---|
129 | { TBGRANormal3D }
|
---|
130 |
|
---|
131 | TBGRANormal3D = class(TInterfacedObject,IBGRANormal3D)
|
---|
132 | private
|
---|
133 | FPool: TBGRANormalPool3D;
|
---|
134 | FPoolIndex: integer;
|
---|
135 | function GetCustomNormal: TPoint3D;
|
---|
136 | function GetCustomNormal_128: TPoint3D_128;
|
---|
137 | function GetUsage: integer;
|
---|
138 | function GetViewNormal: TPoint3D;
|
---|
139 | function GetViewNormal_128: TPoint3D_128;
|
---|
140 | procedure SetCustomNormal(AValue: TPoint3D);
|
---|
141 | procedure SetCustomNormal_128(AValue: TPoint3D_128);
|
---|
142 | procedure SetViewNormal(AValue: TPoint3D);
|
---|
143 | procedure SetViewNormal_128(AValue: TPoint3D_128);
|
---|
144 | public
|
---|
145 | constructor Create(ANormalPool: TBGRANormalPool3D; ACustomNormal: TPoint3D); overload;
|
---|
146 | constructor Create(ANormalPool: TBGRANormalPool3D; ACustomNormal: TPoint3D_128); overload;
|
---|
147 | destructor Destroy; override;
|
---|
148 | property ViewNormal: TPoint3D read GetViewNormal write SetViewNormal;
|
---|
149 | property ViewNormal_128: TPoint3D_128 read GetViewNormal_128 write SetViewNormal_128;
|
---|
150 | property CustomNormal: TPoint3D read GetCustomNormal write SetCustomNormal;
|
---|
151 | property CustomNormal_128: TPoint3D_128 read GetCustomNormal_128 write SetCustomNormal_128;
|
---|
152 | property Usage: integer read GetUsage;
|
---|
153 | end;
|
---|
154 |
|
---|
155 | { TBGRANormal3D }
|
---|
156 |
|
---|
157 | function TBGRANormal3D.GetCustomNormal: TPoint3D;
|
---|
158 | begin
|
---|
159 | result := Point3D((FPool.NormalData[FPoolIndex])^.customNormal);
|
---|
160 | end;
|
---|
161 |
|
---|
162 | function TBGRANormal3D.GetCustomNormal_128: TPoint3D_128;
|
---|
163 | begin
|
---|
164 | result := (FPool.NormalData[FPoolIndex])^.customNormal;
|
---|
165 | end;
|
---|
166 |
|
---|
167 | function TBGRANormal3D.GetUsage: integer;
|
---|
168 | begin
|
---|
169 | result := frefcount;
|
---|
170 | end;
|
---|
171 |
|
---|
172 | function TBGRANormal3D.GetViewNormal: TPoint3D;
|
---|
173 | begin
|
---|
174 | result := Point3D((FPool.NormalData[FPoolIndex])^.viewNormal);
|
---|
175 | end;
|
---|
176 |
|
---|
177 | function TBGRANormal3D.GetViewNormal_128: TPoint3D_128;
|
---|
178 | begin
|
---|
179 | result := (FPool.NormalData[FPoolIndex])^.viewNormal;
|
---|
180 | end;
|
---|
181 |
|
---|
182 | procedure TBGRANormal3D.SetCustomNormal(AValue: TPoint3D);
|
---|
183 | begin
|
---|
184 | (FPool.NormalData[FPoolIndex])^.customNormal := Point3D_128(AValue);
|
---|
185 | end;
|
---|
186 |
|
---|
187 | procedure TBGRANormal3D.SetCustomNormal_128(AValue: TPoint3D_128);
|
---|
188 | begin
|
---|
189 | (FPool.NormalData[FPoolIndex])^.customNormal := AValue;
|
---|
190 | end;
|
---|
191 |
|
---|
192 | procedure TBGRANormal3D.SetViewNormal(AValue: TPoint3D);
|
---|
193 | begin
|
---|
194 | (FPool.NormalData[FPoolIndex])^.viewNormal := Point3D_128(AValue);
|
---|
195 | end;
|
---|
196 |
|
---|
197 | procedure TBGRANormal3D.SetViewNormal_128(AValue: TPoint3D_128);
|
---|
198 | begin
|
---|
199 | (FPool.NormalData[FPoolIndex])^.viewNormal := AValue;
|
---|
200 | end;
|
---|
201 |
|
---|
202 | constructor TBGRANormal3D.Create(ANormalPool: TBGRANormalPool3D;
|
---|
203 | ACustomNormal: TPoint3D);
|
---|
204 | begin
|
---|
205 | FPool := ANormalPool;
|
---|
206 | FPoolIndex:= FPool.Add;
|
---|
207 | CustomNormal := ACustomNormal;
|
---|
208 | end;
|
---|
209 |
|
---|
210 | constructor TBGRANormal3D.Create(ANormalPool: TBGRANormalPool3D;
|
---|
211 | ACustomNormal: TPoint3D_128);
|
---|
212 | begin
|
---|
213 | FPool := ANormalPool;
|
---|
214 | FPoolIndex:= FPool.Add;
|
---|
215 | CustomNormal_128 := ACustomNormal;
|
---|
216 | end;
|
---|
217 |
|
---|
218 | destructor TBGRANormal3D.Destroy;
|
---|
219 | begin
|
---|
220 | FPool.Remove(FPoolIndex);
|
---|
221 | inherited Destroy;
|
---|
222 | end;
|
---|
223 |
|
---|
224 | { TBGRAVertex3D }
|
---|
225 |
|
---|
226 | procedure TBGRAVertex3D.Init(AObject3D: TBGRAObject3D; ACoordPool: TBGRACoordPool3D; ASceneCoord: TPoint3D_128);
|
---|
227 | begin
|
---|
228 | FObject3D := AObject3D;
|
---|
229 | FCoordPool := ACoordPool;
|
---|
230 | FCoordPoolIndex := FCoordPool.Add;
|
---|
231 | FColor := BGRAWhite;
|
---|
232 | FParentColor := True;
|
---|
233 | FLight := 1;
|
---|
234 | SceneCoord_128 := ASceneCoord;
|
---|
235 | end;
|
---|
236 |
|
---|
237 | procedure TBGRAVertex3D.SetCustomNormal(AValue: TPoint3D);
|
---|
238 | begin
|
---|
239 | with FCoordPool.CoordData[FCoordPoolIndex]^ do
|
---|
240 | begin
|
---|
241 | customNormal := Point3D_128(AValue);
|
---|
242 | customNormalUsed := not CompareMem(@customNormal,@Point3D_128_Zero,sizeof(Point3D_128_Zero));
|
---|
243 | end;
|
---|
244 | end;
|
---|
245 |
|
---|
246 | procedure TBGRAVertex3D.SetCustomNormal_128(AValue: TPoint3D_128);
|
---|
247 | begin
|
---|
248 | with FCoordPool.CoordData[FCoordPoolIndex]^ do
|
---|
249 | begin
|
---|
250 | customNormal := AValue;
|
---|
251 | customNormalUsed := not CompareMem(@customNormal,@Point3D_128_Zero,sizeof(Point3D_128_Zero));
|
---|
252 | end;
|
---|
253 | end;
|
---|
254 |
|
---|
255 | function TBGRAVertex3D.GetCoordData: PBGRACoordData3D;
|
---|
256 | begin
|
---|
257 | result := FCoordPool.CoordData[FCoordPoolIndex];
|
---|
258 | end;
|
---|
259 |
|
---|
260 | function TBGRAVertex3D.GetCustomNormal: TPoint3D;
|
---|
261 | begin
|
---|
262 | result := Point3D(FCoordPool.CoordData[FCoordPoolIndex]^.customNormal);
|
---|
263 | end;
|
---|
264 |
|
---|
265 | function TBGRAVertex3D.GetCustomNormal_128: TPoint3D_128;
|
---|
266 | begin
|
---|
267 | result := FCoordPool.CoordData[FCoordPoolIndex]^.customNormal;
|
---|
268 | end;
|
---|
269 |
|
---|
270 | constructor TBGRAVertex3D.Create(AObject3D: TBGRAObject3D; ACoordPool: TBGRACoordPool3D; ASceneCoord: TPoint3D);
|
---|
271 | begin
|
---|
272 | Init(AObject3D, ACoordPool, Point3D_128(ASceneCoord));
|
---|
273 | end;
|
---|
274 |
|
---|
275 | constructor TBGRAVertex3D.Create(AObject3D: TBGRAObject3D; ACoordPool: TBGRACoordPool3D; ASceneCoord: TPoint3D_128);
|
---|
276 | begin
|
---|
277 | Init(AObject3D, ACoordPool, ASceneCoord);
|
---|
278 | end;
|
---|
279 |
|
---|
280 | destructor TBGRAVertex3D.Destroy;
|
---|
281 | begin
|
---|
282 | FCoordPool.Remove(FCoordPoolIndex);
|
---|
283 | inherited Destroy;
|
---|
284 | end;
|
---|
285 |
|
---|
286 | function TBGRAVertex3D.GetColor: TBGRAPixel;
|
---|
287 | begin
|
---|
288 | result := FColor;
|
---|
289 | end;
|
---|
290 |
|
---|
291 | function TBGRAVertex3D.GetLight: Single;
|
---|
292 | begin
|
---|
293 | result := FLight;
|
---|
294 | end;
|
---|
295 |
|
---|
296 | function TBGRAVertex3D.GetViewNormal: TPoint3D;
|
---|
297 | begin
|
---|
298 | result := Point3D(FCoordPool.CoordData[FCoordPoolIndex]^.viewNormal);
|
---|
299 | end;
|
---|
300 |
|
---|
301 | function TBGRAVertex3D.GetViewNormal_128: TPoint3D_128;
|
---|
302 | begin
|
---|
303 | result := FCoordPool.CoordData[FCoordPoolIndex]^.viewNormal;
|
---|
304 | end;
|
---|
305 |
|
---|
306 | function TBGRAVertex3D.GetSceneCoord: TPoint3D;
|
---|
307 | begin
|
---|
308 | result := Point3D(FCoordPool.CoordData[FCoordPoolIndex]^.sceneCoord);
|
---|
309 | end;
|
---|
310 |
|
---|
311 | function TBGRAVertex3D.GetSceneCoord_128: TPoint3D_128;
|
---|
312 | begin
|
---|
313 | result := FCoordPool.CoordData[FCoordPoolIndex]^.sceneCoord;
|
---|
314 | end;
|
---|
315 |
|
---|
316 | function TBGRAVertex3D.GetTexCoord: TPointF;
|
---|
317 | begin
|
---|
318 | result := FTexCoord;
|
---|
319 | end;
|
---|
320 |
|
---|
321 | function TBGRAVertex3D.GetViewCoord: TPoint3D;
|
---|
322 | begin
|
---|
323 | result := Point3D(FCoordPool.CoordData[FCoordPoolIndex]^.viewCoord);
|
---|
324 | end;
|
---|
325 |
|
---|
326 | function TBGRAVertex3D.GetViewCoord_128: TPoint3D_128;
|
---|
327 | begin
|
---|
328 | result := FCoordPool.CoordData[FCoordPoolIndex]^.viewCoord;
|
---|
329 | end;
|
---|
330 |
|
---|
331 | function TBGRAVertex3D.GetUsage: integer;
|
---|
332 | begin
|
---|
333 | result := frefcount;
|
---|
334 | end;
|
---|
335 |
|
---|
336 | function TBGRAVertex3D.GetCustomFlags: DWord;
|
---|
337 | begin
|
---|
338 | result := FCustomFlags;
|
---|
339 | end;
|
---|
340 |
|
---|
341 | procedure TBGRAVertex3D.SetColor(const AValue: TBGRAPixel);
|
---|
342 | begin
|
---|
343 | FColor := AValue;
|
---|
344 | FParentColor := false;
|
---|
345 | FObject3D.InvalidateColor;
|
---|
346 | end;
|
---|
347 |
|
---|
348 | procedure TBGRAVertex3D.SetLight(const AValue: Single);
|
---|
349 | begin
|
---|
350 | FLight := AValue;
|
---|
351 | end;
|
---|
352 |
|
---|
353 | procedure TBGRAVertex3D.SetViewNormal(const AValue: TPoint3D);
|
---|
354 | begin
|
---|
355 | FCoordPool.CoordData[FCoordPoolIndex]^.viewNormal := Point3D_128(AValue);
|
---|
356 | end;
|
---|
357 |
|
---|
358 | procedure TBGRAVertex3D.SetViewNormal_128(const AValue: TPoint3D_128);
|
---|
359 | begin
|
---|
360 | FCoordPool.CoordData[FCoordPoolIndex]^.viewNormal := AValue;
|
---|
361 | end;
|
---|
362 |
|
---|
363 | procedure TBGRAVertex3D.SetSceneCoord(const AValue: TPoint3D);
|
---|
364 | begin
|
---|
365 | FCoordPool.CoordData[FCoordPoolIndex]^.sceneCoord := Point3D_128(AValue);
|
---|
366 | end;
|
---|
367 |
|
---|
368 | procedure TBGRAVertex3D.SetSceneCoord_128(const AValue: TPoint3D_128);
|
---|
369 | begin
|
---|
370 | FCoordPool.CoordData[FCoordPoolIndex]^.sceneCoord := AValue;
|
---|
371 | end;
|
---|
372 |
|
---|
373 | procedure TBGRAVertex3D.SetTexCoord(const AValue: TPointF);
|
---|
374 | begin
|
---|
375 | FTexCoord := AValue;
|
---|
376 | end;
|
---|
377 |
|
---|
378 | procedure TBGRAVertex3D.SetViewCoord(const AValue: TPoint3D);
|
---|
379 | begin
|
---|
380 | FCoordPool.CoordData[FCoordPoolIndex]^.viewCoord := Point3D_128(AValue);
|
---|
381 | end;
|
---|
382 |
|
---|
383 | procedure TBGRAVertex3D.SetViewCoord_128(const AValue: TPoint3D_128);
|
---|
384 | begin
|
---|
385 | FCoordPool.CoordData[FCoordPoolIndex]^.viewCoord := AValue;
|
---|
386 | end;
|
---|
387 |
|
---|
388 | function TBGRAVertex3D.GetViewCoordZ: single;
|
---|
389 | begin
|
---|
390 | result := FCoordPool.CoordData[FCoordPoolIndex]^.viewCoord.Z;
|
---|
391 | end;
|
---|
392 |
|
---|
393 | function TBGRAVertex3D.GetParentColor: Boolean;
|
---|
394 | begin
|
---|
395 | result := FParentColor;
|
---|
396 | end;
|
---|
397 |
|
---|
398 | procedure TBGRAVertex3D.SetParentColor(const AValue: Boolean);
|
---|
399 | begin
|
---|
400 | FParentColor := AValue;
|
---|
401 | FObject3D.InvalidateColor;
|
---|
402 | end;
|
---|
403 |
|
---|
404 | function TBGRAVertex3D.GetProjectedCoord: TPointF;
|
---|
405 | begin
|
---|
406 | result := FCoordPool.CoordData[FCoordPoolIndex]^.projectedCoord;
|
---|
407 | end;
|
---|
408 |
|
---|
409 | procedure TBGRAVertex3D.SetProjectedCoord(const AValue: TPointF);
|
---|
410 | begin
|
---|
411 | FCoordPool.CoordData[FCoordPoolIndex]^.projectedCoord := AValue;
|
---|
412 | end;
|
---|
413 |
|
---|
414 | procedure TBGRAVertex3D.ComputeCoordinateAndClearNormal(const AMatrix: TMatrix3D; const AProjection : TProjection3D);
|
---|
415 | var P: PBGRACoordData3D;
|
---|
416 | begin
|
---|
417 | P := FCoordPool.CoordData[FCoordPoolIndex];
|
---|
418 | with p^ do
|
---|
419 | begin
|
---|
420 | viewCoord := AMatrix*sceneCoord;
|
---|
421 | if customNormalUsed then
|
---|
422 | viewNormal := MultiplyVect3DWithoutTranslation(AMatrix,customNormal)
|
---|
423 | else
|
---|
424 | ClearPoint3D_128(viewNormal);
|
---|
425 | if viewCoord.z > 0 then
|
---|
426 | begin
|
---|
427 | InvZ := 1/viewCoord.z;
|
---|
428 | projectedCoord := PointF(viewCoord.x*InvZ*AProjection.Zoom.x + AProjection.Center.x,
|
---|
429 | viewCoord.y*InvZ*AProjection.Zoom.Y + AProjection.Center.y);
|
---|
430 | end else
|
---|
431 | projectedCoord := PointF(0,0);
|
---|
432 | end;
|
---|
433 | end;
|
---|
434 |
|
---|
435 | function TBGRAVertex3D.GetAsObject: TObject;
|
---|
436 | begin
|
---|
437 | result := self;
|
---|
438 | end;
|
---|
439 |
|
---|
440 | procedure TBGRAVertex3D.NormalizeViewNormal;
|
---|
441 | begin
|
---|
442 | Normalize3D_128(FCoordPool.CoordData[FCoordPoolIndex]^.viewNormal);
|
---|
443 | end;
|
---|
444 |
|
---|
445 | procedure TBGRAVertex3D.AddViewNormal(const AValue: TPoint3D_128);
|
---|
446 | begin
|
---|
447 | with FCoordPool.CoordData[FCoordPoolIndex]^ do
|
---|
448 | if not customNormalUsed then
|
---|
449 | Add3D_Aligned(viewNormal, AValue);
|
---|
450 | end;
|
---|
451 |
|
---|
452 | procedure TBGRAVertex3D.SetCustomFlags(AValue: DWord);
|
---|
453 | begin
|
---|
454 | FCustomFlags:= AValue;
|
---|
455 | end;
|
---|
456 |
|
---|