1
unit LUX.Data.Octree.D3;
3
interface //#################################################################### ■
5
uses LUX, LUX.D3, LUX.M4,
6
LUX.Data.Octree, LUX.Data.Octree.Atom,
9
type //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【型】
11
IOcNode3D = interface;
12
IOcLeaf3D = interface;
13
IOcKnot3D = interface;
14
IOctree3D = interface;
20
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
22
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【インタフェース】
24
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IOcNode3D
26
IOcNode3D = interface( IOcNode )
27
['{828065B3-3378-4052-8ECA-FF2BD612970F}']
30
function GetRoot :IOctree3D;
31
function GetParen :IOcNode3D;
32
procedure SetParen( const Paren_:IOcNode3D );
33
function GetChilds( const I_:Byte ) :IOcNode3D;
34
procedure SetChilds( const I_:Byte; const Child_:IOcNode3D );
35
function GetCubo :TSingleCubo3D;
38
property Root :IOctree3D read GetRoot ;
39
property Paren :IOcNode3D read GetParen write SetParen ;
40
property Childs[ const I_:Byte ] :IOcNode3D read GetChilds write SetChilds;
41
property Cubo :TSingleCubo3D read GetCubo ;
43
function ForChilds( const Func_:TConstFunc<IOcNode3D,Boolean> ) :Boolean;
44
procedure ForFamily( const Proc_:TConstProc<IOcNode3D> );
45
function ForChildPairs( const Node_:IOcNode3D; const Func_:TConstFunc<IOcNode3D,IOcNode3D,Boolean> ) :Boolean;
46
function Collision( const Node_:IOcNode3D ) :Boolean;
49
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IOcLeaf3D
51
IOcLeaf3D = interface( IOcLeaf )
52
['{A362526F-11E9-4521-B64B-F565A261DD50}']
57
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IOcKnot3D
59
IOcKnot3D = interface( IOcKnot )
60
['{824043A9-14C2-4FD2-8C8E-06C2E0EA0E6C}']
65
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% IOctree3D
67
IOctree3D = interface( IOctree )
68
['{E8A174D1-4F6F-4F03-9182-D8BE1A631541}']
72
function GetCubo( const Lev_:Cardinal; const Ind_:TCardinal3D ) :TSingleCubo3D; overload;
75
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
77
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOcLeaf3D
79
TOcLeaf3D = class( TOcLeaf<IOcNode3D,IOctree3D>, IOcLeaf3D, IOcNode3D )
83
function GetCubo :TSingleCubo3D;
85
class constructor Create;
87
destructor Destroy; override;
89
property Cubo :TSingleCubo3D read GetCubo;
91
function Collision( const Node_:IOcNode3D ) :Boolean;
94
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOcKnot3D
96
TOcKnot3D = class( TOcKnot<IOcNode3D,IOctree3D>, IOcKnot3D, IOcNode3D )
100
function GetCubo :TSingleCubo3D;
102
class constructor Create;
104
destructor Destroy; override;
106
property Cubo :TSingleCubo3D read GetCubo;
108
function Collision( const Node_:IOcNode3D ) :Boolean;
111
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOctree3D
113
TOctree3D = class( TOctree<IOcNode3D,IOctree3D,TOcKnot3D,TOcLeaf3D>, IOctree3D, IOcNode3D )
116
_Area :TSingleArea3D;
119
function GetCubo :TSingleCubo3D; overload;
121
class constructor Create;
123
destructor Destroy; override;
125
property Cubo :TSingleCubo3D read GetCubo ;
126
property Area :TSingleArea3D read _Area write _Area;
127
property Pose :TSingleM4 read _Pose write _Pose;
129
function GetCubo( const Lev_:Cardinal; const Ind_:TCardinal3D ) :TSingleCubo3D; overload;
130
function Collision( const Node_:IOcNode3D ) :Boolean;
133
//const //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【定数】
135
//var //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【変数】
137
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
139
implementation //############################################################### ■
141
uses System.SysUtils, System.Math;
143
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
145
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
147
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOcNode3D
149
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOcLeaf3D
151
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
153
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
155
/////////////////////////////////////////////////////////////////////// アクセス
157
function TOcLeaf3D.GetCubo :TSingleCubo3D;
159
Result := Root.GetCubo( Lev, Ind );
162
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
164
class constructor TOcLeaf3D.Create;
168
_CastNode := function( const Node_:IOcNode ) :IOcNode3D
169
begin Result := Node_ as IOcNode3D; end;
171
_CastRoot := function( const Root_:IOctree ) :IOctree3D
172
begin Result := Root_ as IOctree3D; end;
175
constructor TOcLeaf3D.Create;
181
destructor TOcLeaf3D.Destroy;
187
/////////////////////////////////////////////////////////////////////// メソッド
189
function TOcLeaf3D.Collision( const Node_:IOcNode3D ) :Boolean;
191
Result := Cubo.Collision( Node_.Cubo )
192
and ForChildPairs( Node_, function( const N0,N1:IOcNode3D ) :Boolean
194
Result := N0.Collision( N1 );
198
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOcKnot3D
200
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
202
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
204
/////////////////////////////////////////////////////////////////////// アクセス
206
function TOcKnot3D.GetCubo :TSingleCubo3D;
208
Result := Root.GetCubo( Lev, Ind );
211
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
213
class constructor TOcKnot3D.Create;
217
_CastNode := function( const Node_:IOcNode ) :IOcNode3D
218
begin Result := Node_ as IOcNode3D; end;
220
_CastRoot := function( const Root_:IOctree ) :IOctree3D
221
begin Result := Root_ as IOctree3D; end;
224
constructor TOcKnot3D.Create;
230
destructor TOcKnot3D.Destroy;
236
/////////////////////////////////////////////////////////////////////// メソッド
238
function TOcKnot3D.Collision( const Node_:IOcNode3D ) :Boolean;
240
Result := Cubo.Collision( Node_.Cubo )
241
and ForChildPairs( Node_, function( const N0,N1:IOcNode3D ) :Boolean
243
Result := N0.Collision( N1 );
247
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TOctree3D
249
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
251
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
253
/////////////////////////////////////////////////////////////////////// アクセス
255
function TOctree3D.GetCubo :TSingleCubo3D;
257
Result := Root.GetCubo( Lev, Ind );
260
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
262
class constructor TOctree3D.Create;
266
_CastNode := function( const Node_:IOcNode ) :IOcNode3D
267
begin Result := Node_ as IOcNode3D; end;
269
_CastRoot := function( const Root_:IOctree ) :IOctree3D
270
begin Result := Root_ as IOctree3D; end;
273
constructor TOctree3D.Create;
279
destructor TOctree3D.Destroy;
285
/////////////////////////////////////////////////////////////////////// メソッド
287
function TOctree3D.GetCubo( const Lev_:Cardinal; const Ind_:TCardinal3D ) :TSingleCubo3D;
292
N := TOctree3D.DivLtoN( Lev_ );
294
S.X := _Area.SizeX / N;
295
S.Y := _Area.SizeY / N;
296
S.Z := _Area.SizeZ / N;
304
X := _Area.Min.X + S.X * Ind_.X;
305
Y := _Area.Min.Y + S.Y * Ind_.Y;
306
Z := _Area.Min.Z + S.Z * Ind_.Z;
321
//------------------------------------------------------------------------------
323
function TOctree3D.Collision( const Node_:IOcNode3D ) :Boolean;
325
Result := Cubo.Collision( Node_.Cubo )
326
and ForChildPairs( Node_, function( const N0,N1:IOcNode3D ) :Boolean
328
Result := N0.Collision( N1 );
332
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
334
//############################################################################## □
336
initialization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 初期化
338
finalization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 最終化
340
end. //######################################################################### ■