1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __MeshFileFormat_H__
|
---|
26 | #define __MeshFileFormat_H__
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 |
|
---|
30 | namespace Ogre {
|
---|
31 |
|
---|
32 | /** Definition of the OGRE .mesh file format
|
---|
33 |
|
---|
34 | .mesh files are binary files (for read efficiency at runtime) and are arranged into chunks
|
---|
35 | of data, very like 3D Studio's format.
|
---|
36 | A chunk always consists of:
|
---|
37 | unsigned short CHUNK_ID : one of the following chunk ids identifying the chunk
|
---|
38 | unsigned long LENGTH : length of the chunk in bytes, including this header
|
---|
39 | void* DATA : the data, which may contain other sub-chunks (various data types)
|
---|
40 |
|
---|
41 | A .mesh file can contain both the definition of the Mesh itself, and optionally the definitions
|
---|
42 | of the materials is uses (although these can be omitted, if so the Mesh assumes that at runtime the
|
---|
43 | Materials referred to by name in the Mesh are loaded/created from another source)
|
---|
44 |
|
---|
45 | A .mesh file only contains a single mesh, which can itself have multiple submeshes.
|
---|
46 |
|
---|
47 | */
|
---|
48 |
|
---|
49 | enum MeshChunkID {
|
---|
50 | M_HEADER = 0x1000,
|
---|
51 | // char* version : Version number check
|
---|
52 | M_MESH = 0x3000,
|
---|
53 | // bool skeletallyAnimated // important flag which affects h/w buffer policies
|
---|
54 | // Optional M_GEOMETRY chunk
|
---|
55 | M_SUBMESH = 0x4000,
|
---|
56 | // char* materialName
|
---|
57 | // bool useSharedVertices
|
---|
58 | // unsigned int indexCount
|
---|
59 | // bool indexes32Bit
|
---|
60 | // unsigned int* faceVertexIndices (indexCount)
|
---|
61 | // OR
|
---|
62 | // unsigned short* faceVertexIndices (indexCount)
|
---|
63 | // M_GEOMETRY chunk (Optional: present only if useSharedVertices = false)
|
---|
64 | M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing
|
---|
65 | // unsigned short operationType
|
---|
66 | M_SUBMESH_BONE_ASSIGNMENT = 0x4100,
|
---|
67 | // Optional bone weights (repeating section)
|
---|
68 | // unsigned int vertexIndex;
|
---|
69 | // unsigned short boneIndex;
|
---|
70 | // float weight;
|
---|
71 | M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH
|
---|
72 | // unsigned int vertexCount
|
---|
73 | M_GEOMETRY_VERTEX_DECLARATION = 0x5100,
|
---|
74 | M_GEOMETRY_VERTEX_ELEMENT = 0x5110, // Repeating section
|
---|
75 | // unsigned short source; // buffer bind source
|
---|
76 | // unsigned short type; // VertexElementType
|
---|
77 | // unsigned short semantic; // VertexElementSemantic
|
---|
78 | // unsigned short offset; // start offset in buffer in bytes
|
---|
79 | // unsigned short index; // index of the semantic (for colours and texture coords)
|
---|
80 | M_GEOMETRY_VERTEX_BUFFER = 0x5200, // Repeating section
|
---|
81 | // unsigned short bindIndex; // Index to bind this buffer to
|
---|
82 | // unsigned short vertexSize; // Per-vertex size, must agree with declaration at this index
|
---|
83 | M_GEOMETRY_VERTEX_BUFFER_DATA = 0x5210,
|
---|
84 | // raw buffer data
|
---|
85 | M_MESH_SKELETON_LINK = 0x6000,
|
---|
86 | // Optional link to skeleton
|
---|
87 | // char* skeletonName : name of .skeleton to use
|
---|
88 | M_MESH_BONE_ASSIGNMENT = 0x7000,
|
---|
89 | // Optional bone weights (repeating section)
|
---|
90 | // unsigned int vertexIndex;
|
---|
91 | // unsigned short boneIndex;
|
---|
92 | // float weight;
|
---|
93 | M_MESH_LOD = 0x8000,
|
---|
94 | // Optional LOD information
|
---|
95 | // unsigned short numLevels;
|
---|
96 | // bool manual; (true for manual alternate meshes, false for generated)
|
---|
97 | M_MESH_LOD_USAGE = 0x8100,
|
---|
98 | // Repeating section, ordered in increasing depth
|
---|
99 | // NB LOD 0 (full detail from 0 depth) is omitted
|
---|
100 | // float fromSquaredDepth;
|
---|
101 | M_MESH_LOD_MANUAL = 0x8110,
|
---|
102 | // Required if M_MESH_LOD section manual = true
|
---|
103 | // String manualMeshName;
|
---|
104 | M_MESH_LOD_GENERATED = 0x8120,
|
---|
105 | // Required if M_MESH_LOD section manual = false
|
---|
106 | // Repeating section (1 per submesh)
|
---|
107 | // unsigned int indexCount;
|
---|
108 | // bool indexes32Bit
|
---|
109 | // unsigned short* faceIndexes; (indexCount)
|
---|
110 | // OR
|
---|
111 | // unsigned int* faceIndexes; (indexCount)
|
---|
112 | M_MESH_BOUNDS = 0x9000,
|
---|
113 | // float minx, miny, minz
|
---|
114 | // float maxx, maxy, maxz
|
---|
115 | // float radius
|
---|
116 |
|
---|
117 | // Added By DrEvil
|
---|
118 | // optional chunk that contains a table of submesh indexes and the names of
|
---|
119 | // the sub-meshes.
|
---|
120 | M_SUBMESH_NAME_TABLE = 0xA000,
|
---|
121 | // Subchunks of the name table. Each chunk contains an index & string
|
---|
122 | M_SUBMESH_NAME_TABLE_ELEMENT = 0xA100,
|
---|
123 | // short index
|
---|
124 | // char* name
|
---|
125 |
|
---|
126 | // Optional chunk which stores precomputed edge data
|
---|
127 | M_EDGE_LISTS = 0xB000,
|
---|
128 | // Each LOD has a separate edge list
|
---|
129 | M_EDGE_LIST_LOD = 0xB100,
|
---|
130 | // unsigned short lodIndex
|
---|
131 | // bool isManual // If manual, no edge data here, loaded from manual mesh
|
---|
132 | // unsigned long numTriangles
|
---|
133 | // unsigned long numEdgeGroups
|
---|
134 | // Triangle* triangleList
|
---|
135 | // unsigned long indexSet
|
---|
136 | // unsigned long vertexSet
|
---|
137 | // unsigned long vertIndex[3]
|
---|
138 | // unsigned long sharedVertIndex[3]
|
---|
139 | // float normal[4]
|
---|
140 |
|
---|
141 | M_EDGE_GROUP = 0xB110,
|
---|
142 | // unsigned long vertexSet
|
---|
143 | // unsigned long numEdges
|
---|
144 | // Edge* edgeList
|
---|
145 | // unsigned long triIndex[2]
|
---|
146 | // unsigned long vertIndex[2]
|
---|
147 | // unsigned long sharedVertIndex[2]
|
---|
148 | // bool degenerate
|
---|
149 |
|
---|
150 |
|
---|
151 | /* Version 1.2 of the .mesh fornmat (deprecated)
|
---|
152 | enum MeshChunkID {
|
---|
153 | M_HEADER = 0x1000,
|
---|
154 | // char* version : Version number check
|
---|
155 | M_MESH = 0x3000,
|
---|
156 | // bool skeletallyAnimated // important flag which affects h/w buffer policies
|
---|
157 | // Optional M_GEOMETRY chunk
|
---|
158 | M_SUBMESH = 0x4000,
|
---|
159 | // char* materialName
|
---|
160 | // bool useSharedVertices
|
---|
161 | // unsigned int indexCount
|
---|
162 | // bool indexes32Bit
|
---|
163 | // unsigned int* faceVertexIndices (indexCount)
|
---|
164 | // OR
|
---|
165 | // unsigned short* faceVertexIndices (indexCount)
|
---|
166 | // M_GEOMETRY chunk (Optional: present only if useSharedVertices = false)
|
---|
167 | M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing
|
---|
168 | // unsigned short operationType
|
---|
169 | M_SUBMESH_BONE_ASSIGNMENT = 0x4100,
|
---|
170 | // Optional bone weights (repeating section)
|
---|
171 | // unsigned int vertexIndex;
|
---|
172 | // unsigned short boneIndex;
|
---|
173 | // float weight;
|
---|
174 | M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH
|
---|
175 | */
|
---|
176 | // unsigned int vertexCount
|
---|
177 | // float* pVertices (x, y, z order x numVertices)
|
---|
178 | M_GEOMETRY_NORMALS = 0x5100, //(Optional)
|
---|
179 | // float* pNormals (x, y, z order x numVertices)
|
---|
180 | M_GEOMETRY_COLOURS = 0x5200, //(Optional)
|
---|
181 | // unsigned long* pColours (RGBA 8888 format x numVertices)
|
---|
182 | M_GEOMETRY_TEXCOORDS = 0x5300, //(Optional, REPEATABLE, each one adds an extra set)
|
---|
183 | // unsigned short dimensions (1 for 1D, 2 for 2D, 3 for 3D)
|
---|
184 | // float* pTexCoords (u [v] [w] order, dimensions x numVertices)
|
---|
185 | /*
|
---|
186 | M_MESH_SKELETON_LINK = 0x6000,
|
---|
187 | // Optional link to skeleton
|
---|
188 | // char* skeletonName : name of .skeleton to use
|
---|
189 | M_MESH_BONE_ASSIGNMENT = 0x7000,
|
---|
190 | // Optional bone weights (repeating section)
|
---|
191 | // unsigned int vertexIndex;
|
---|
192 | // unsigned short boneIndex;
|
---|
193 | // float weight;
|
---|
194 | M_MESH_LOD = 0x8000,
|
---|
195 | // Optional LOD information
|
---|
196 | // unsigned short numLevels;
|
---|
197 | // bool manual; (true for manual alternate meshes, false for generated)
|
---|
198 | M_MESH_LOD_USAGE = 0x8100,
|
---|
199 | // Repeating section, ordered in increasing depth
|
---|
200 | // NB LOD 0 (full detail from 0 depth) is omitted
|
---|
201 | // float fromSquaredDepth;
|
---|
202 | M_MESH_LOD_MANUAL = 0x8110,
|
---|
203 | // Required if M_MESH_LOD section manual = true
|
---|
204 | // String manualMeshName;
|
---|
205 | M_MESH_LOD_GENERATED = 0x8120,
|
---|
206 | // Required if M_MESH_LOD section manual = false
|
---|
207 | // Repeating section (1 per submesh)
|
---|
208 | // unsigned int indexCount;
|
---|
209 | // bool indexes32Bit
|
---|
210 | // unsigned short* faceIndexes; (indexCount)
|
---|
211 | // OR
|
---|
212 | // unsigned int* faceIndexes; (indexCount)
|
---|
213 | M_MESH_BOUNDS = 0x9000
|
---|
214 | // float minx, miny, minz
|
---|
215 | // float maxx, maxy, maxz
|
---|
216 | // float radius
|
---|
217 |
|
---|
218 | // Added By DrEvil
|
---|
219 | // optional chunk that contains a table of submesh indexes and the names of
|
---|
220 | // the sub-meshes.
|
---|
221 | M_SUBMESH_NAME_TABLE,
|
---|
222 | // Subchunks of the name table. Each chunk contains an index & string
|
---|
223 | M_SUBMESH_NAME_TABLE_ELEMENT,
|
---|
224 | // short index
|
---|
225 | // char* name
|
---|
226 | */
|
---|
227 | };
|
---|
228 | } // namespace
|
---|
229 |
|
---|
230 |
|
---|
231 | #endif
|
---|