| 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-2006 Torus Knot Software Ltd |
|---|
| 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 | You may alternatively use this source under the terms of a specific version of |
|---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
|---|
| 26 | Torus Knot Software Ltd. |
|---|
| 27 | ----------------------------------------------------------------------------- |
|---|
| 28 | */ |
|---|
| 29 | #ifndef __MeshFileFormat_H__ |
|---|
| 30 | #define __MeshFileFormat_H__ |
|---|
| 31 | |
|---|
| 32 | #include "OgrePrerequisites.h" |
|---|
| 33 | |
|---|
| 34 | namespace Ogre { |
|---|
| 35 | |
|---|
| 36 | /** Definition of the OGRE .mesh file format |
|---|
| 37 | |
|---|
| 38 | .mesh files are binary files (for read efficiency at runtime) and are arranged into chunks |
|---|
| 39 | of data, very like 3D Studio's format. |
|---|
| 40 | A chunk always consists of: |
|---|
| 41 | unsigned short CHUNK_ID : one of the following chunk ids identifying the chunk |
|---|
| 42 | unsigned long LENGTH : length of the chunk in bytes, including this header |
|---|
| 43 | void* DATA : the data, which may contain other sub-chunks (various data types) |
|---|
| 44 | |
|---|
| 45 | A .mesh file can contain both the definition of the Mesh itself, and optionally the definitions |
|---|
| 46 | of the materials is uses (although these can be omitted, if so the Mesh assumes that at runtime the |
|---|
| 47 | Materials referred to by name in the Mesh are loaded/created from another source) |
|---|
| 48 | |
|---|
| 49 | A .mesh file only contains a single mesh, which can itself have multiple submeshes. |
|---|
| 50 | |
|---|
| 51 | */ |
|---|
| 52 | |
|---|
| 53 | enum MeshChunkID { |
|---|
| 54 | M_HEADER = 0x1000, |
|---|
| 55 | // char* version : Version number check |
|---|
| 56 | M_MESH = 0x3000, |
|---|
| 57 | // bool skeletallyAnimated // important flag which affects h/w buffer policies |
|---|
| 58 | // Optional M_GEOMETRY chunk |
|---|
| 59 | M_SUBMESH = 0x4000, |
|---|
| 60 | // char* materialName |
|---|
| 61 | // bool useSharedVertices |
|---|
| 62 | // unsigned int indexCount |
|---|
| 63 | // bool indexes32Bit |
|---|
| 64 | // unsigned int* faceVertexIndices (indexCount) |
|---|
| 65 | // OR |
|---|
| 66 | // unsigned short* faceVertexIndices (indexCount) |
|---|
| 67 | // M_GEOMETRY chunk (Optional: present only if useSharedVertices = false) |
|---|
| 68 | M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing |
|---|
| 69 | // unsigned short operationType |
|---|
| 70 | M_SUBMESH_BONE_ASSIGNMENT = 0x4100, |
|---|
| 71 | // Optional bone weights (repeating section) |
|---|
| 72 | // unsigned int vertexIndex; |
|---|
| 73 | // unsigned short boneIndex; |
|---|
| 74 | // float weight; |
|---|
| 75 | // Optional chunk that matches a texture name to an alias |
|---|
| 76 | // a texture alias is sent to the submesh material to use this texture name |
|---|
| 77 | // instead of the one in the texture unit with a matching alias name |
|---|
| 78 | M_SUBMESH_TEXTURE_ALIAS = 0x4200, // Repeating section |
|---|
| 79 | // char* aliasName; |
|---|
| 80 | // char* textureName; |
|---|
| 81 | |
|---|
| 82 | M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH |
|---|
| 83 | // unsigned int vertexCount |
|---|
| 84 | M_GEOMETRY_VERTEX_DECLARATION = 0x5100, |
|---|
| 85 | M_GEOMETRY_VERTEX_ELEMENT = 0x5110, // Repeating section |
|---|
| 86 | // unsigned short source; // buffer bind source |
|---|
| 87 | // unsigned short type; // VertexElementType |
|---|
| 88 | // unsigned short semantic; // VertexElementSemantic |
|---|
| 89 | // unsigned short offset; // start offset in buffer in bytes |
|---|
| 90 | // unsigned short index; // index of the semantic (for colours and texture coords) |
|---|
| 91 | M_GEOMETRY_VERTEX_BUFFER = 0x5200, // Repeating section |
|---|
| 92 | // unsigned short bindIndex; // Index to bind this buffer to |
|---|
| 93 | // unsigned short vertexSize; // Per-vertex size, must agree with declaration at this index |
|---|
| 94 | M_GEOMETRY_VERTEX_BUFFER_DATA = 0x5210, |
|---|
| 95 | // raw buffer data |
|---|
| 96 | M_MESH_SKELETON_LINK = 0x6000, |
|---|
| 97 | // Optional link to skeleton |
|---|
| 98 | // char* skeletonName : name of .skeleton to use |
|---|
| 99 | M_MESH_BONE_ASSIGNMENT = 0x7000, |
|---|
| 100 | // Optional bone weights (repeating section) |
|---|
| 101 | // unsigned int vertexIndex; |
|---|
| 102 | // unsigned short boneIndex; |
|---|
| 103 | // float weight; |
|---|
| 104 | M_MESH_LOD = 0x8000, |
|---|
| 105 | // Optional LOD information |
|---|
| 106 | // unsigned short numLevels; |
|---|
| 107 | // bool manual; (true for manual alternate meshes, false for generated) |
|---|
| 108 | M_MESH_LOD_USAGE = 0x8100, |
|---|
| 109 | // Repeating section, ordered in increasing depth |
|---|
| 110 | // NB LOD 0 (full detail from 0 depth) is omitted |
|---|
| 111 | // float fromSquaredDepth; |
|---|
| 112 | M_MESH_LOD_MANUAL = 0x8110, |
|---|
| 113 | // Required if M_MESH_LOD section manual = true |
|---|
| 114 | // String manualMeshName; |
|---|
| 115 | M_MESH_LOD_GENERATED = 0x8120, |
|---|
| 116 | // Required if M_MESH_LOD section manual = false |
|---|
| 117 | // Repeating section (1 per submesh) |
|---|
| 118 | // unsigned int indexCount; |
|---|
| 119 | // bool indexes32Bit |
|---|
| 120 | // unsigned short* faceIndexes; (indexCount) |
|---|
| 121 | // OR |
|---|
| 122 | // unsigned int* faceIndexes; (indexCount) |
|---|
| 123 | M_MESH_BOUNDS = 0x9000, |
|---|
| 124 | // float minx, miny, minz |
|---|
| 125 | // float maxx, maxy, maxz |
|---|
| 126 | // float radius |
|---|
| 127 | |
|---|
| 128 | // Added By DrEvil |
|---|
| 129 | // optional chunk that contains a table of submesh indexes and the names of |
|---|
| 130 | // the sub-meshes. |
|---|
| 131 | M_SUBMESH_NAME_TABLE = 0xA000, |
|---|
| 132 | // Subchunks of the name table. Each chunk contains an index & string |
|---|
| 133 | M_SUBMESH_NAME_TABLE_ELEMENT = 0xA100, |
|---|
| 134 | // short index |
|---|
| 135 | // char* name |
|---|
| 136 | |
|---|
| 137 | // Optional chunk which stores precomputed edge data |
|---|
| 138 | M_EDGE_LISTS = 0xB000, |
|---|
| 139 | // Each LOD has a separate edge list |
|---|
| 140 | M_EDGE_LIST_LOD = 0xB100, |
|---|
| 141 | // unsigned short lodIndex |
|---|
| 142 | // bool isManual // If manual, no edge data here, loaded from manual mesh |
|---|
| 143 | // bool isClosed |
|---|
| 144 | // unsigned long numTriangles |
|---|
| 145 | // unsigned long numEdgeGroups |
|---|
| 146 | // Triangle* triangleList |
|---|
| 147 | // unsigned long indexSet |
|---|
| 148 | // unsigned long vertexSet |
|---|
| 149 | // unsigned long vertIndex[3] |
|---|
| 150 | // unsigned long sharedVertIndex[3] |
|---|
| 151 | // float normal[4] |
|---|
| 152 | |
|---|
| 153 | M_EDGE_GROUP = 0xB110, |
|---|
| 154 | // unsigned long vertexSet |
|---|
| 155 | // unsigned long triStart |
|---|
| 156 | // unsigned long triCount |
|---|
| 157 | // unsigned long numEdges |
|---|
| 158 | // Edge* edgeList |
|---|
| 159 | // unsigned long triIndex[2] |
|---|
| 160 | // unsigned long vertIndex[2] |
|---|
| 161 | // unsigned long sharedVertIndex[2] |
|---|
| 162 | // bool degenerate |
|---|
| 163 | |
|---|
| 164 | // Optional poses section, referred to by pose keyframes |
|---|
| 165 | M_POSES = 0xC000, |
|---|
| 166 | M_POSE = 0xC100, |
|---|
| 167 | // char* name (may be blank) |
|---|
| 168 | // unsigned short target // 0 for shared geometry, |
|---|
| 169 | // 1+ for submesh index + 1 |
|---|
| 170 | M_POSE_VERTEX = 0xC111, |
|---|
| 171 | // unsigned long vertexIndex |
|---|
| 172 | // float xoffset, yoffset, zoffset |
|---|
| 173 | // Optional vertex animation chunk |
|---|
| 174 | M_ANIMATIONS = 0xD000, |
|---|
| 175 | M_ANIMATION = 0xD100, |
|---|
| 176 | // char* name |
|---|
| 177 | // float length |
|---|
| 178 | M_ANIMATION_TRACK = 0xD110, |
|---|
| 179 | // unsigned short type // 1 == morph, 2 == pose |
|---|
| 180 | // unsigned short target // 0 for shared geometry, |
|---|
| 181 | // 1+ for submesh index + 1 |
|---|
| 182 | M_ANIMATION_MORPH_KEYFRAME = 0xD111, |
|---|
| 183 | // float time |
|---|
| 184 | // float x,y,z // repeat by number of vertices in original geometry |
|---|
| 185 | M_ANIMATION_POSE_KEYFRAME = 0xD112, |
|---|
| 186 | // float time |
|---|
| 187 | M_ANIMATION_POSE_REF = 0xD113, // repeat for number of referenced poses |
|---|
| 188 | // unsigned short poseIndex |
|---|
| 189 | // float influence |
|---|
| 190 | |
|---|
| 191 | // Optional submesh extreme vertex list chink |
|---|
| 192 | M_TABLE_EXTREMES = 0xE000, |
|---|
| 193 | // unsigned short submesh_index; |
|---|
| 194 | // float extremes [n_extremes][3]; |
|---|
| 195 | |
|---|
| 196 | /* Version 1.2 of the .mesh fornmat (deprecated) |
|---|
| 197 | enum MeshChunkID { |
|---|
| 198 | M_HEADER = 0x1000, |
|---|
| 199 | // char* version : Version number check |
|---|
| 200 | M_MESH = 0x3000, |
|---|
| 201 | // bool skeletallyAnimated // important flag which affects h/w buffer policies |
|---|
| 202 | // Optional M_GEOMETRY chunk |
|---|
| 203 | M_SUBMESH = 0x4000, |
|---|
| 204 | // char* materialName |
|---|
| 205 | // bool useSharedVertices |
|---|
| 206 | // unsigned int indexCount |
|---|
| 207 | // bool indexes32Bit |
|---|
| 208 | // unsigned int* faceVertexIndices (indexCount) |
|---|
| 209 | // OR |
|---|
| 210 | // unsigned short* faceVertexIndices (indexCount) |
|---|
| 211 | // M_GEOMETRY chunk (Optional: present only if useSharedVertices = false) |
|---|
| 212 | M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing |
|---|
| 213 | // unsigned short operationType |
|---|
| 214 | M_SUBMESH_BONE_ASSIGNMENT = 0x4100, |
|---|
| 215 | // Optional bone weights (repeating section) |
|---|
| 216 | // unsigned int vertexIndex; |
|---|
| 217 | // unsigned short boneIndex; |
|---|
| 218 | // float weight; |
|---|
| 219 | M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH |
|---|
| 220 | */ |
|---|
| 221 | // unsigned int vertexCount |
|---|
| 222 | // float* pVertices (x, y, z order x numVertices) |
|---|
| 223 | M_GEOMETRY_NORMALS = 0x5100, //(Optional) |
|---|
| 224 | // float* pNormals (x, y, z order x numVertices) |
|---|
| 225 | M_GEOMETRY_COLOURS = 0x5200, //(Optional) |
|---|
| 226 | // unsigned long* pColours (RGBA 8888 format x numVertices) |
|---|
| 227 | M_GEOMETRY_TEXCOORDS = 0x5300, //(Optional, REPEATABLE, each one adds an extra set) |
|---|
| 228 | // unsigned short dimensions (1 for 1D, 2 for 2D, 3 for 3D) |
|---|
| 229 | // float* pTexCoords (u [v] [w] order, dimensions x numVertices) |
|---|
| 230 | /* |
|---|
| 231 | M_MESH_SKELETON_LINK = 0x6000, |
|---|
| 232 | // Optional link to skeleton |
|---|
| 233 | // char* skeletonName : name of .skeleton to use |
|---|
| 234 | M_MESH_BONE_ASSIGNMENT = 0x7000, |
|---|
| 235 | // Optional bone weights (repeating section) |
|---|
| 236 | // unsigned int vertexIndex; |
|---|
| 237 | // unsigned short boneIndex; |
|---|
| 238 | // float weight; |
|---|
| 239 | M_MESH_LOD = 0x8000, |
|---|
| 240 | // Optional LOD information |
|---|
| 241 | // unsigned short numLevels; |
|---|
| 242 | // bool manual; (true for manual alternate meshes, false for generated) |
|---|
| 243 | M_MESH_LOD_USAGE = 0x8100, |
|---|
| 244 | // Repeating section, ordered in increasing depth |
|---|
| 245 | // NB LOD 0 (full detail from 0 depth) is omitted |
|---|
| 246 | // float fromSquaredDepth; |
|---|
| 247 | M_MESH_LOD_MANUAL = 0x8110, |
|---|
| 248 | // Required if M_MESH_LOD section manual = true |
|---|
| 249 | // String manualMeshName; |
|---|
| 250 | M_MESH_LOD_GENERATED = 0x8120, |
|---|
| 251 | // Required if M_MESH_LOD section manual = false |
|---|
| 252 | // Repeating section (1 per submesh) |
|---|
| 253 | // unsigned int indexCount; |
|---|
| 254 | // bool indexes32Bit |
|---|
| 255 | // unsigned short* faceIndexes; (indexCount) |
|---|
| 256 | // OR |
|---|
| 257 | // unsigned int* faceIndexes; (indexCount) |
|---|
| 258 | M_MESH_BOUNDS = 0x9000 |
|---|
| 259 | // float minx, miny, minz |
|---|
| 260 | // float maxx, maxy, maxz |
|---|
| 261 | // float radius |
|---|
| 262 | |
|---|
| 263 | // Added By DrEvil |
|---|
| 264 | // optional chunk that contains a table of submesh indexes and the names of |
|---|
| 265 | // the sub-meshes. |
|---|
| 266 | M_SUBMESH_NAME_TABLE, |
|---|
| 267 | // Subchunks of the name table. Each chunk contains an index & string |
|---|
| 268 | M_SUBMESH_NAME_TABLE_ELEMENT, |
|---|
| 269 | // short index |
|---|
| 270 | // char* name |
|---|
| 271 | |
|---|
| 272 | */ |
|---|
| 273 | }; |
|---|
| 274 | } // namespace |
|---|
| 275 | |
|---|
| 276 | |
|---|
| 277 | #endif |
|---|