//////////////////////////////////////////////////////////////////////////// // // Crytek Engine Source File. // Copyright (C), Crytek Studios, 2002. // ------------------------------------------------------------------------- // File name: geom.cpp // Version: v1.00 // Created: 28/5/2001 by Vladimir Kajalin // Compilers: Visual Studio.NET // Description: loading geometry from cgf // ------------------------------------------------------------------------- // History: // //////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "Geom.h" #include "file.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CGeom::CGeom() : CBaseObj() { memset(&m_Chunk,0,sizeof(m_Chunk)); m_pVertices =NULL; m_pFaces =NULL; // m_pLinks =NULL; m_pUVs =NULL; m_sPropstr =NULL; // bones =NULL; m_pTexFaces =NULL; // m_pNumLinks =NULL; // links =NULL; m_pVcols =NULL; // BoneNames =NULL; } CGeom::~CGeom() { /* if(links) { for(int i=0;iFSeek(pos,SEEK_SET)) return true; int res=f->FRead(&m_Chunk,sizeof(m_Chunk),1); if(res!=1) return true; m_ChunkHeader=m_Chunk.chdr; if(m_ChunkHeader.ChunkType != ChunkType_Mesh || m_ChunkHeader.ChunkVersion != MESH_CHUNK_DESC_VERSION) { memset(&m_Chunk,0,sizeof(m_Chunk)); return true; } //read verts m_pVertices=(CryVertex*)malloc(sizeof(CryVertex)*m_Chunk.nVerts); assert(m_pVertices); res=f->FRead(m_pVertices,sizeof(CryVertex),m_Chunk.nVerts); if(res!=m_Chunk.nVerts) return true; //read m_pFaces m_pFaces=(CryFace*)malloc(sizeof(CryFace)*m_Chunk.nFaces); assert(m_pFaces); res=f->FRead(m_pFaces,sizeof(CryFace),m_Chunk.nFaces); if(res!=m_Chunk.nFaces) return true; //read tverts if(m_Chunk.nTVerts) { m_pUVs=(CryUV*)malloc(sizeof(CryUV)*m_Chunk.nTVerts); assert(m_pUVs); res=f->FRead(m_pUVs,sizeof(CryUV),m_Chunk.nTVerts); if(res!=m_Chunk.nTVerts) return true; // flip tex coords (since it was flipped in max?) for(int t=0; tFRead(m_pTexFaces,sizeof(CryTexFace),m_Chunk.nFaces); if(res!=m_Chunk.nFaces) return true; } } //read Vertex Colors if(m_Chunk.HasVertexCol) { m_pVcols=(CryIRGB *)malloc(m_Chunk.nVerts*sizeof(CryIRGB)); assert(m_pVcols); int res=f->FRead(m_pVcols, sizeof(CryIRGB), m_Chunk.nVerts); /* for (int k=0;k