libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Amigas 'defines' Grupos Páginas
mo3ds.h
Ir a la documentación de este archivo.
1 #ifndef _3DS_H
2 #define _3DS_H
3 
4 #include "mo3dModelManager.h"
5 
6 //>------ Primary Chunk, at the beginning of each file
7 #define PRIMARY 0x4D4D
8 
9 //>------ Main Chunks
10 #define OBJECTINFO 0x3D3D // This gives the version of the mesh and is found right before the material and object information
11 #define VERSION 0x0002 // This gives the version of the .3ds file
12 #define EDITKEYFRAME 0xB000 // This is the header for all of the key frame info
13 
14 //>------ sub defines of OBJECTINFO
15 #define MATERIAL 0xAFFF // This stored the texture info
16 #define OBJECT 0x4000 // This stores the faces, vertices, etc...
17 
18 //>------ sub defines of MATERIAL
19 #define MATNAME 0xA000 // This holds the material name
20 #define MATDIFFUSE 0xA020
21 
22  // This holds the ambient component color
23 #define MAT_AMBIENT_COLOR 0xA010
24  // This holds the color of the object/material
25 #define MAT_DIFFUSE_COLOR 0xA020
26  // This holds the specular component color
27 #define MAT_SPECULAR_COLOR 0xA030
28 #define MAT_SHININESS 0xA040
29 #define MAT_SHININESS_STRENGTH 0xA041
30 #define MAT_TRANSPARENCY 0xA050
31 #define MAT_TRANSPARENCY_FALLOFF 0xA052
32 #define MAT_TWO_SIDED 0xA081
33 #define MAT_WIRE_FRAME_ON 0xA085
34 
35 /*
36  0xA200 : Texture map 1
37  0xA33A : Texture map 2
38  0xA210 : Opacity map
39  0xA230 : Bump map
40  0xA33C : Shininess map
41  0xA204 : Specular map
42  0xA33D : Self illum. map
43  0xA220 : Reflection map
44  0xA33E : Mask for texture map 1
45  0xA340 : Mask for texture map 2
46  0xA342 : Mask for opacity map
47  0xA344 : Mask for bump map
48  0xA346 : Mask for shininess map
49  0xA348 : Mask for specular map
50  0xA34A : Mask for self illum. map
51  0xA34C : Mask for reflection map
52 */
53  // This holds the file name of the texture
54 #define MAT_TEXTURE_MAP1_CHUNK 0xA200
55 #define MAT_TEXTURE_MAP2_CHUNK 0xA33A
56 #define MAT_OPACITY_MAP_CHUNK 0xA210
57 #define MAT_BUMP_MAP_CHUNK 0xA230
58 #define MAT_SHININESS_MAP_CHUNK 0xA33C
59 #define MAT_SPECULAR_MAP_CHUNK 0xA204
60 #define MAT_SELF_ILLUM_MAP_CHUNK 0xA33D
61 #define MAT_REFLECTION_MAP_CHUNK 0xA220
62 
63 #define MAP_FILENAME 0xA300
64 #define MAP_V_SCALE 0xA354
65 #define MAP_U_SCALE 0xA356
66 #define MAP_U_OFFSET 0xA358
67 #define MAP_V_OFFSET 0xA35A
68 #define MAP_ROTATION 0xA35C
69 
70 /*
71  0xA360 : RGB Luma/Alpha tint 1
72  0xA362 : RGB Luma/Alpha tint 2
73  0xA364 : RGB tint R
74  0xA366 : RGB tint G
75  0xA368 : RGB tint B
76 */
77 
78 #define OBJECT_MESH 0x4100 // This lets us know that we are reading a new object
79 
80 //>------ sub defines of OBJECT_MESH
81  // The objects vertices
82 #define OBJECT_VERTICES 0x4110
83  // The objects faces
84 #define OBJECT_FACES 0x4120
85  // This is found if the object has a material, either texture map or color
86 #define OBJECT_MATERIAL 0x4130
87  // The UV texture coordinates
88 #define OBJECT_UV 0x4140
89 
90 // Here is our structure for our 3DS indicies(since .3DS stores 4 unsigned shorts)
91 struct tIndices
92 {
93  // This will hold point1, 2, and 3 index's into the vertex array plus a visible flag
94  unsigned short a, b, c, bVisible;
95 };
96 
97 // This holds the chunk info
98 struct tChunk
99 {
100  unsigned short int ID; // The chunk's ID
101  unsigned int length; // The length of the chunk
102  unsigned int bytesRead; // The amount of bytes read within that chunk
103 };
104 
105 // This class handles all of the loading code
107 {
108  public:
109 
110  CLoad3DS (); // This inits the data members
111 
112  // This is the function that you call to load the 3DS
113  bool Import3DS (mo3DSModel * pModel, char *strFileName);
114 
115  private:
116 
117  CVector3 Vector(CVector3 vPoint1, CVector3 vPoint2);
118 
119  // This adds 2 vectors together and returns the result
120  CVector3 AddVector(CVector3 vVector1, CVector3 vVector2);
121 
122  // This divides a vector by a single number(scalar) and returns the result
123  CVector3 DivideVectorByScaler(CVector3 vVector1, float Scaler);
124 
125  // This returns the cross product between 2 vectors
126  CVector3 Cross(CVector3 vVector1, CVector3 vVector2);
127 
128  // This returns the normal of a vector
129  CVector3 Normalize(CVector3 vNormal);
130 
131  // This reads in a string and saves it in the char array passed in
132  int GetString (char *);
133 
134  // This reads the next chunk
135  void ReadChunk (tChunk *);
136 
137  // This reads the next large chunk
138  void ProcessNextChunk (mo3DSModel * pModel, tChunk *);
139 
140  // This reads the object chunks
141  void ProcessNextObjectChunk (mo3DSModel * pModel, mo3DSObject * pObject,
142  tChunk *);
143 
144  // This reads the material chunks
145  void ProcessNextMaterialChunk (mo3DSModel * pModel, tChunk *);
146 
147  // This reads the RGB value for the object's color
148  void ReadColorChunk (mo3DSMaterialInfo * pMaterial, tChunk * pChunk, int color);
149 
150  // This reads the objects vertices
151  void ReadVertices (mo3DSObject * pObject, tChunk *);
152 
153  // This reads the objects face information
154  void ReadVertexIndices (mo3DSObject * pObject, tChunk *);
155 
156  // This reads the texture coodinates of the object
157  void ReadUVCoordinates (mo3DSObject * pObject, tChunk *);
158 
159  // This reads in the material name assigned to the object and sets the materialID
160  void ReadObjectMaterial (mo3DSModel * pModel, mo3DSObject * pObject,
161  tChunk * pPreviousChunk);
162 
163  // This computes the vertex normals for the object(used for lighting)
164  void ComputeNormals (mo3DSModel * pModel);
165 
166  // This frees memory and closes the file
167  void CleanUp ();
168 
169  // The file pointer
170  FILE * m_FilePointer;
171 
172  // These are used through the loading process to hold the chunk information
173  tChunk * m_CurrentChunk;
174  tChunk * m_TempChunk;
175 };
176 #endif /* */
177 
179 //
180 // * QUICK NOTES *
181 //
182 // This file is created in the hopes that you can just plug it into your code
183 // easily. You will probably want to query more chunks though for animation, etc..
184 //
185 //
186 // Ben Humphrey(DigiBen)
187 // Game Programmer
188 // DigiBen@GameTutorials.com
189 // Co-Web Host of www.GameTutorials.com
190 //
191 //
192 
unsigned short c
Definition: mo3ds.h:94
unsigned short bVisible
Definition: mo3ds.h:94
unsigned int length
Definition: mo3ds.h:101
#define LIBMOLDEO_API
Definition: moTypes.h:180
Definition: mo3ds.h:98
Definition: mo3ds.h:91
unsigned short b
Definition: mo3ds.h:94
unsigned short int ID
Definition: mo3ds.h:100
unsigned int bytesRead
Definition: mo3ds.h:102
unsigned short a
Definition: mo3ds.h:94