Changeset 8357 in orxonox.OLD for branches/bsp_model/src/lib
- Timestamp:
- Jun 14, 2006, 2:22:49 AM (18 years ago)
- Location:
- branches/bsp_model/src/lib/graphics/importer/md3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.cc
r8348 r8357 19 19 20 20 21 using namespace std; 21 namespace md3 22 { 23 24 25 /** 26 * create a MD3BoneFrame object with the data coming from the specified input stream 27 */ 28 MD3BoneFrame::MD3BoneFrame(int tagNum /*, DataInput din*/) 29 { /* loadBoneFrame(this, din) */ } 30 31 32 MD3BoneFrame::MD3BoneFrame(/*int tagNum*/) 33 { /* this->tags = new MD3Tag[tagNum] */ } 34 35 36 MD3BoneFrame::~MD3BoneFrame() 37 {} 38 39 40 41 }; -
branches/bsp_model/src/lib/graphics/importer/md3/md3_bone_frame.h
r8348 r8357 13 13 #include <string> 14 14 15 namespace md3 16 { 15 17 16 18 class MD3Tag; 17 18 19 19 20 class MD3BoneFrame … … 21 22 public: 22 23 /** create a MD3BoneFrame object with the data coming from the specified input stream */ 23 MD3BoneFrame(int tagNum /*, DataInput din*/) { /* loadBoneFrame(this, din) */ }24 MD3BoneFrame(/*int tagNum*/) { /* this->tags = new MD3Tag[tagNum] */ }24 MD3BoneFrame(int tagNum /*, DataInput din*/); 25 MD3BoneFrame(/*int tagNum*/); 25 26 virtual ~MD3BoneFrame(); 26 27 … … 39 40 }; 40 41 42 } 41 43 42 44 #endif /* _MD3_ANIMATION_H */ -
branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc
r8355 r8357 17 17 #include "md3_data.h" 18 18 19 #include "md3_bone_frame.h" 20 19 21 20 22 namespace md3 … … 30 32 MD3Data::MD3Data(const std::string& modelFileName, const std::string& skinFileName, float scale) 31 33 { 32 scale *= 0.1f; 33 34 this->pVertices = NULL; 35 this->pGLCommands = NULL; 36 this->pLightNormals = NULL; 37 this->pTexCoor = NULL; 38 39 this->numFrames = 0; 40 this->numVertices = 0; 41 this->numGLCommands = 0; 42 this->numTexCoor = 0; 43 44 // this->scaleFactor = 1.0f; 45 this->scaleFactor = scale; 46 47 this->fileName = ""; 48 this->skinFileName = ""; 34 49 35 50 36 … … 62 48 { 63 49 delete this->header; 64 65 delete [] this->pVertices;66 delete [] this->pGLCommands;67 delete [] this->pLightNormals;68 delete [] this->pTexCoor;69 50 } 70 51 … … 95 76 return false; 96 77 } 97 this->header = new MD3Header; 98 fread(this->header, 1, sizeof(MD3Header), pFile); 99 fileOffset += sizeof(MD3Header); 78 fileOffset += this->readHeader(pFile, fileOffset); 100 79 /* check for the header version: make sure its a md2 file :) */ 101 80 if( unlikely(this->header->version != MD3_VERSION) && unlikely(this->header->ident != MD3_IDENT)) … … 104 83 return false; 105 84 } 106 107 //header debug:108 PRINTF(0)("MD3 Header debug section======================================\n");109 printf("ident: %i\n", this->header->ident);110 printf("version: %i\n", this->header->version);111 printf("filename: %s\n", this->header->filename);112 printf("boneFrameNum: %i\n", this->header->boneFrameNum);113 printf("tag number: %i\n", this->header->tagNum);114 printf("mesh number: %i\n", this->header->meshNum);115 printf("max tex num: %i\n", this->header->maxTexNum);116 printf("bone frame start: %i\n", this->header->boneFrameStart);117 printf("tag start: %i\n", this->header->tagStart);118 printf("mesh start: %i\n", this->header->meshStart);119 printf("fileSize: %i\n", this->header->fileSize);120 85 121 86 … … 132 97 while( !(bBoneFrames && bTags && bMeshes)) 133 98 { 99 printf("while\n"); 134 100 if( fileOffset == this->header->boneFrameStart && !bBoneFrames) 135 101 { … … 217 183 bool MD3Data::loadSkin(const std::string& fileName) 218 184 { 219 if( fileName.empty())220 {221 this->skinFileName = "";222 return false;223 }224 225 this->skinFileName = fileName;226 227 this->material.setName("md2ModelMaterial");228 this->material.setDiffuseMap(fileName);229 this->material.setIllum(3);230 this->material.setAmbient(1.0, 1.0, 1.0);185 // if( fileName.empty()) 186 // { 187 // this->skinFileName = ""; 188 // return false; 189 // } 190 // 191 // this->skinFileName = fileName; 192 // 193 // this->material.setName("md2ModelMaterial"); 194 // this->material.setDiffuseMap(fileName); 195 // this->material.setIllum(3); 196 // this->material.setAmbient(1.0, 1.0, 1.0); 231 197 232 198 return true; … … 239 205 int MD3Data::readHeader(FILE* pFile, int fileOffset) 240 206 { 207 this->header = new MD3Header; 208 fread(this->header, 1, sizeof(MD3Header), pFile); 209 210 //header debug: 211 PRINTF(0)("MD3 Header debug section======================================\n"); 212 printf("ident: %i\n", this->header->ident); 213 printf("version: %i\n", this->header->version); 214 printf("filename: %s\n", this->header->filename); 215 printf("boneFrameNum: %i\n", this->header->boneFrameNum); 216 printf("tag number: %i\n", this->header->tagNum); 217 printf("mesh number: %i\n", this->header->meshNum); 218 printf("max tex num: %i\n", this->header->maxTexNum); 219 printf("bone frame start: %i\n", this->header->boneFrameStart); 220 printf("tag start: %i\n", this->header->tagStart); 221 printf("mesh start: %i\n", this->header->meshStart); 222 printf("fileSize: %i\n", this->header->fileSize); 223 224 225 return sizeof(MD3Header); 226 } 227 228 229 /** 230 * read bone frames 231 */ 232 int MD3Data::readBoneFrames(FILE* pFile, int fileOffset) 233 { 234 this->boneFrames = new MD3BoneFrame*[this->header->boneFrameNum]; 235 236 for( int i = 0; i < this->header->boneFrameNum; i++) 237 this->boneFrames[i] = new MD3BoneFrame(i); 238 241 239 return 0; 242 240 } … … 244 242 245 243 /** 246 * read bone frames247 */ 248 int MD3Data::read BoneFrames(FILE* pFile, int fileOffset)244 * read the tags 245 */ 246 int MD3Data::readTags(FILE* pFile, int fileOffset) 249 247 { 250 248 return 0; … … 253 251 254 252 /** 255 * read the tags256 */ 257 int MD3Data::read Tags(FILE* pFile, int fileOffset)253 * read meshes 254 */ 255 int MD3Data::readMeshes(FILE* pFile, int fileOffset) 258 256 { 259 257 return 0; 260 258 } 261 259 262 263 /** 264 * read meshes 265 */ 266 int MD3Data::readMeshes(FILE* pFile, int fileOffset) 267 { 268 return 0; 269 } 270 271 } 272 260 } 261 -
branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h
r8355 r8357 46 46 { 47 47 48 class MD3BoneFrame; 49 class MD3Mesh; 50 48 51 //! This holds the header information that is read in at the beginning of the file: id software definition 49 52 struct MD3Header … … 87 90 88 91 public: 89 int numFrames; //!< number of frames90 int numVertices; //!< number of vertices91 int numTriangles; //!< number of triangles92 int numTexCoor; //!< number of texture coordinates93 int numGLCommands; //!< number of gl commands in the glList (tells how to draw)94 std::string fileName; //!< file name of the model File95 std::string skinFileName; //!< file name of the skin file96 MD3Header* header; //!< the header file97 92 98 sVec3D* pVertices; //!< pointer to the vertices data block 99 sTriangle* pTriangles; //!< pointer to the triangles data 100 sTexCoor* pTexCoor; //!< pointer to the texture coordinate data 101 int* pGLCommands; //!< pointer to the gllist data block 102 int* pLightNormals; //!< pointer to the light normals 93 MD3Header* header; //!< the header file 103 94 104 Material material; //!< pointer to the material 105 float scaleFactor; //!< the scale factor of the model, (global) 95 std::string filename; //!< the name of the file as recorded in the .md3 file 96 std::string loadFilename; //!< filename of the actual file from which data was loaded 97 98 int boneFrameNum; //!< number of anumation key fames in the models 99 int tagNum; //!< number of tags 100 int meshNum; //!< number of meshes 101 102 int maxTextureNum; //!< maximum number of unique used in an md3 file 103 int boneFrameStart; //!< starting position of bone frame data structures 104 int tagStart; //!< starting position of tag-structures 105 106 int meshStart; //!< starting position of mesh structures 107 108 int fileSize; //!< file size 109 110 111 MD3BoneFrame** boneFrames; //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame 112 MD3Mesh* meshes; //!< array of meshes in the model. each containing the mesh for each of the animation 113 114 int parentTagIndex; //!< tag index 115 116 //MD3Model* parent; //!< reference to the MD3Model 117 118 106 119 }; 107 120 -
branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h
r8354 r8357 16 16 { 17 17 18 class MD3BoneFrame; 19 class MD3Mesh; 20 class MD3Data; 18 19 class MD3Data; 21 20 22 21 class MD3Model : public Model … … 28 27 29 28 30 31 29 private: 32 30 MD3Data* md3Data; //!< reference to the md3 model data 31 }; 33 32 34 std::string filename; //!< the name of the file as recorded in the .md3 file35 std::string loadFilename; //!< filename of the actual file from which data was loaded36 37 int boneFrameNum; //!< number of anumation key fames in the models38 int tagNum; //!< number of tags39 int meshNum; //!< number of meshes40 41 int maxTextureNum; //!< maximum number of unique used in an md3 file42 int boneFrameStart; //!< starting position of bone frame data structures43 int tagStart; //!< starting position of tag-structures44 45 int meshStart; //!< starting position of mesh structures46 47 int fileSize; //!< file size48 49 50 MD3BoneFrame* boneFrames; //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame51 MD3Mesh* meshes; //!< array of meshes in the model. each containing the mesh for each of the animation52 53 int parentTagIndex; //!< tag index54 MD3Model* parent; //!< reference to the MD3Model55 };56 33 } 57 34
Note: See TracChangeset
for help on using the changeset viewer.