[692] | 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 | // Optional chunk that matches a texture name to an alias
|
---|
| 72 | // a texture alias is sent to the submesh material to use this texture name
|
---|
| 73 | // instead of the one in the texture unit with a matching alias name
|
---|
| 74 | M_SUBMESH_TEXTURE_ALIAS = 0x4200, // Repeating section
|
---|
| 75 | // char* aliasName;
|
---|
| 76 | // char* textureName;
|
---|
| 77 |
|
---|
| 78 | M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH
|
---|
| 79 | // unsigned int vertexCount
|
---|
| 80 | M_GEOMETRY_VERTEX_DECLARATION = 0x5100,
|
---|
| 81 | M_GEOMETRY_VERTEX_ELEMENT = 0x5110, // Repeating section
|
---|
| 82 | // unsigned short source; // buffer bind source
|
---|
| 83 | // unsigned short type; // VertexElementType
|
---|
| 84 | // unsigned short semantic; // VertexElementSemantic
|
---|
| 85 | // unsigned short offset; // start offset in buffer in bytes
|
---|
| 86 | // unsigned short index; // index of the semantic (for colours and texture coords)
|
---|
| 87 | M_GEOMETRY_VERTEX_BUFFER = 0x5200, // Repeating section
|
---|
| 88 | // unsigned short bindIndex; // Index to bind this buffer to
|
---|
| 89 | // unsigned short vertexSize; // Per-vertex size, must agree with declaration at this index
|
---|
| 90 | M_GEOMETRY_VERTEX_BUFFER_DATA = 0x5210,
|
---|
| 91 | // raw buffer data
|
---|
| 92 | M_MESH_SKELETON_LINK = 0x6000,
|
---|
| 93 | // Optional link to skeleton
|
---|
| 94 | // char* skeletonName : name of .skeleton to use
|
---|
| 95 | M_MESH_BONE_ASSIGNMENT = 0x7000,
|
---|
| 96 | // Optional bone weights (repeating section)
|
---|
| 97 | // unsigned int vertexIndex;
|
---|
| 98 | // unsigned short boneIndex;
|
---|
| 99 | // float weight;
|
---|
| 100 | M_MESH_LOD = 0x8000,
|
---|
| 101 | // Optional LOD information
|
---|
| 102 | // unsigned short numLevels;
|
---|
| 103 | // bool manual; (true for manual alternate meshes, false for generated)
|
---|
| 104 | M_MESH_LOD_USAGE = 0x8100,
|
---|
| 105 | // Repeating section, ordered in increasing depth
|
---|
| 106 | // NB LOD 0 (full detail from 0 depth) is omitted
|
---|
| 107 | // float fromSquaredDepth;
|
---|
| 108 | M_MESH_LOD_MANUAL = 0x8110,
|
---|
| 109 | // Required if M_MESH_LOD section manual = true
|
---|
| 110 | // String manualMeshName;
|
---|
| 111 | M_MESH_LOD_GENERATED = 0x8120,
|
---|
| 112 | // Required if M_MESH_LOD section manual = false
|
---|
| 113 | // Repeating section (1 per submesh)
|
---|
| 114 | // unsigned int indexCount;
|
---|
| 115 | // bool indexes32Bit
|
---|
| 116 | // unsigned short* faceIndexes; (indexCount)
|
---|
| 117 | // OR
|
---|
| 118 | // unsigned int* faceIndexes; (indexCount)
|
---|
| 119 | M_MESH_BOUNDS = 0x9000,
|
---|
| 120 | // float minx, miny, minz
|
---|
| 121 | // float maxx, maxy, maxz
|
---|
| 122 | // float radius
|
---|
| 123 |
|
---|
| 124 | // Added By DrEvil
|
---|
| 125 | // optional chunk that contains a table of submesh indexes and the names of
|
---|
| 126 | // the sub-meshes.
|
---|
| 127 | M_SUBMESH_NAME_TABLE = 0xA000,
|
---|
| 128 | // Subchunks of the name table. Each chunk contains an index & string
|
---|
| 129 | M_SUBMESH_NAME_TABLE_ELEMENT = 0xA100,
|
---|
| 130 | // short index
|
---|
| 131 | // char* name
|
---|
| 132 |
|
---|
| 133 | // Optional chunk which stores precomputed edge data
|
---|
| 134 | M_EDGE_LISTS = 0xB000,
|
---|
| 135 | // Each LOD has a separate edge list
|
---|
| 136 | M_EDGE_LIST_LOD = 0xB100,
|
---|
| 137 | // unsigned short lodIndex
|
---|
| 138 | // bool isManual // If manual, no edge data here, loaded from manual mesh
|
---|
| 139 | // unsigned long numTriangles
|
---|
| 140 | // unsigned long numEdgeGroups
|
---|
| 141 | // Triangle* triangleList
|
---|
| 142 | // unsigned long indexSet
|
---|
| 143 | // unsigned long vertexSet
|
---|
| 144 | // unsigned long vertIndex[3]
|
---|
| 145 | // unsigned long sharedVertIndex[3]
|
---|
| 146 | // float normal[4]
|
---|
| 147 |
|
---|
| 148 | M_EDGE_GROUP = 0xB110,
|
---|
| 149 | // unsigned long vertexSet
|
---|
| 150 | // unsigned long numEdges
|
---|
| 151 | // Edge* edgeList
|
---|
| 152 | // unsigned long triIndex[2]
|
---|
| 153 | // unsigned long vertIndex[2]
|
---|
| 154 | // unsigned long sharedVertIndex[2]
|
---|
| 155 | // bool degenerate
|
---|
| 156 |
|
---|
| 157 | // Optional poses section, referred to by pose keyframes
|
---|
| 158 | M_POSES = 0xC000,
|
---|
| 159 | M_POSE = 0xC100,
|
---|
| 160 | // char* name (may be blank)
|
---|
| 161 | // unsigned short target // 0 for shared geometry,
|
---|
| 162 | // 1+ for submesh index + 1
|
---|
| 163 | M_POSE_VERTEX = 0xC111,
|
---|
| 164 | // unsigned long vertexIndex
|
---|
| 165 | // float xoffset, yoffset, zoffset
|
---|
| 166 | // Optional vertex animation chunk
|
---|
| 167 | M_ANIMATIONS = 0xD000,
|
---|
| 168 | M_ANIMATION = 0xD100,
|
---|
| 169 | // char* name
|
---|
| 170 | // float length
|
---|
| 171 | M_ANIMATION_TRACK = 0xD110,
|
---|
| 172 | // unsigned short type // 1 == morph, 2 == pose
|
---|
| 173 | // unsigned short target // 0 for shared geometry,
|
---|
| 174 | // 1+ for submesh index + 1
|
---|
| 175 | M_ANIMATION_MORPH_KEYFRAME = 0xD111,
|
---|
| 176 | // float time
|
---|
| 177 | // float x,y,z // repeat by number of vertices in original geometry
|
---|
| 178 | M_ANIMATION_POSE_KEYFRAME = 0xD112,
|
---|
| 179 | // float time
|
---|
| 180 | M_ANIMATION_POSE_REF = 0xD113, // repeat for number of referenced poses
|
---|
| 181 | // unsigned short poseIndex
|
---|
| 182 | // float influence
|
---|
| 183 |
|
---|
| 184 |
|
---|
| 185 |
|
---|
| 186 | /* Version 1.2 of the .mesh fornmat (deprecated)
|
---|
| 187 | enum MeshChunkID {
|
---|
| 188 | M_HEADER = 0x1000,
|
---|
| 189 | // char* version : Version number check
|
---|
| 190 | M_MESH = 0x3000,
|
---|
| 191 | // bool skeletallyAnimated // important flag which affects h/w buffer policies
|
---|
| 192 | // Optional M_GEOMETRY chunk
|
---|
| 193 | M_SUBMESH = 0x4000,
|
---|
| 194 | // char* materialName
|
---|
| 195 | // bool useSharedVertices
|
---|
| 196 | // unsigned int indexCount
|
---|
| 197 | // bool indexes32Bit
|
---|
| 198 | // unsigned int* faceVertexIndices (indexCount)
|
---|
| 199 | // OR
|
---|
| 200 | // unsigned short* faceVertexIndices (indexCount)
|
---|
| 201 | // M_GEOMETRY chunk (Optional: present only if useSharedVertices = false)
|
---|
| 202 | M_SUBMESH_OPERATION = 0x4010, // optional, trilist assumed if missing
|
---|
| 203 | // unsigned short operationType
|
---|
| 204 | M_SUBMESH_BONE_ASSIGNMENT = 0x4100,
|
---|
| 205 | // Optional bone weights (repeating section)
|
---|
| 206 | // unsigned int vertexIndex;
|
---|
| 207 | // unsigned short boneIndex;
|
---|
| 208 | // float weight;
|
---|
| 209 | M_GEOMETRY = 0x5000, // NB this chunk is embedded within M_MESH and M_SUBMESH
|
---|
| 210 | */
|
---|
| 211 | // unsigned int vertexCount
|
---|
| 212 | // float* pVertices (x, y, z order x numVertices)
|
---|
| 213 | M_GEOMETRY_NORMALS = 0x5100, //(Optional)
|
---|
| 214 | // float* pNormals (x, y, z order x numVertices)
|
---|
| 215 | M_GEOMETRY_COLOURS = 0x5200, //(Optional)
|
---|
| 216 | // unsigned long* pColours (RGBA 8888 format x numVertices)
|
---|
| 217 | M_GEOMETRY_TEXCOORDS = 0x5300, //(Optional, REPEATABLE, each one adds an extra set)
|
---|
| 218 | // unsigned short dimensions (1 for 1D, 2 for 2D, 3 for 3D)
|
---|
| 219 | // float* pTexCoords (u [v] [w] order, dimensions x numVertices)
|
---|
| 220 | /*
|
---|
| 221 | M_MESH_SKELETON_LINK = 0x6000,
|
---|
| 222 | // Optional link to skeleton
|
---|
| 223 | // char* skeletonName : name of .skeleton to use
|
---|
| 224 | M_MESH_BONE_ASSIGNMENT = 0x7000,
|
---|
| 225 | // Optional bone weights (repeating section)
|
---|
| 226 | // unsigned int vertexIndex;
|
---|
| 227 | // unsigned short boneIndex;
|
---|
| 228 | // float weight;
|
---|
| 229 | M_MESH_LOD = 0x8000,
|
---|
| 230 | // Optional LOD information
|
---|
| 231 | // unsigned short numLevels;
|
---|
| 232 | // bool manual; (true for manual alternate meshes, false for generated)
|
---|
| 233 | M_MESH_LOD_USAGE = 0x8100,
|
---|
| 234 | // Repeating section, ordered in increasing depth
|
---|
| 235 | // NB LOD 0 (full detail from 0 depth) is omitted
|
---|
| 236 | // float fromSquaredDepth;
|
---|
| 237 | M_MESH_LOD_MANUAL = 0x8110,
|
---|
| 238 | // Required if M_MESH_LOD section manual = true
|
---|
| 239 | // String manualMeshName;
|
---|
| 240 | M_MESH_LOD_GENERATED = 0x8120,
|
---|
| 241 | // Required if M_MESH_LOD section manual = false
|
---|
| 242 | // Repeating section (1 per submesh)
|
---|
| 243 | // unsigned int indexCount;
|
---|
| 244 | // bool indexes32Bit
|
---|
| 245 | // unsigned short* faceIndexes; (indexCount)
|
---|
| 246 | // OR
|
---|
| 247 | // unsigned int* faceIndexes; (indexCount)
|
---|
| 248 | M_MESH_BOUNDS = 0x9000
|
---|
| 249 | // float minx, miny, minz
|
---|
| 250 | // float maxx, maxy, maxz
|
---|
| 251 | // float radius
|
---|
| 252 |
|
---|
| 253 | // Added By DrEvil
|
---|
| 254 | // optional chunk that contains a table of submesh indexes and the names of
|
---|
| 255 | // the sub-meshes.
|
---|
| 256 | M_SUBMESH_NAME_TABLE,
|
---|
| 257 | // Subchunks of the name table. Each chunk contains an index & string
|
---|
| 258 | M_SUBMESH_NAME_TABLE_ELEMENT,
|
---|
| 259 | // short index
|
---|
| 260 | // char* name
|
---|
| 261 |
|
---|
| 262 | */
|
---|
| 263 | };
|
---|
| 264 | } // namespace
|
---|
| 265 |
|
---|
| 266 |
|
---|
| 267 | #endif
|
---|