00001 #ifndef _3DS_H
00002 #define _3DS_H
00003
00004 #include <iostream>
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007
00008 # include <string>
00009 # include <vector>
00010
00011 #include "constants.h"
00012
00013 using namespace std;
00014
00015
00016 #define PRIMARY 0x4D4D
00017
00018
00019 #define OBJECTINFO 0x3D3D // This gives the version of the mesh and is found right before the material and object information
00020 #define VERSION 0x0002 // This gives the version of the .3ds file
00021 #define EDITKEYFRAME 0xB000 // This is the header for all of the key frame info
00022
00023
00024 #define MATERIAL 0xAFFF // This stored the texture info
00025 #define OBJECT 0x4000 // This stores the faces, vertices, etc...
00026
00027
00028 #define MATNAME 0xA000 // This holds the material name
00029 #define MATDIFFUSE 0xA020 // This holds the color of the object/material
00030 #define MATMAP 0xA200 // This is a header for a new material
00031 #define MATMAPFILE 0xA300 // This holds the file name of the texture
00032
00033 #define OBJECT_MESH 0x4100 // This lets us know that we are reading a new object
00034
00035
00036 #define OBJECT_VERTICES 0x4110 // The objects vertices
00037 #define OBJECT_FACES 0x4120 // The objects faces
00038 #define OBJECT_MATERIAL 0x4130 // This is found if the object has a material, either texture map or color
00039 #define OBJECT_UV 0x4140 // The UV texture coordinates
00040
00041
00042
00043 struct tIndices {
00044
00045 unsigned short a, b, c, bVisible;
00046 };
00047
00048
00049 struct tChunk
00050 {
00051 unsigned short int ID;
00052 unsigned int length;
00053 unsigned int bytesRead;
00054 };
00055
00056
00057 class CLoad3DS
00058 {
00059 public:
00060 CLoad3DS();
00061
00062
00063 bool Import3DS(t3DModel *pModel, char *strFileName);
00064
00065 private:
00066
00067 int GetString(char *);
00068
00069
00070 void ReadChunk(tChunk *);
00071
00072
00073 void ProcessNextChunk(t3DModel *pModel, tChunk *);
00074
00075
00076 void ProcessNextObjectChunk(t3DModel *pModel, t3DObject *pObject, tChunk *);
00077
00078
00079 void ProcessNextMaterialChunk(t3DModel *pModel, tChunk *);
00080
00081
00082 void ReadColorChunk(tMaterialInfo *pMaterial, tChunk *pChunk);
00083
00084
00085 void ReadVertices(t3DObject *pObject, tChunk *);
00086
00087
00088 void ReadVertexIndices(t3DObject *pObject, tChunk *);
00089
00090
00091 void ReadUVCoordinates(t3DObject *pObject, tChunk *);
00092
00093
00094 void ReadObjectMaterial(t3DModel *pModel, t3DObject *pObject, tChunk *pPreviousChunk);
00095
00096
00097
00098
00099
00100 void CleanUp();
00101
00102
00103 FILE *m_FilePointer;
00104
00105
00106 tChunk *m_CurrentChunk;
00107 tChunk *m_TempChunk;
00108 };
00109
00110
00111 #endif
00112
00113
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127