00001 #ifndef _tdsloader_hh
00002 #define _tdsloader_hh
00003
00004 #include "tdstypes.hh"
00005
00006
00007 #define PRIMARY 0x4D4D
00008
00009
00010 #define OBJECTINFO 0x3D3D // This gives the version of the mesh and is found right before the material and object information
00011 #define VERSION 0x0002 // This gives the version of the .3ds file
00012 #define EDITKEYFRAME 0xB000 // This is the header for all of the key frame info
00013
00014
00015 #define MATERIAL 0xAFFF // This stored the texture info
00016 #define OBJECT 0x4000 // This stores the faces, vertices, etc...
00017
00018
00019 #define MATNAME 0xA000 // This holds the material name
00020 #define MATDIFFUSE 0xA020 // This holds the color of the object/material
00021 #define MATMAP 0xA200 // This is a header for a new material
00022 #define MATMAPFILE 0xA300 // This holds the file name of the texture
00023
00024 #define OBJECT_MESH 0x4100 // This lets us know that we are reading a new object
00025
00026
00027 #define OBJECT_VERTICES 0x4110 // The objects vertices
00028 #define OBJECT_FACES 0x4120 // The objects faces
00029 #define OBJECT_MATERIAL 0x4130 // This is found if the object has a material, either texture map or color
00030 #define OBJECT_UV 0x4140 // The UV texture coordinates
00031
00032
00033
00034 struct tIndices {
00035
00036 unsigned short a, b, c, bVisible;
00037 };
00038
00039
00040 struct tChunk
00041 {
00042 unsigned short int ID;
00043 unsigned int length;
00044 unsigned int bytesRead;
00045 };
00046
00047
00048 class CLoad3DS {
00049
00050 public:
00051 CLoad3DS();
00052
00053
00054 bool import3DS(t3DModel *pModel, char *strFileName);
00055
00056 private:
00057
00058 int getString(char *);
00059
00060
00061 void readChunk(tChunk *);
00062
00063
00064 void processNextChunk(t3DModel *pModel, tChunk *);
00065
00066
00067 void processNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *);
00068
00069
00070 void processNextMaterialChunk(t3DModel *pModel, tChunk *);
00071
00072
00073 void readColorChunk(tMaterialInfo *pMaterial, tChunk *pChunk);
00074
00075
00076 void readVertices(t3DObject *pObject, tChunk *);
00077
00078
00079 void readVertexIndices(t3DObject *pObject, tChunk *);
00080
00081
00082 void readUVCoordinates(t3DObject *pObject, tChunk *);
00083
00084
00085 void readObjectMaterial(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk);
00086
00087
00088 void computeNormals(t3DModel *pModel);
00089
00090
00091 void cleanUp();
00092
00093
00094 FILE *m_FilePointer;
00095
00096
00097 tChunk *m_CurrentChunk;
00098 tChunk *m_TempChunk;
00099 };
00100
00101 #endif
00102