Changeset 8372 in orxonox.OLD for branches/bsp_model/src/lib/graphics/importer
- Timestamp:
- Jun 14, 2006, 11:28:29 AM (18 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc
r8371 r8372 19 19 #include "md3_bone_frame.h" 20 20 #include "md3_tag.h" 21 #include "md3_mesh.h" 21 22 22 23 … … 118 119 } 119 120 120 #if 0121 this->fileName =fileName;122 /* got the data: map it to locals */123 this->numFrames = this->header->numFrames;124 this->numVertices = this->header->numVertices;125 this->numTriangles = this->header->numTriangles;126 this->numGLCommands = this->header->numGlCommands;127 this->numTexCoor = this->header->numTexCoords;128 /* allocate memory for the data storage */129 this->pVertices = new sVec3D[this->numVertices * this->numFrames];130 this->pGLCommands = new int[this->numGLCommands];131 this->pLightNormals = new int[this->numVertices * this->numFrames];132 this->pTriangles = new sTriangle[this->numTriangles];133 this->pTexCoor = new sTexCoor[this->numTexCoor];134 buffer = new char[this->numFrames * this->header->frameSize];135 136 137 /* read frame data from the file to a temp buffer */138 fseek(pFile, this->header->offsetFrames, SEEK_SET);139 fread(buffer, this->header->frameSize, this->numFrames, pFile);140 /* read opengl commands */141 fseek(pFile, this->header->offsetGlCommands, SEEK_SET);142 fread(this->pGLCommands, sizeof(int), this->numGLCommands, pFile);143 /* triangle list */144 fseek(pFile, this->header->offsetTriangles, SEEK_SET);145 fread(this->pTriangles, sizeof(sTriangle), this->numTriangles, pFile);146 /* read in texture coordinates */147 fseek(pFile, this->header->offsetTexCoords, SEEK_SET);148 fread(this->pTexCoor, sizeof(sTexCoor), this->numTexCoor, pFile);149 150 151 for(int i = 0; i < this->numFrames; ++i)152 {153 frame = (sFrame*)(buffer + this->header->frameSize * i);154 pVertex = this->pVertices + this->numVertices * i;155 pNormals = this->pLightNormals + this->numVertices * i;156 157 for(int j = 0; j < this->numVertices; ++j)158 {159 /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)... */160 pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;161 pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;162 pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;163 164 //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);165 166 pNormals[j] = frame->pVertices[j].lightNormalIndex;167 }168 }169 PRINTF(4)("Finished loading the md2 file\n");170 #endif171 172 //delete [] buffer;173 121 fclose(pFile); 174 122 … … 240 188 MD3BoneFrameData* md = new MD3BoneFrameData; 241 189 fread(md, 1, sizeof(MD3BoneFrameData), pFile); 190 this->boneFrames[i]->data = md; 242 191 } 243 192 … … 262 211 MD3TagData* md = new MD3TagData; 263 212 fread(md, 1, sizeof(MD3TagData), pFile); 213 this->boneFrames[i]->tags[j]->data = md; 264 214 } 265 215 } … … 274 224 int MD3Data::readMeshes(FILE* pFile, int fileOffset) 275 225 { 226 this->meshes = new MD3Mesh*[this->header->meshNum]; 227 228 for( int i = 0; i < this->header->meshNum; i++) 229 { 230 this->meshes[i] = new MD3Mesh(); 231 232 } 276 233 return 0; 277 234 } -
branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h
r8357 r8372 110 110 111 111 MD3BoneFrame** boneFrames; //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame 112 MD3Mesh* 112 MD3Mesh** meshes; //!< array of meshes in the model. each containing the mesh for each of the animation 113 113 114 114 int parentTagIndex; //!< tag index -
branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.cc
r8351 r8372 24 24 * md3 mesh constructor 25 25 */ 26 MD3Mesh::MD3Mesh( FILE *pFile, int dataOffset)26 MD3Mesh::MD3Mesh() 27 27 { 28 28 } -
branches/bsp_model/src/lib/graphics/importer/md3/md3_mesh.h
r8351 r8372 23 23 { 24 24 public: 25 MD3Mesh( FILE *pFile, int dataOffset);25 MD3Mesh(); 26 26 virtual ~MD3Mesh(); 27 27 -
branches/bsp_model/src/lib/graphics/importer/md3/md3_tag.h
r8359 r8372 30 30 31 31 32 p rivate:32 public: 33 33 std::string name; //!< name of tag as its usualy called in the md3 file 34 34 Vector position; //!< the position of the tag reltive to the models containing that tag -
branches/bsp_model/src/lib/graphics/importer/md_model_structure.h
r8352 r8372 2 2 * @file md_model_structure.h 3 3 */ 4 5 6 7 #ifndef _MD3_MODEL_STRUCTURE_H 8 #define _MD3_MODEL_STRUCTURE_H 4 9 5 10 … … 81 86 } sAnimState; 82 87 88 #endif /* _MD3_MODEL_STRUCTURE_H */
Note: See TracChangeset
for help on using the changeset viewer.