46 #ifndef CFileModelOBJH
47 #define CFileModelOBJH
77 bool cLoadFileOBJ(cMultiMesh* a_object,
const std::string& a_filename);
80 bool cSaveFileOBJ(cMultiMesh* a_object,
const std::string& a_filename);
97 #ifndef DOXYGEN_SHOULD_SKIP_THIS
105 struct vertexIndexSet
113 vIndex = nIndex = tIndex = 0;
115 vertexIndexSet(
int vIndex,
int nIndex,
int tIndex)
117 this->vIndex = vIndex;
118 this->nIndex = nIndex;
119 this->tIndex = tIndex;
121 vertexIndexSet(
int vIndex)
123 this->vIndex = vIndex;
131 struct ltVertexIndexSet
133 bool operator()(vertexIndexSet v1, vertexIndexSet v2)
const
135 if (v1.vIndex < v2.vIndex)
return 1;
136 if (v2.vIndex < v1.vIndex)
return 0;
137 if (v1.nIndex < v2.nIndex)
return 1;
138 if (v2.nIndex < v1.nIndex)
return 0;
139 if (v1.tIndex < v2.tIndex)
return 1;
146 typedef std::map<vertexIndexSet,unsigned int,ltVertexIndexSet> vertexIndexSet_uint_map;
155 #define C_OBJ_SIZE_PATH 255
158 #define C_OBJ_VERTEX_ID "v"
159 #define C_OBJ_TEXCOORD_ID "vt"
160 #define C_OBJ_NORMAL_ID "vn"
161 #define C_OBJ_FACE_ID "f"
162 #define C_OBJ_COMMENT_ID "#"
163 #define C_OBJ_MTL_LIB_ID "mtllib"
164 #define C_OBJ_USE_MTL_ID "usemtl"
165 #define C_OBJ_NAME_ID "g"
168 #define C_OBJ_NEW_MTL_ID "newmtl"
169 #define C_OBJ_MTL_TEXTURE_ID "map_Kd"
170 #define C_OBJ_MTL_AMBIENT_ID "Ka"
171 #define C_OBJ_MTL_DIFFUSE_ID "Kd"
172 #define C_OBJ_MTL_SPECULAR_ID "Ks"
173 #define C_OBJ_MTL_SHININESS_ID "Ns"
174 #define C_OBJ_MTL_ALPHA_ID "Tr"
175 #define C_OBJ_MTL_ALPHA_ID_ALT "d"
178 #define C_OBJ_MAX_STR_SIZE 1024
181 #define C_OBJ_MAX_VERTICES 256
186 unsigned int m_vertexCount;
187 unsigned int m_texCoordCount;
188 unsigned int m_normalCount;
189 unsigned int m_faceCount;
190 unsigned int m_materialCount;
196 unsigned int m_numVertices;
197 unsigned int m_materialIndex;
202 int *m_pVertexIndices;
203 cVector3d *m_pVertices;
205 int *m_pNormalIndices;
206 cVector3d *m_pNormals;
207 int *m_pTextureIndices;
208 cVector3d *m_pTexCoords;
215 char m_texture[C_OBJ_SIZE_PATH];
220 float m_emmissive[3];
228 m_diffuse[0] = m_diffuse[1] = m_diffuse[2] = 0.8f;
229 m_ambient[0] = m_ambient[1] = m_ambient[2] = 0.8f;
230 m_specular[0] = m_specular[1] = m_specular[2] = 0.3f;
231 m_emmissive[0] = m_emmissive[1] = m_emmissive[2] = 0.0f;
266 bool LoadModel(
const char szFileName[]);
274 cVector3d* m_pVertices;
283 cVector3d* m_pNormals;
286 cVector3d* m_pTexCoords;
289 cMaterialInfo* m_pMaterials;
292 cOBJFileInfo m_OBJInfo;
295 std::vector<char*> m_groupNames;
305 void readNextString(
char a_string[],
int a_size, FILE *hStream);
308 void getTokenParameter(
char a_string[],
const unsigned int a_strSize, FILE *a_hFile);
311 void makePath(
char a_fileAndPath[]);
314 bool loadMaterialLib(
const char a_fFileName[], cMaterialInfo *a_pMaterials,
315 unsigned int *a_curMaterialIndex,
char a_basePath[]);
318 void parseFaceString(
char a_faceString[], cFace *a_faceOut,
const cVector3d *a_pVertices,
319 const cVector3d *a_pNormals,
const cVector3d *a_pTexCoords,
const unsigned int a_materialIndex);
322 void getFileInfo(FILE *a_hStream, cOBJFileInfo *a_stat,
const char a_constBasePath[]);
326 unsigned int getVertexIndex(cMesh* a_Mesh,
328 vertexIndexSet_uint_map* a_VertexMap,
329 vertexIndexSet& vis);
332 #endif // DOXYGEN_SHOULD_SKIP_THIS
Implements a 3D multi-mesh object.
bool cSaveFileOBJ(cMultiMesh *a_object, const std::string &a_filename)
This function saves an OBJ model file.
Definition: CFileModelOBJ.cpp:381
bool cLoadFileOBJ(cMultiMesh *a_object, const std::string &a_filename)
This function loads an OBJ model file.
Definition: CFileModelOBJ.cpp:81
Definition: CAudioBuffer.cpp:56
bool g_objLoaderShouldGenerateExtraVertices
Definition: CFileModelOBJ.cpp:65