Page principale | Liste des namespaces | Hiérarchie des classes | Liste par ordre alphabétique | Liste des composants | Liste des fichiers | Membres des namespaces | Composants | Déclarations

ExCModel3DS.h

Aller à la documentation de ce fichier.
00001 /************************************************************************/
00002 /* Ex Nihlo Engine by Hermanns Christophe                                                               */
00003 /************************************************************************/
00004 /* This program is free software; you can redistribute it and/or                */
00005 /* modify it under the terms of the GNU General Public License                  */
00006 /* as published by the Free Software Foundation; either version 2               */
00007 /* of the License, or (at your option) any later version.                               */
00008 /*                                                                                                                                              */
00009 /* This program is distributed in the hope that it will be useful,              */
00010 /* but WITHOUT ANY WARRANTY; without even the implied warranty of               */
00011 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                                 */
00012 /*                                                                                                                                              */
00013 /* See the GNU General Public License for more details.                                 */
00014 /*                                                                                                                                              */
00015 /* You should have received a copy of the GNU General Public License    */
00016 /* along with this program; if not, write to the Free Software                  */
00017 /* Foundation, Inc., 59 Temple Place - Suite 330,                                               */
00018 /* Boston, MA  02111-1307, USA.                                                                                 */
00019 /*                                                                                                                                              */
00020 /* If you use a important part of this code please send me a mail               */
00021 /* I just want to see where my code go thks :)                                                  */
00022 /************************************************************************/
00023 
00024 /************************************************************************/
00025 /* Contact                                                              */  
00026 /************************************************************************/
00027 /* ExNihilo Website :www.ploksoftware.org                               */
00028 /*                                                                      */
00029 /* Hermanns Christophe ExNihilo creator and main programmer             */
00030 /*                                                                      */
00031 /* Mail             : Data@ploksoftware.org                                                             */
00032 /* ICQ              : 8030901                                                                                   */
00033 /* MSN Messenger    : Data_7@hotmail.com                                                                */
00034 /*                                                                      */
00035 /*                                                                      */
00036 /************************************************************************/
00037 
00038 /************************************************************************/
00039 /* File Description                                                                                             */
00040 /************************************************************************/
00041 /* File Name   :ExCModel3DS.h                                                                           */
00042 /*                                                                                                                                              */
00043 /* Start Date   :06/20/2003                                                                                             */
00044 /*                                                                                                                                              */
00045 /* Last Update :06/20/2003                                              */
00046 /*                                                                                                                                              */
00047 /* File Description :                                                                                                   */
00048 /*                                                                      */
00049 /* For update of this file check : www.ploksoftware.org                 */
00050 /************************************************************************/
00051 
00052 #ifndef __EXCMODEL3DS_H__
00053 #define __EXCMODEL3DS_H__
00054 //------------------------------------------------------------------------
00055 //Includes
00056 //------------------------------------------------------------------------
00057 #include "ExDefine.h"
00058 //------------------------------------------------------------------------
00059 #include "Math/ExMath.h"
00060 #include "Math/ExCFrustum.h"
00061 //------------------------------------------------------------------------
00062 #include "Object/Object3D/Model/ExCModel.h"
00063 //------------------------------------------------------------------------
00064 #include "Object/Object3D/Gizmo/ExCGizmoRectangle.h"
00065 //------------------------------------------------------------------------
00066 
00067 //define relative to 3ds file format
00068 
00069 //>------ Primary Chunk, at the beginning of each file
00070 #define PRIMARY       0x4D4D
00071 //>------ Main Chunks
00072 #define OBJECTINFO    0x3D3D                            // This gives the version of the mesh and is found right before the material and object information
00073 #define EDITKEYFRAME  0xB000                            // This is the header for all of the key frame info
00074 #define FILEVERSION   0x0002
00075 //>------ common chunk
00076 #define INT_PERCENTAGE          0x0030
00077 #define PERCENTAGE                      0x0031
00078 //>------ sub defines of OBJECTINFO
00079 #define MATERIAL          0xAFFF                                // This stored the texture info
00080 #define OBJECT            0x4000                                // This stores the faces, vertices, etc...
00081 #define MESH_VERSION  0x3D3E
00082 #define MASTER_SCALE  0x0100
00083 
00084 //>------ sub defines of MATERIAL
00085 
00086 
00087 #define MATNAME                         0xA000                          // The material name                            TYPE:ascii
00088 #define MATAMBIENTCOLOR         0xA010                          // The material ambient color           TYPE:s
00089 #define MATDIFFUSE                      0xA020                          // The material diffuse color           TYPE:s
00090 #define MATSPECULAR                     0xA030                          // The material specular color          TYPE:s
00091 #define MATSHININESS            0xA040                          // The shininess                                        TYPE:s
00092 #define MATSHININESSSTR         0xA041                          // The shininess strenght                       TYPE:s
00093 #define MATTRANSPARENCY         0xA050
00094 #define MATTRANSFALLOFF         0xA052
00095 #define MATREFLECTBLUR          0xA053
00096 #define MATTWOSIDED                     0xA081
00097 #define MATTRANSPARENCYADD      0xA083
00098 #define MATSELFILUM                     0xA084
00099 #define MATWIREON                       0xA085
00100 #define MATWIRETHICKNESS        0xA087
00101 #define MATFACEMAP                      0xA088
00102 #define MATTRANSFALLOFFIN       0xA08A
00103 #define MATSOFTEN                       0xA08C
00104 #define MAT3DWIRETHICKNESS      0xA08E
00105 #define MATTYPE                         0xA100
00106 #define MATMAP                          0xA200                          // This is a header for a new material
00107 #define MATMAPFILE                      0xA300                          // This holds the file name of the texture
00108 #define MATMAPOPTION            0xA351                          
00109 #define MATMAPFILTERINGBLUR     0xA353          
00110 
00111 
00112 #define OBJECT_MESH   0x4100                            // This lets us know that we are reading a new object
00113 //>------ sub defines of OBJECT_MESH
00114 #define OBJECT_VERTICES     0x4110                      // The objects vertices
00115 #define OBJECT_FACES            0x4120                  // The objects faces
00116 #define OBJECT_MATERIAL         0x4130                  // This is found if the object has a material, either texture map or color
00117 #define OBJECT_UV                       0x4140                  // The UV texture coordinates
00118 #define OBJECT_SMOOTH_GROUP 0x4150
00119 #define OBJECT_MESH_MATRIX      0x4160
00120 
00121 struct tChunk
00122 {
00123         unsigned short int ID;                                  // The chunk's ID               
00124         unsigned int length;                                    // The length of the chunk
00125         unsigned int bytesRead;                                 // The amount of bytes read within that chunk
00126 };
00127 struct tFace
00128 {
00129         int vertIndex[3];                       // indicies for the verts that make up this triangle
00130         int coordIndex[3];                      // indicies for the tex coords to texture this face
00131 };
00132 struct tMaterialInfo
00133 {
00134         char  strName[255];                     // The texture name
00135         char  strFile[255];                     // The texture file name (If this is set it's a texture map)
00136         BYTE  color[3];                         // The color of the object (R, G, B)
00137         int   texureId;                         // the texture ID
00138         float uTile;                            // u tiling of texture  (Currently not used)
00139         float vTile;                            // v tiling of texture  (Currently not used)
00140         float uOffset;                      // u offset of texture      (Currently not used)
00141         float vOffset;                          // v offset of texture  (Currently not used)
00142 } ;
00143 struct t3DObject 
00144 {
00145         int  numOfVerts;                        // The number of verts in the model
00146         int  numOfFaces;                        // The number of faces in the model
00147         int  numTexVertex;                      // The number of texture coordinates
00148         int  materialID;                        // The texture ID to use, which is the index into our texture array
00149         bool bHasTexture;                       // This is TRUE if there is a texture map for this object
00150         char strName[255];                      // The name of the object
00151         std::string                     Material;                               
00152         std::vector<ExCVec3D>  Verts;   // The object's vertices
00153         std::vector<ExCVec3D>  Normals; // The object's normals
00154         std::vector<ExCVec2D>  TexVerts;        // The texture's UV coordinates
00155         std::vector<tFace>                Faces;        // The faces information of the object
00156         
00157         float   *TabVertices;
00158         float   *TabTextures;
00159 
00160         ExCGizmoRectangle               m_BoxForFrustrum;
00161         GLuint                                  m_ListId;
00162 };
00163 //--------------------------------
00164 class ExCModel3DS : public ExCModel
00165 {
00166 protected:
00167 
00168 //--------------------------------
00169 // Variable
00170 //--------------------------------
00171         FILE                    *m_filePtr;
00172 //--------------------------------
00173 // Methode
00174 //--------------------------------
00175         void ReadObjectInfo(tChunk *chunk);
00176         void ReadObject(tChunk *chunk);
00177         void ReadObjectMaterial(tChunk *chunk);
00178 
00179         void ReadChunk(tChunk *chunk);
00180         void Skip(tChunk *chunk);
00181         
00182         void ReadVertices(t3DObject *pObject, tChunk *chunk);
00183         void ReadFace(t3DObject *pObject, tChunk *chunk);
00184         void ReadUVCoordinates(t3DObject *pObject, tChunk *chunk);
00185         void ReadObjectMaterial(t3DObject *pObject, tChunk *chunk);
00186 
00187         int numOfObjects;                                       // The number of objects in the model
00188         int numOfMaterials;                                     // The number of materials for the model
00189         std::vector<tMaterialInfo> m_VecMaterials;      // The list of material information (Textures and colors)
00190         
00191 
00192         tChunk *m_CurrentChunk;
00193         tChunk *m_TempChunk;
00194         GLuint                                  m_ListId;
00195 
00196         
00197 
00198         float                   *m_VertexArray;                 //vertex Arrray
00199         unsigned int    *m_FaceArray;                   //Faces Array
00200         float                   *m_TextureArray;                //texture Arrray
00201         void BuildArray(int Rendu);
00202         std::vector<std::string> m_VecAction;
00203         std::vector<std::string>::iterator m_IVecAction;
00204 
00205 
00206         PFNGLBINDBUFFERARBPROC glBindBufferARB ;
00207         PFNGLGENBUFFERSARBPROC glGenBuffersARB ;
00208         PFNGLBUFFERDATAARBPROC glBufferDataARB ;
00209 public:
00210         bool                                    HasList;
00211         bool                                    HasArray;
00212         std::vector<t3DObject> *m_VecObject;                    // The object list for our model
00213 //--------------------------------
00214 // Constructor  // Destructor
00215 //--------------------------------
00216         ExCModel3DS(void);
00217         ~ExCModel3DS(void);
00218 //--------------------------------
00219 // Methode
00220 //--------------------------------
00221         void BuildList(int Rendu);
00222         void Draw(void);
00223         void CallAllList(void);
00224         void CallAllArray(void);
00225         bool Load(std::string FileName);
00226         void StartAction(std::string     Action);
00227         void StopAction(std::string      Action);
00228         void Process(std::string         Action);
00229         void ProcessAllAction(void);
00230         ExCAction InputAction(ExCAction Action);
00231         bool IsAction(std::string Action);
00232 };
00233 #endif //__EXCMODEL3DS_H__

Généré le Tue Oct 28 12:43:32 2003 pour ExNihilo par doxygen 1.3.4