Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CLoad3DS Class Reference

#include <3dsloader.hh>

Collaboration diagram for CLoad3DS:

Collaboration graph
[legend]
List of all members.

Public Methods

 CLoad3DS ()
bool import3DS (t3DModel *pModel, char *strFileName)

Private Methods

int getString (char *)
void readChunk (tChunk *)
void processNextChunk (t3DModel *pModel, tChunk *)
void processNextObjectChunk (t3DModel *pModel, t3DObject *pObject, tChunk *)
void processNextMaterialChunk (t3DModel *pModel, tChunk *)
void readColorChunk (tMaterialInfo *pMaterial, tChunk *pChunk)
void readVertices (t3DObject *pObject, tChunk *)
void readVertexIndices (t3DObject *pObject, tChunk *)
void readUVCoordinates (t3DObject *pObject, tChunk *)
void readObjectMaterial (t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk)
void computeNormals (t3DModel *pModel)
void cleanUp ()

Private Attributes

FILE * m_FilePointer
tChunkm_CurrentChunk
tChunkm_TempChunk

Constructor & Destructor Documentation

CLoad3DS::CLoad3DS  
 

This file handles all of the code needed to load a .3DS file. Basically, how it works is, you load a chunk, then you check the chunk ID. Depending on the chunk ID, you load the information that is stored in that chunk. If you do not want to read that information, you read past it. You know how many bytes to read past the chunk because every chunk stores the length in bytes of that chunk.

Definition at line 18 of file 3dsloader.cc.

References m_CurrentChunk, and m_TempChunk.


Member Function Documentation

void CLoad3DS::cleanUp   [private]
 

This function cleans up our allocated memory and closes the file

Definition at line 72 of file 3dsloader.cc.

References m_CurrentChunk, m_FilePointer, and m_TempChunk.

Referenced by import3DS().

void CLoad3DS::computeNormals t3DModel   pModel [private]
 

This function computes the normals and vertex normals of the objects

Definition at line 584 of file 3dsloader.cc.

References addVector(), cross(), divideVectorByScaler(), anoid::simple::i(), anoid::simple::j(), normalize(), t3DObject::numOfFaces, t3DModel::numOfObjects, t3DObject::numOfVerts, t3DObject::pFaces, t3DObject::pNormals, t3DModel::pObject, t3DObject::pVerts, and Vector().

Referenced by import3DS().

int CLoad3DS::getString char *    pBuffer [private]
 

This function reads in a string of characters

Definition at line 345 of file 3dsloader.cc.

References m_FilePointer.

Referenced by processNextChunk(), and readObjectMaterial().

bool CLoad3DS::import3DS t3DModel   pModel,
char *    strFileName
 

Reads the 3DS file with the filename strFileName and returns true or false depending of successfull reading

Definition at line 29 of file 3dsloader.cc.

References cleanUp(), computeNormals(), tChunk::ID, m_CurrentChunk, m_FilePointer, PRIMARY, processNextChunk(), and readChunk().

void CLoad3DS::processNextChunk t3DModel   pModel,
tChunk   pPreviousChunk
[private]
 

This function reads the main sections of the .3DS file, then dives deeper with recursion

Definition at line 83 of file 3dsloader.cc.

References tChunk::bytesRead, EDITKEYFRAME, getString(), tChunk::ID, tChunk::length, m_CurrentChunk, m_FilePointer, m_TempChunk, MATERIAL, t3DModel::numOfMaterials, t3DModel::numOfObjects, OBJECT, OBJECTINFO, t3DModel::pMaterials, t3DModel::pObject, processNextMaterialChunk(), processNextObjectChunk(), readChunk(), VERSION, and anoid::main::version.

Referenced by import3DS().

void CLoad3DS::processNextMaterialChunk t3DModel   pModel,
tChunk   pPreviousChunk
[private]
 

This function handles all the information about the material (Texture)

Definition at line 272 of file 3dsloader.cc.

References tChunk::bytesRead, tChunk::ID, tChunk::length, m_CurrentChunk, m_FilePointer, MATDIFFUSE, MATMAP, MATMAPFILE, MATNAME, t3DModel::numOfMaterials, t3DModel::pMaterials, readChunk(), and readColorChunk().

Referenced by processNextChunk().

void CLoad3DS::processNextObjectChunk t3DModel   pModel,
t3DObject   pObject,
tChunk   pPreviousChunk
[private]
 

This function handles all the information about the objects in the file

Definition at line 204 of file 3dsloader.cc.

References tChunk::bytesRead, tChunk::ID, tChunk::length, m_CurrentChunk, m_FilePointer, OBJECT_FACES, OBJECT_MATERIAL, OBJECT_MESH, OBJECT_UV, OBJECT_VERTICES, readChunk(), readObjectMaterial(), readUVCoordinates(), readVertexIndices(), and readVertices().

Referenced by processNextChunk().

void CLoad3DS::readChunk tChunk   pChunk [private]
 

reads the chunk ID and its length in bytes

Definition at line 330 of file 3dsloader.cc.

References tChunk::bytesRead, tChunk::ID, tChunk::length, and m_FilePointer.

Referenced by import3DS(), processNextChunk(), processNextMaterialChunk(), processNextObjectChunk(), and readColorChunk().

void CLoad3DS::readColorChunk tMaterialInfo   pMaterial,
tChunk   pChunk
[private]
 

This function reads in the RGB color data

Definition at line 368 of file 3dsloader.cc.

References tChunk::bytesRead, tMaterialInfo::color, tChunk::length, m_FilePointer, m_TempChunk, and readChunk().

Referenced by processNextMaterialChunk().

void CLoad3DS::readObjectMaterial t3DModel   pModel,
t3DObject   pObject,
tChunk   pPreviousChunk
[private]
 

This function reads in the material name assigned to the object and sets the materialID

Definition at line 462 of file 3dsloader.cc.

References t3DObject::bHasTexture, tChunk::bytesRead, getString(), anoid::simple::i(), tChunk::length, m_FilePointer, t3DObject::materialID, t3DModel::numOfMaterials, and t3DModel::pMaterials.

Referenced by processNextObjectChunk().

void CLoad3DS::readUVCoordinates t3DObject   pObject,
tChunk   pPreviousChunk
[private]
 

This function reads in the UV coordinates for the object

Definition at line 423 of file 3dsloader.cc.

References tChunk::bytesRead, tChunk::length, m_FilePointer, t3DObject::numTexVertex, and t3DObject::pTexVerts.

Referenced by processNextObjectChunk().

void CLoad3DS::readVertexIndices t3DObject   pObject,
tChunk   pPreviousChunk
[private]
 

This function reads in the indices for the vertex array

Definition at line 384 of file 3dsloader.cc.

References tChunk::bytesRead, anoid::simple::i(), anoid::simple::j(), m_FilePointer, t3DObject::numOfFaces, and t3DObject::pFaces.

Referenced by processNextObjectChunk().

void CLoad3DS::readVertices t3DObject   pObject,
tChunk   pPreviousChunk
[private]
 

This function reads in the vertices for the object

Definition at line 441 of file 3dsloader.cc.

References tChunk::bytesRead, tChunk::length, m_FilePointer, t3DObject::numOfVerts, and t3DObject::pVerts.

Referenced by processNextObjectChunk().


Member Data Documentation

tChunk* CLoad3DS::m_CurrentChunk [private]
 

Definition at line 97 of file 3dsloader.hh.

Referenced by cleanUp(), CLoad3DS(), import3DS(), processNextChunk(), processNextMaterialChunk(), and processNextObjectChunk().

FILE* CLoad3DS::m_FilePointer [private]
 

Definition at line 94 of file 3dsloader.hh.

Referenced by cleanUp(), getString(), import3DS(), processNextChunk(), processNextMaterialChunk(), processNextObjectChunk(), readChunk(), readColorChunk(), readObjectMaterial(), readUVCoordinates(), readVertexIndices(), and readVertices().

tChunk* CLoad3DS::m_TempChunk [private]
 

Definition at line 98 of file 3dsloader.hh.

Referenced by cleanUp(), CLoad3DS(), processNextChunk(), and readColorChunk().


The documentation for this class was generated from the following files:
Anoid NG © Michael Westergaard, Martin Stig Stissing, Ronni Michael Laursen, and Kristian Bisgaard Lassen