[1869] | 1 | #ifndef _3DSTRUCTS_H |
---|
| 2 | #define _3DSTRUCTS_H |
---|
| 3 | |
---|
| 4 | /* STL (Standard Template Library) Vector */ |
---|
| 5 | #include <vector> |
---|
| 6 | using namespace std; |
---|
| 7 | |
---|
| 8 | /*########################### Showroom.cpp ########################### |
---|
| 9 | # This file includes all of the model structures that are needed to load |
---|
| 10 | # in a .3DS file. |
---|
| 11 | # $Author: Ben Humphrey (DigiBen), Johannes Bader |
---|
| 12 | # $Revision: 1.0 |
---|
| 13 | # $Date: 5.5.04 |
---|
| 14 | ###################################################################### */ |
---|
| 15 | |
---|
| 16 | /* This is our 3D point class. |
---|
| 17 | This will be used to store the vertices of our model. */ |
---|
| 18 | class CVector3 |
---|
| 19 | { |
---|
| 20 | public: |
---|
| 21 | float x, y, z; |
---|
| 22 | }; |
---|
| 23 | |
---|
| 24 | /* This is our 2D point class. |
---|
| 25 | This will be used to store the UV coordinates. */ |
---|
| 26 | class CVector2 |
---|
| 27 | { |
---|
| 28 | public: |
---|
| 29 | float x, y; |
---|
| 30 | }; |
---|
| 31 | |
---|
[1870] | 32 | /* ############## Currently not supported by Showroom */ |
---|
| 33 | |
---|
| 34 | /* This holds the information for a material. It may be a texture map of a |
---|
| 35 | color. Some of these are not used, but I left them because you will want to |
---|
| 36 | eventually read in the UV tile ratio and the UV tile offset for some |
---|
| 37 | models.*/ |
---|
| 38 | struct tMaterialInfo |
---|
| 39 | { |
---|
| 40 | char strName[255]; /* The texture name */ |
---|
| 41 | char strFile[255]; /* The texture file name */ |
---|
[1901] | 42 | /* pb fix: BYTE -> int */ |
---|
| 43 | int color[3]; /* The color of the object (R, G, B) */ |
---|
[1870] | 44 | int texureId; /* the texture ID */ |
---|
| 45 | float uTile; /* u tiling of texture (Currently not used) */ |
---|
| 46 | float vTile; /* v tiling of texture (Currently not used) */ |
---|
| 47 | float uOffset; /* u offset of texture (Currently not used) */ |
---|
| 48 | float vOffset; /* v offset of texture (Currently not used) */ |
---|
| 49 | } ; |
---|
| 50 | |
---|
| 51 | |
---|
[1869] | 52 | /* This is the face structure. This is is used for indexing into the vertex |
---|
| 53 | and texture coordinate arrays. From this information we know which vertices |
---|
| 54 | from our vertex array go to which face, along with the correct |
---|
| 55 | texture coordinates. */ |
---|
| 56 | struct tFace |
---|
| 57 | { |
---|
| 58 | int vertIndex[3]; /* indicies for the verts that make up this triangle */ |
---|
| 59 | int coordIndex[3]; /* indicies for the tex coords to texture this face */ |
---|
| 60 | }; |
---|
| 61 | |
---|
| 62 | /* This holds the object information. An object is part of a model */ |
---|
| 63 | struct t3dObject |
---|
| 64 | { |
---|
| 65 | int iNumOfVerts; /* The number of verts in the model */ |
---|
| 66 | int iNumOfFaces; /* The number of faces in the model */ |
---|
| 67 | char strName[255]; /* The name of the object */ |
---|
| 68 | CVector3 *pVerts; /* The object's vertices */ |
---|
| 69 | CVector3 *pNormals; /* The object's normals */ |
---|
| 70 | CVector2 *pTexVerts; /* The texture's UV coordinates */ |
---|
| 71 | tFace *pFaces; /* The faces information of the object */ |
---|
| 72 | |
---|
| 73 | /* Not used */ |
---|
| 74 | int iNumTexVertex; // The number of texture coordinates |
---|
| 75 | int materialID; // The texture ID to use, which is the index into our texture array |
---|
| 76 | bool bHasTexture; // This is TRUE if there is a texture map for this object |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | /* This holds the model information. A model may consist of several |
---|
| 80 | objects */ |
---|
| 81 | class C3dModel |
---|
| 82 | { |
---|
| 83 | public: |
---|
| 84 | int numOfObjects; /* The number of objects */ |
---|
| 85 | vector<t3dObject> pObject; /* The object list for our model */ |
---|
| 86 | |
---|
| 87 | /* Not yet used */ |
---|
| 88 | int numOfMaterials; /* The number of materials */ |
---|
| 89 | vector<tMaterialInfo> pMaterials; /* The list of material information |
---|
| 90 | (Textures and colors) */ |
---|
| 91 | /* Draws the Model, mode = GL_LINE_STRIP etc. */ |
---|
| 92 | void Draw( int mode ); |
---|
| 93 | void PrintProperties( void ); |
---|
| 94 | }; |
---|
| 95 | |
---|
| 96 | #endif |
---|