Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4087 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 6, 2005, 5:01:47 PM (20 years ago)
Author:
patrick
Message:

orxonox/branches/md2_loader: finished work on conversion and cleanup function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc

    r4082 r4087  
    212212*/
    213213void MD2Loader::convertDataStructures(t3DModel *pModel)
    214 {}
     214{
     215        int j = 0, i = 0;
     216       
     217        memset(pModel, 0, sizeof(t3DModel));
     218        pModel->numOfObjects = this->header.numFrames;
     219
     220        this->parseAnimations(pModel);
     221
     222        for (i = 0; i < pModel->numOfObjects; i++)
     223        {
     224                t3DObject* currentFrame = new t3DObject;
     225
     226                currentFrame->numOfVerts = this->header.numVertices;
     227                currentFrame->numTexVertex = this->header.numTexCoords;
     228                currentFrame->numOfFaces = this->header.numTriangles;
     229
     230                currentFrame->pVerts = new CVector3[currentFrame->numOfVerts];
     231
     232                for (j = 0; j < currentFrame->numOfVerts; j++)
     233                {
     234                        currentFrame->pVerts[j].x = this->pFrames[i].pVertices[j].vertex[0];
     235                        currentFrame->pVerts[j].y = this->pFrames[i].pVertices[j].vertex[1];
     236                        currentFrame->pVerts[j].z = this->pFrames[i].pVertices[j].vertex[2];
     237                }
     238
     239                delete this->pFrames[i].pVertices;
     240
     241                if( likely(i > 0))
     242                {
     243                        pModel->objectList->add(currentFrame);
     244                        continue;
     245                }
     246                       
     247                currentFrame->pTexVerts = new CVector2[currentFrame->numTexVertex];
     248                currentFrame->pFaces = new tFace[currentFrame->numOfFaces];
     249
     250                for(j = 0; j < currentFrame->numTexVertex; j++)
     251                {
     252                        currentFrame->pTexVerts[j].x = this->pTexCoords[j].u / float(this->header.skinWidth);
     253                        currentFrame->pTexVerts[j].y = 1 - this->pTexCoords[j].v / float(this->header.skinHeight);
     254                }
     255
     256                for(j = 0; j < currentFrame->numOfFaces; j++)
     257                {
     258                        currentFrame->pFaces[j].vertIndex[0] = this->pTriangles[j].vertexIndices[0];
     259                        currentFrame->pFaces[j].vertIndex[1] = this->pTriangles[j].vertexIndices[1];
     260                        currentFrame->pFaces[j].vertIndex[2] = this->pTriangles[j].vertexIndices[2];
     261
     262                        currentFrame->pFaces[j].coordIndex[0] = this->pTriangles[j].textureIndices[0];
     263                        currentFrame->pFaces[j].coordIndex[1] = this->pTriangles[j].textureIndices[1];
     264                        currentFrame->pFaces[j].coordIndex[2] = this->pTriangles[j].textureIndices[2];
     265                }
     266                pModel->objectList->add(currentFrame);
     267        }
     268}
    215269
    216270
     
    226280*/
    227281void MD2Loader::cleanUp()
    228 {}
     282{
     283        fclose(this->pFile);                   
     284       
     285        if( this->pSkins) delete [] this->pSkins;               
     286        if( this->pTexCoords) delete this->pTexCoords;
     287        if( this->pTriangles) delete this->pTriangles;
     288        if( this->pFrames) delete this->pFrames;
     289}
Note: See TracChangeset for help on using the changeset viewer.