mElite
1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
mElite
ObjectLoader3ds.h
Go to the documentation of this file.
1
8
#ifndef _C3DS_OBJECT_H_
9
#define _C3DS_OBJECT_H_
10
11
#include<stdio.h>
12
#include<vector>
13
18
struct
stChunk
{
19
stChunk
() :
id
(0),
length
(0),
bytesRead
(0) {}
20
unsigned
short
id
;
// unsigned added
21
size_t
length
;
22
size_t
bytesRead
;
23
};
24
29
struct
stVertex
{
30
stVertex
() :
x
(0),
y
(0),
z
(0) {}
31
float
x
,
y
,
z
;
32
};
33
38
struct
stFace
{
39
stFace
() :
matId
(0) {
indices
[0] =
indices
[1] =
indices
[2] = 0; }
40
unsigned
int
indices
[3];
41
stVertex
normal
;
42
int
matId
;
43
};
44
49
struct
stFileFace
{
50
stFileFace
() :
vis
(0) {
indices
[0] =
indices
[1] =
indices
[2] = 0; }
51
unsigned
short
indices
[3],
vis
;
52
};
53
58
struct
stColor
{
59
stColor
() :
r
(0),
g
(0),
b
(0) {}
60
unsigned
char
r
,
g
,
b
;
61
};
62
68
struct
stTexCoord
{
69
stTexCoord
() :
tu
(0),
tv
(0) {}
70
float
tu
,
tv
;
71
};
72
78
struct
stMaterial
{
79
stMaterial
() {
name
[0] = 0;
textureName
[0] = 0; }
80
char
name
[256];
81
stColor
colorDiffuse
;
82
stColor
colorAmbient
;
83
stColor
colorSpecular
;
84
char
textureName
[256];
85
};
86
91
struct
stMesh
{
92
stMesh
() :
pFaces
(0),
pVertices
(0),
pTexCoords
(0),
93
totalFaces
(0),
totalVertices
(0),
totalTexCoords
(0) {}
94
95
char
name
[256];
96
97
stFace
*
pFaces
;
98
stVertex
*
pVertices
;
99
stTexCoord
*
pTexCoords
;
100
101
unsigned
int
totalFaces
;
102
unsigned
int
totalVertices
;
103
unsigned
int
totalTexCoords
;
104
};
105
114
class
ObjectLoader3ds
{
115
public
:
116
ObjectLoader3ds
();
117
~ObjectLoader3ds
();
118
119
// load a file
120
bool
LoadModel
(
const
char
*fileName);
121
122
// deals with reading chunk headers.
123
void
ReadSubChunk
(FILE *fp,
stChunk
*pChunk);
124
void
MoveToNextChunk
(FILE *fp,
stChunk
*pChunk);
125
size_t
GetNextString
(FILE *fp,
char
*str);
126
void
ReadChunk
(FILE *fp,
stChunk
*pChunk);
127
128
// read different sections out of the file like vertex
129
// positions, tex coords, faces, etc.
130
void
ReadMaterials
(FILE *fp,
stChunk
*pChunk);
131
void
ReadDiffuse
(FILE *fp,
stChunk
*pChunk);
132
void
ReadAmbient
(FILE *fp,
stChunk
*pChunk);
133
void
ReadSpecular
(FILE *fp,
stChunk
*pChunk);
134
void
ReadMeshMaterials
(FILE *fp,
stChunk
*pChunk);
135
void
ReadFaces
(FILE *fp,
stChunk
*pChunk);
136
void
ReadVertices
(FILE *fp,
stChunk
*pChunk);
137
void
ReadTexCoords
(FILE *fp,
stChunk
*pChunk);
138
139
void
shutdown
();
140
141
// List of mesh objects if there are more than 1,
142
// list of materials, and counters for each.
143
std::vector<stMesh>
meshList
;
144
std::vector<stMaterial>
materialList
;
145
int
totalMeshes
;
146
int
totalMaterials
;
147
};
148
149
#endif
Generated on Tue Oct 2 2012 14:38:37 for mElite by
1.8.2