Changeset 4146 in orxonox.OLD for orxonox/branches/md2_loader
- Timestamp:
- May 10, 2005, 5:07:46 PM (20 years ago)
- Location:
- orxonox/branches/md2_loader/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/md2_loader/src/lib/graphics/importer/abstract_model.h
r4142 r4146 23 23 24 24 #include "stdincl.h" 25 #include "base_object.h" 26 #include <vector> 25 27 26 #include "base_object.h" 28 using namespace std; 27 29 28 30 //template<class T> class tList; 29 template<class T> class vector;31 ; 30 32 31 33 //! This is our 3D point class. CONFLICTING with Vector.cc … … 94 96 int currentAnim; // The current index into pAnimations list (NEW) 95 97 int currentFrame; // The current frame of the current animation (NEW) 96 vector<tAnimationInfo> *animationList; // The list of animations (NEW)97 vector<tMaterialInfo> *materialList; // The list of material information (Textures and colors)98 vector<t3DObject> *objectList; // The object list for our model98 vector<tAnimationInfo> animationList; // The list of animations (NEW) 99 vector<tMaterialInfo> materialList; // The list of material information (Textures and colors) 100 vector<t3DObject> objectList; // The object list for our model 99 101 }; 100 102 -
orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc
r4142 r4146 19 19 #include <fstream> 20 20 #include <string> 21 22 21 #include <vector> 23 22 … … 56 55 void MD2Model::draw(t3DModel *pModel) 57 56 { 58 if( pModel->objectList ->size() <= 0) return;59 60 t3DObject *pObject = pModel->objectList->firstElement();57 if( pModel->objectList.size() <= 0) return; 58 59 t3DObject *pObject = &pModel->objectList[0]; 61 60 glBegin(GL_TRIANGLES); 62 61 for(int j = 0; j < pObject->numOfFaces; j++) … … 112 111 bool MD2Loader::importMD2(t3DModel *pModel, char *fileName, char *textureName) 113 112 { 114 115 pModel->animationList = new vector<tAnimationInfo>();116 pModel->objectList = new vector<t3DObject>();117 pModel->materialList = new vector<tMaterialInfo>();118 119 113 this->pFile = fopen(fileName, "rb"); 120 114 if( unlikely(!pFile)) … … 136 130 if( likely((int)textureName)) 137 131 { 138 tMaterialInfo * textureInfo = new tMaterialInfo;139 strcpy(textureInfo ->strFile, textureName);132 tMaterialInfo textureInfo; 133 strcpy(textureInfo.strFile, textureName); 140 134 /* since there is only one texture for a .Md2 file, the ID is always 0 */ 141 textureInfo ->texureId = 0;142 textureInfo ->uTile = 1;135 textureInfo.texureId = 0; 136 textureInfo.uTile = 1; 143 137 /* we only have 1 material for a model */ 144 138 pModel->numOfMaterials = 1; 145 pModel->materialList ->add(textureInfo);139 pModel->materialList.push_back(textureInfo); 146 140 } 147 141 … … 200 194 void MD2Loader::parseAnimations(t3DModel *pModel) 201 195 { 202 tAnimationInfo * animationInfo = new tAnimationInfo;196 tAnimationInfo animationInfo; 203 197 string strLastName = ""; 204 198 … … 231 225 if( strLastName != "") 232 226 { 233 strcpy(animationInfo ->strName, strLastName.c_str());234 animationInfo ->endFrame = i;235 pModel->animationList ->add(animationInfo);227 strcpy(animationInfo.strName, strLastName.c_str()); 228 animationInfo.endFrame = i; 229 pModel->animationList.push_back(animationInfo); 236 230 memset(&animationInfo, 0, sizeof(tAnimationInfo)); 237 231 pModel->numOfAnimations++; 238 232 } 239 animationInfo ->startFrame = frameNum - 1 + i;233 animationInfo.startFrame = frameNum - 1 + i; 240 234 } 241 235 strLastName = strName; … … 258 252 for (i = 0; i < pModel->numOfObjects; i++) 259 253 { 260 t3DObject * currentFrame = new t3DObject;261 262 currentFrame ->numOfVerts = this->header.numVertices;263 currentFrame ->numTexVertex = this->header.numTexCoords;264 currentFrame ->numOfFaces = this->header.numTriangles;265 266 currentFrame ->pVerts = new CVector3[currentFrame->numOfVerts];267 268 for (j = 0; j < currentFrame ->numOfVerts; j++)269 { 270 currentFrame ->pVerts[j].x = this->pFrames[i].pVertices[j].vertex[0];271 currentFrame ->pVerts[j].y = this->pFrames[i].pVertices[j].vertex[1];272 currentFrame ->pVerts[j].z = this->pFrames[i].pVertices[j].vertex[2];254 t3DObject currentFrame; 255 256 currentFrame.numOfVerts = this->header.numVertices; 257 currentFrame.numTexVertex = this->header.numTexCoords; 258 currentFrame.numOfFaces = this->header.numTriangles; 259 260 currentFrame.pVerts = new CVector3[currentFrame.numOfVerts]; 261 262 for (j = 0; j < currentFrame.numOfVerts; j++) 263 { 264 currentFrame.pVerts[j].x = this->pFrames[i].pVertices[j].vertex[0]; 265 currentFrame.pVerts[j].y = this->pFrames[i].pVertices[j].vertex[1]; 266 currentFrame.pVerts[j].z = this->pFrames[i].pVertices[j].vertex[2]; 273 267 } 274 268 … … 277 271 if( likely(i > 0)) 278 272 { 279 pModel->objectList ->add(currentFrame);273 pModel->objectList.push_back(currentFrame); 280 274 continue; 281 275 } 282 276 283 currentFrame ->pTexVerts = new CVector2[currentFrame->numTexVertex];284 currentFrame ->pFaces = new tFace[currentFrame->numOfFaces];285 286 for(j = 0; j < currentFrame ->numTexVertex; j++)287 { 288 currentFrame ->pTexVerts[j].x = this->pTexCoords[j].u / float(this->header.skinWidth);289 currentFrame ->pTexVerts[j].y = 1 - this->pTexCoords[j].v / float(this->header.skinHeight);290 } 291 292 for(j = 0; j < currentFrame ->numOfFaces; j++)293 { 294 currentFrame ->pFaces[j].vertIndex[0] = this->pTriangles[j].vertexIndices[0];295 currentFrame ->pFaces[j].vertIndex[1] = this->pTriangles[j].vertexIndices[1];296 currentFrame ->pFaces[j].vertIndex[2] = this->pTriangles[j].vertexIndices[2];297 298 currentFrame ->pFaces[j].coordIndex[0] = this->pTriangles[j].textureIndices[0];299 currentFrame ->pFaces[j].coordIndex[1] = this->pTriangles[j].textureIndices[1];300 currentFrame ->pFaces[j].coordIndex[2] = this->pTriangles[j].textureIndices[2];301 } 302 pModel->objectList ->add(currentFrame);277 currentFrame.pTexVerts = new CVector2[currentFrame.numTexVertex]; 278 currentFrame.pFaces = new tFace[currentFrame.numOfFaces]; 279 280 for(j = 0; j < currentFrame.numTexVertex; j++) 281 { 282 currentFrame.pTexVerts[j].x = this->pTexCoords[j].u / float(this->header.skinWidth); 283 currentFrame.pTexVerts[j].y = 1 - this->pTexCoords[j].v / float(this->header.skinHeight); 284 } 285 286 for(j = 0; j < currentFrame.numOfFaces; j++) 287 { 288 currentFrame.pFaces[j].vertIndex[0] = this->pTriangles[j].vertexIndices[0]; 289 currentFrame.pFaces[j].vertIndex[1] = this->pTriangles[j].vertexIndices[1]; 290 currentFrame.pFaces[j].vertIndex[2] = this->pTriangles[j].vertexIndices[2]; 291 292 currentFrame.pFaces[j].coordIndex[0] = this->pTriangles[j].textureIndices[0]; 293 currentFrame.pFaces[j].coordIndex[1] = this->pTriangles[j].textureIndices[1]; 294 currentFrame.pFaces[j].coordIndex[2] = this->pTriangles[j].textureIndices[2]; 295 } 296 pModel->objectList.push_back(currentFrame); 303 297 } 304 298 }
Note: See TracChangeset
for help on using the changeset viewer.