-
Notifications
You must be signed in to change notification settings - Fork 344
/
_xsi.hpp
204 lines (155 loc) · 4.3 KB
/
_xsi.hpp
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// This file is distributed under a BSD license. See LICENSE.txt for details.
#ifndef ___XSI_HPP__
#define ___XSI_HPP__
#include "_types.hpp"
#include "_start.hpp"
/****************************************************************************/
/****************************************************************************/
#define sXSI_MAXUV 256 // maximum uv-sets per cluster
#define sXSI_MAXWEIGHT 16 // maximum relevant bone-weigth
#define sXSI_MAXTS 256 // maximum total texture supports in scene
#define XSISIZE 256 // maximum xsi string size
#define XSINAME 256
#define XSIPATH 4096
struct sXSIVertex
{
sInt Index; // position index from which this vertex was created
sVector Pos; // 3d Position
sVector Normal; // 3d Normal
sU32 Color; // Color Support
sF32 UV[4][2]; // Multiple UV Supports
sF32 Weight[sXSI_MAXWEIGHT]; // Weights (compressed)
class sXSIModel *WeightModel[sXSI_MAXWEIGHT];
sInt WeightCount;
sInt Temp;
void Init();
void AddWeight(class sXSIModel *,sF32 w);
};
/****************************************************************************/
class sXSITexture : public sObject
{
public:
sXSITexture();
~sXSITexture();
void Tag();
sChar Name[XSINAME];
sChar PathName[XSIPATH];
sBitmap *Bitmap;
};
/****************************************************************************/
class sXSIMaterial : public sObject
{
public:
sXSIMaterial();
~sXSIMaterial();
void Tag();
sChar Name[XSINAME];
sU32 Flags;
sU32 Mode;
sU32 TFlags[4];
sU32 TUV[4];
sXSITexture *Tex[4];
sU32 Ambient;
sU32 Diffuse;
sU32 Specular;
sF32 Specularity;
};
/****************************************************************************/
class sXSICluster : public sObject
{
public:
sXSICluster();
~sXSICluster();
void Clear();
void Tag();
void Optimise();
sInt VertexCount; // number of vertices
sInt IndexCount; // number of face-entries
sXSIVertex *Vertices; // vertices
sXSIMaterial *Material; // used material
sInt *Faces; // fan,index,fan,index,...
};
/****************************************************************************/
struct sXSIFCurveKey
{
sInt Num;
sF32 Pos;
sF32 Spline[4];
void Init();
};
class sXSIFCurve : public sObject
{
public:
sXSIFCurve();
~sXSIFCurve();
void Clear();
sInt Offset;
sInt KeyCount;
sXSIFCurveKey *Keys;
sInt Index;
};
/****************************************************************************/
class sXSIModel : public sObject
{
public:
sXSIModel();
~sXSIModel();
void Tag();
void Clear();
sChar Name[XSINAME];
sList<sXSIModel> *Childs;
sList<sXSIFCurve> *FCurves;
sList<sXSICluster> *Clusters;
sVector BaseS,BaseR,BaseT;
sVector TransS,TransR,TransT;
sBool Visible;
sInt Index; // use at your will
sInt Usage;
sXSIModel *FindModel(sChar *name);
void DumpModel(sInt indent);
};
/****************************************************************************/
class sXSILoader : public sObject
{
// document
sChar BasePath[XSIPATH];
sXSITexture *FindTexture(sChar *name);
sXSIMaterial *FindMaterial(sChar *name);
sChar TSName[sXSI_MAXTS][XSISIZE];
sInt TSCount;
// type scanning
sInt ScanInt();
sF32 ScanFloat();
void ScanString(sChar *buffer,sInt size);
// general scanning
void ScanName(sChar *buffer,sInt size);
void SkipChunk();
void ScanChunk(sInt indent,sChar *chunk,sChar *name);
void EndChunk();
// specific parsing
void ScanMatLib(sInt indent);
void ScanMesh(sInt indent,sXSIModel *model);
sXSIFCurve *ScanFCurve(sInt indent);
sXSIModel *ScanModel(sInt indent,sChar *name);
void ScanEnvList(sInt indent);
// work
void Optimise1(sXSIModel *model);
public:
sBool Error;
sChar *Scan;
sInt Version;
sList<sXSITexture> *Textures;
sList<sXSIMaterial> *Materials;
sList<sXSIModel> *Models;
sXSIModel *RootModel;
sXSILoader();
~sXSILoader();
void Tag();
void Clear();
sBool LoadXSI(sChar *path);
void Optimise();
void DebugStats();
};
/****************************************************************************/
/****************************************************************************/
#endif