-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImportCOB.h
262 lines (220 loc) · 5.81 KB
/
ImportCOB.h
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
//
// stuff to read *.cob files...
// - Garry Knudson's code
// 8-15-99
//
#include "MODVIEW32Doc.h"
class CImportCOB
{
protected:
public:
int m_Game;
CString errstring;
CString errdetails;
CString logstring;
CImportCOB();
~CImportCOB();
ERRORCODE ReadCOB(CFile *f);
void ConvertCob2Model();
void MakePof(/*char *output*/);
private:
CMODVIEW32Doc *GetDocument();
void StatusPrnt2(char *fmt, ...);
void ReduceToUnit(float vector[3]);
void calcNormal(float v[3][3], float out[3]);
void ohdr();
void txtr();
void Dump0Data();
void Dump1Data(unsigned int Segment);
void Dump23Data(int Polygon);
void Dump4Data(FS_VPNT Normal, FS_VPNT Point, FS_VPNT Min, FS_VPNT Max);
void Dump5Data(FS_VPNT Min, FS_VPNT Max);
void split(FS_VPNT Min, FS_VPNT Max,unsigned int SobjNum);
void sobj(int SobjNum);
void shld();
void pinf();
#define D_GROU 0x756f7247
#define D_POLH 0x486c6f50
#define D_MAT1 0x3174614d
#define D_MREC 0x6365524d
#define D_END 0x20444e45
#define SOBJ_MAX 100
#define VEC_MAX 10000
#define POLY_MAX 10000
#define TEXTURE_MAX 100
#define MATL_MAX 250
#define SHIELD_MAX 500
#define DELTA 0.001f
#define COB2FS_VERSION "COB2FS Version 0.05 09/04/1999"
//int run(char *input, char *output);
typedef struct vector {
float x,y,z;
} VECTOR;
typedef struct quad {
float j,k,l,m;
} QUAD;
//#pragma pack( push, 1 )
#pragma pack(1)
typedef struct cob_header {
char Name[9];
char Version[6];
char Format;
char Endian[2];
char Blank[13];
char Newline;
} COB_HEADER;
typedef struct chunk_header {
unsigned int Type;
unsigned short Major;
unsigned short Minor;
unsigned int Chunkid;
unsigned int Parentid;
unsigned int Size;
} CHUNK_HEADER;
typedef struct grou_data {
VECTOR Center,Localx,Localy,localz;
QUAD Matrix1,Matrix2,Matrix3;
} GROU_DATA;
typedef struct matl_data {
unsigned short number;
char shader, facet, autofacet;
float red, green, blue, opacity;
float ambient, specular, hilight, refraction;
} MATL_DATA;
typedef struct matlt_data {
float uoffset, voffset, urepeat, vrepeat;
} MATLT_DATA;
typedef struct polh_data {
VECTOR Center,Localx,Localy,localz;
QUAD Matrix1,Matrix2,Matrix3;
} POLH_DATA;
typedef struct cvpnt {
float x,y,z;
} CVPNT;
typedef struct cuv {
float u,v;
} CUV;
typedef struct cindex {
long v,uv;
} CINDEX;
typedef struct cface {
unsigned int n_index;
unsigned int segment;
unsigned int chunk;
unsigned int chunkmatl;
char facet;
unsigned int material;
unsigned int polytype;
unsigned int matlindex;
CINDEX index[25];
} CFACE;
typedef struct cmodel
{
unsigned int Vcount;
CVPNT Vpoint[VEC_MAX];
unsigned int Vpntseg[VEC_MAX];
unsigned int Vpntchunk[VEC_MAX];
unsigned int Vpntreal[VEC_MAX];
unsigned short Vpntfinal[VEC_MAX];
unsigned int UVcount;
CUV UVpoint[VEC_MAX*2];
unsigned int Pcount;
CFACE Poly[POLY_MAX];
unsigned int Scount;
char Sname[SOBJ_MAX][30];
CVPNT Soffset[SOBJ_MAX];
unsigned int parent[SOBJ_MAX];
} CMODEL;
/* model stuff... from fs-extra.h*/
#define D_EOF 0 //eof
#define D_DEFPOINTS 1 //defpoints
#define D_FLATPOLY 2 //flat-shaded polygon
#define D_TMAPPOLY 3 //texture-mapped polygon
#define D_SORTNORM 4 //sort by normal
#define D_BOUNDBOX 5 //bounding box
#define ID_PSPO 0x4f505350L //pof file id
#define ID_OHDR 0x5244484fL //Object header
#define ID_SOBJ 0x4a424f53L //Subobject header
#define ID_TXTR 0x52545854L //Texture filename list
#define ID_PATH 0x48544150L //Texture filename list
#define ID_SPCL 0x4C435053L //Texture filename list
#define ID_SHLD 0x444C4853L //Texture filename list
#define ID__EYE 0x45594520L //Texture filename list
#define ID_GPNT 0x544E5047L //Texture filename list
#define ID_MPNT 0x544E504DL //Texture filename list
#define ID_TGUN 0x4E554754L //Texture filename list
#define ID_TMIS 0x53494D54L //Texture filename list
#define ID_DOCK 0x4B434F44L //Texture filename list
#define ID_FUEL 0x4C455546L //Texture filename list
#define ID_PINF 0x464E4950L //Texture filename list
typedef struct vpnt {
float x,y,z;
} VPNT;
typedef struct bbinfo {
VPNT min,max;
} BBINFO;
typedef struct pinfo {
unsigned int Corners;
unsigned int Colors;
unsigned int facet;
unsigned int Segment;
unsigned int Chunk;
unsigned int Sobj;
unsigned int Ptype;
unsigned int detail;
FS_VPNT Center;
FS_VPNT Normal;
float Radius;
unsigned short Vp[20];
unsigned short Np[20];
float U[20];
float V[20];
} PINFO;
typedef struct fsmodel {
unsigned short NScount;
unsigned short NSobj[VEC_MAX*2];
unsigned short VScount;
unsigned short VSobj[VEC_MAX];
unsigned short Vcount;
FS_VPNT Vpoint[VEC_MAX];
unsigned int Vpntseg[VEC_MAX];
unsigned int Vpntchunk[VEC_MAX];
unsigned char n_vn[VEC_MAX];
unsigned short Ncount;
FS_VPNT Npoint[VEC_MAX*2];
unsigned int BBcount;
BBINFO Bbox[POLY_MAX];
unsigned int Pcount;
PINFO Poly[POLY_MAX];
unsigned int Scount;
char Sname[MAX_FS_SOBJ][30];
long Sparent[MAX_FS_SOBJ];
FS_VPNT Soffset[MAX_FS_SOBJ];
unsigned int Debriscount;
unsigned int Sdebris[MAX_FS_SOBJ];
unsigned int Detailcount;
unsigned int Sdetail[MAX_FS_SOBJ];
long shield;
} FSMODEL;
typedef struct sinfo {
unsigned int VScount;
unsigned int VSlist[SHIELD_MAX];
unsigned int PScount;
unsigned int PSlist[SHIELD_MAX];
unsigned int PSnext[SHIELD_MAX][3];
} SINFO;
MATL_DATA Matldata[MATL_MAX];
MATLT_DATA Matltdata[MATL_MAX];
char Matlname[MATL_MAX][100];
unsigned int Matlcount,numtextures;
// Place to hold the model data...
FSMODEL FSModel;
CMODEL Cmodel;
unsigned int chunknum;
unsigned char *OutputData;
unsigned int OutputLength;
};
//
// end...
//
//#pragma pack( pop )