-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasetypeparams.pas
103 lines (82 loc) · 2.73 KB
/
basetypeparams.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
unit basetypeparams;
{ base class for typeparameter classes
}
interface
uses
Classes, SysUtils,
CastleVectors,
CastleScene,
Collect;
type
TBaseTypeParams = class
{ type name }
TypeName : String;
{ number of animals of this type }
TypeCount : integer;
PovTranslation : TVector3;
PovRotation : TVector4;
{ model information }
ModelUrl : string;
ModelTemplate : TCastleScene;
ModelTranslate : TVector3;
ModelScale : single;
ModelRotate : single; { around y axis to rotate model to standard direction }
FullDetailDist : single; { distance witin which you can see full detail model }
LowDefColor : TVector3;
LowDefTopUrl : String;
LowDefSideUrl : String;
LowDefFrontUrl: String;
LowDefBackUrl : String;
constructor create( iName : string;
iURL : string = '';
scale : single = 1.0;
rotate: single = 0.0);
end;
TBaseTypeList = class( TSortedCollection )
function findBaseType( typename : string ) : TBaseTypeParams;
procedure setModelTemplate( typename : string; Template : TCastleScene );
function compare(item1, item2 : pointer) : integer; override;
function keyof( item : pointer ) : pointer; override;
end;
implementation
constructor TBaseTypeParams.create( iName : string;
iURL : string = '';
scale : single = 1.0;
rotate: single = 0.0);
begin
inherited create;
TypeName := iName;
PovTranslation := Vector3( 0, 0, 0 );
PovRotation := Vector4( 0, 0, 0, 0 );
ModelUrl := iURL;
ModelRotate := rotate;
ModelScale := scale;
ModelTranslate := Vector3( 0, 0, 0 );
TypeCount := 0;
ModelTemplate := nil;
FullDetailDist := 40;
LowDefColor := Vector3( 0.5, 0.5, 0.5 );
end;
function TBaseTypeList.compare(item1, item2 : pointer) : integer;
begin
result := comparetext( pchar( item1 ), pchar( item2 ));
end;
function TBaseTypeList.keyof( item : pointer ) : pointer;
begin
Result := PChar(TBaseTypeParams( item ).TypeName);
end;
function TBaseTypeList.findBaseType( typename : string ) : TBaseTypeParams;
var i : integer;
begin
Result := nil;
if search( pchar(typename), i ) then
Result := TBaseTypeParams( At( i ))
end;
procedure TBaseTypeList.setModelTemplate( typename : string; Template : TCastleScene );
var params : TBaseTypeParams;
begin
params := findBaseType( typename );
if assigned( Params ) then
Params.ModelTemplate := Template;
end;
end.