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 200 unsigned int m_vertexCount;
201 unsigned int m_texCoordCount;
202 unsigned int m_normalCount;
203 unsigned int m_faceCount;
204 unsigned int m_materialCount;
210 unsigned int m_numVertices;
211 unsigned int m_materialIndex;
213 int* m_pVertexIndices;
214 cVector3d* m_pVertices;
216 int* m_pNormalIndices;
217 cVector3d* m_pNormals;
218 int* m_pTextureIndices;
219 cVector3d* m_pTexCoords;
229 m_materialIndex = -1;
231 m_pVertexIndices = NULL;
234 m_pNormalIndices = NULL;
236 m_pTextureIndices = NULL;
245 char m_texture[C_OBJ_SIZE_PATH];
250 float m_emmissive[3];
264 m_diffuse[0] = m_diffuse[1] = m_diffuse[2] = 0.8f;
265 m_ambient[0] = m_ambient[1] = m_ambient[2] = 0.5f;
266 m_specular[0] = m_specular[1] = m_specular[2] = 0.3f;
267 m_emmissive[0] = m_emmissive[1] = m_emmissive[2] = 0.0f;
302 bool LoadModel(
const char szFileName[]);
310 cVector3d* m_pVertices;
319 cVector3d* m_pNormals;
322 cVector3d* m_pTexCoords;
325 cMaterialInfo* m_pMaterials;
328 cOBJFileInfo m_OBJInfo;
331 std::vector<char*> m_groupNames;
341 void readNextString(
char *a_str,
int a_size, FILE *a_hStream);
344 void getTokenParameter(
char a_str[],
const unsigned int a_strSize, FILE *a_hFile);
347 void makePath(
char a_fileAndPath[]);
350 bool loadMaterialLib(
const char a_fFileName[], cMaterialInfo *a_pMaterials,
351 unsigned int *a_curMaterialIndex,
char a_basePath[]);
354 void parseFaceString(
char a_faceString[], cFace *a_faceOut,
const cVector3d *a_pVertices,
355 const cVector3d *a_pNormals,
const cVector3d *a_pTexCoords,
const unsigned int a_materialIndex);
358 void getFileInfo(FILE *a_hStream, cOBJFileInfo *a_stat,
const char a_constBasePath[]);
362 unsigned int getVertexIndex(cMesh* a_Mesh,
364 vertexIndexSet_uint_map* a_VertexMap,
365 vertexIndexSet& vis);
368 #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