void CLoad3DS::ProcessNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk) { // The current chunk to work with tChunk currentChunk = {0}; // Continue to read these chunks until we read the end of this sub chunk while (pPreviousChunk->bytesRead < pPreviousChunk->length) { // Read the next chunk ReadChunk(¤tChunk); // Check which chunk we just read switch (currentChunk.ID) { case OBJECT_MESH: // This lets us know that we are reading a new object // We found a new object, so let's read in it's info using recursion ProcessNextObjectChunk(pModel, pObject, ¤tChunk); break; case OBJECT_VERTICES: // This is the objects vertices ReadVertices(pObject, ¤tChunk); break; case OBJECT_FACES: // This is the objects face information ReadVertexIndices(pObject, ¤tChunk); break; case OBJECT_MATERIAL: // This holds the material name that the object has // This chunk holds the name of the material that the object has assigned to it. // This could either be just a color or a texture map. This chunk also holds // the faces that the texture is assigned to (In the case that there is multiple // textures assigned to one object, or it just has a texture on a part of the object. // Since most of my game objects just have the texture around the whole object, and // they aren't multitextured, I just want the material name. // We now will read the name of the material assigned to this object ReadObjectMaterial(pModel, pObject, ¤tChunk); break; case OBJECT_UV: // This holds the UV texture coordinates for the object // This chunk holds all of the UV coordinates for our object. Let's read them in. ReadUVCoordinates(pObject, ¤tChunk); break; default: // Read past the ignored or unknown chunks currentChunk.bytesRead += fread(gBuffer, 1, currentChunk.length - currentChunk.bytesRead, m_FilePointer); break; } // Add the bytes read from the last chunk to the previous chunk passed in. pPreviousChunk->bytesRead += currentChunk.bytesRead; } }
void ModelLoader::ProcessNextObjectChunk(Model3DS *pModel, Object3DS *pObject, Chunk *pPreviousChunk) { // The current chunk to work with Chunk currentChunk = {0}; // Continue to read these chunks until we read the end of this sub chunk while (pPreviousChunk->bytesRead < pPreviousChunk->length){ // Read the next chunk ReadChunk(¤tChunk); // Check which chunk we just read switch (currentChunk.ID){ case OBJECT_MESH: // This case means we hit a new object, so jump in again and read this next chunk ProcessNextObjectChunk(pModel, pObject, ¤tChunk); break; case OBJECT_VERTICES: // Object vertices ReadVertices(pObject, ¤tChunk); break; case OBJECT_FACES: // Object faces ReadVertexIndices(pObject, ¤tChunk); break; case OBJECT_MATERIAL: // This chunk stores both texture information, or color information // depending on the object. At the moment we'll just support textures // so we'll read in the name of the texture and build it later. If there // is just color we'll not bother then. ReadObjectMaterial(pModel, pObject, ¤tChunk); break; case OBJECT_UV: // UV coordinates ReadUVCoordinates(pObject, ¤tChunk); break; default: // Ignored chunk, read past it. currentChunk.bytesRead += fread(m_Buffer, 1, currentChunk.length - currentChunk.bytesRead, m_FilePointer); break; } // Add the bytes read from the last chunk to the previous chunk passed in. pPreviousChunk->bytesRead += currentChunk.bytesRead; } }
void ProcessNextObjectChunk(Loader3ds *pt3ds,tChunk *pPreviousChunk) { tChunk currentChunk = {0}; while (pPreviousChunk->bytesRead < pPreviousChunk->length) { // Read the next chunk ReadChunk(pt3ds,¤tChunk); switch (currentChunk.ID) { case OBJECT_MESH: // We found a new object so use recursion ProcessNextObjectChunk(pt3ds,¤tChunk); break; case OBJECT_VERTICES: // 4110This is the objects vertices ReadVertices(pt3ds,¤tChunk); break; case OBJECT_FACES: // 4120This is the objects face information ReadVertexIndices(pt3ds,¤tChunk); break; case OBJECT_MATERIAL: ReadObjectMaterial(pt3ds,¤tChunk); break; case OBJECT_UV: // 4140This holds the UV texture coordinates for the object ReadUVCoordinates(pt3ds,¤tChunk); break; case OBJECT_TRANSF: // 4160 ReadObjectTransf(pt3ds,¤tChunk); break; default: currentChunk.bytesRead += fread(pt3ds->gBuffer, 1, currentChunk.length - currentChunk.bytesRead, pt3ds->FilePointer); break; } pPreviousChunk->bytesRead += currentChunk.bytesRead; } }
void CLoad3DS::ProcessNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk) { // int buffer[50000] = {0}; // int *buffer = new int[50000]; m_CurrentChunk = new tChunk; while (pPreviousChunk->bytesRead < pPreviousChunk->length) { ReadChunk(m_CurrentChunk); switch (m_CurrentChunk->ID) { case OBJECT_MESH: ProcessNextObjectChunk(pModel, pObject, m_CurrentChunk); break; case OBJECT_VERTICES: ReadVertices(pObject, m_CurrentChunk); break; case OBJECT_FACES: ReadVertexIndices(pObject, m_CurrentChunk); break; case OBJECT_MATERIAL: ReadObjectMaterial(pModel, pObject, m_CurrentChunk); break; case OBJECT_UV: ReadUVCoordinates(pObject, m_CurrentChunk); break; default: // m_CurrentChunk->bytesRead += ASSET_READ(buffer, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_FilePointer); ASSET_SEEK(m_FilePointer, m_CurrentChunk->length - m_CurrentChunk->bytesRead, SEEK_CUR); m_CurrentChunk->bytesRead += (m_CurrentChunk->length - m_CurrentChunk->bytesRead); break; } pPreviousChunk->bytesRead += m_CurrentChunk->bytesRead; } delete m_CurrentChunk; m_CurrentChunk = pPreviousChunk; // delete []buffer; }
void Loaders::t3DSLoader::ProcessNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk) { m_CurrentChunk = new tChunk; while (pPreviousChunk->bytesRead < pPreviousChunk->length) { ReadChunk(m_CurrentChunk); switch (m_CurrentChunk->ID) { case OBJECT_MESH: ProcessNextObjectChunk(pModel, pObject, m_CurrentChunk); break; case OBJECT_VERTICES: ReadVertices(pObject, m_CurrentChunk); break; case OBJECT_FACES: ReadVertexIndices(pObject, m_CurrentChunk); break; case OBJECT_MATERIAL: ReadObjectMaterial(pModel, pObject, m_CurrentChunk); break; case OBJECT_UV: ReadUVCoordinates(pObject, m_CurrentChunk); break; default: m_CurrentChunk->bytesRead += fread(gBuffer, 1, m_CurrentChunk->length - m_CurrentChunk->bytesRead, m_FilePointer); break; } pPreviousChunk->bytesRead += m_CurrentChunk->bytesRead; } delete m_CurrentChunk; m_CurrentChunk = pPreviousChunk; }