1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2010 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGOGREMESHREADER_H_
40 #define _OSGOGREMESHREADER_H_
45 /*! \file OSGOgreMeshReader.h
49 #include "OSGConfig.h"
50 #include "OSGFileIODef.h"
51 #include "OSGOgreChunkReader.h"
52 #include "OSGOgreOptions.h"
53 #include "OSGGeometry.h"
54 #include "OSGGeoIntegralProperty.h"
55 #include "OSGGeoVectorProperty.h"
56 #include "OSGSkeleton.h"
60 class OSG_FILEIO_DLLMAPPING OgreMeshReader
: public OgreChunkReader
62 /*========================== PUBLIC =================================*/
64 /*---------------------------------------------------------------------*/
68 typedef OgreChunkReader Inherited
;
71 /*---------------------------------------------------------------------*/
72 /*! \name Constructors/Destructor */
75 explicit OgreMeshReader( std::istream
&is
,
76 const OgreOptions
&options
);
77 virtual ~OgreMeshReader(void );
80 /*---------------------------------------------------------------------*/
89 /*========================= PROTECTED ===============================*/
93 CHUNK_HEADER
= 0x1000,
96 CHUNK_SUBMESH
= 0x4000,
97 CHUNK_SUBMESH_OPERATION
= 0x4010,
98 CHUNK_SUBMESH_BONE_ASSIGNMENT
= 0x4100,
99 CHUNK_SUBMESH_TEXTURE_ALIAS
= 0x4200,
101 CHUNK_GEOMETRY
= 0x5000,
102 CHUNK_GEOMETRY_VERTEX_DECLARATION
= 0x5100,
103 CHUNK_GEOMETRY_VERTEX_ELEMENT
= 0x5110,
104 CHUNK_GEOMETRY_VERTEX_BUFFER
= 0x5200,
105 CHUNK_GEOMETRY_VERTEX_BUFFER_DATA
= 0x5210,
107 CHUNK_MESH_SKELETON_LINK
= 0x6000,
108 CHUNK_MESH_BONE_ASSIGNMENT
= 0x7000,
109 CHUNK_MESH_LOD
= 0x8000,
110 CHUNK_MESH_LOD_USAGE
= 0x8100,
111 CHUNK_MESH_LOD_MANUAL
= 0x8110,
112 CHUNK_MESH_LOD_GENERATED
= 0x8120,
113 CHUNK_MESH_BOUNDS
= 0x9000,
115 CHUNK_SUBMESH_NAME_TABLE
= 0xA000,
116 CHUNK_SUBMESH_NAME_TABLE_ELEMENT
= 0xA100,
118 CHUNK_EDGE_LISTS
= 0xB000,
119 CHUNK_EDGE_LIST_LOD
= 0xB100,
120 CHUNK_EDGE_GROUP
= 0xB110,
122 CHUNK_POSES
= 0xC000,
124 CHUNK_POSE_VERTEX
= 0xC111,
126 CHUNK_ANIMATIONS
= 0xD000,
127 CHUNK_ANIMATION
= 0xD100,
128 CHUNK_ANIMATION_TRACK
= 0xD110,
129 CHUNK_ANIMATION_MORPH_KEYFRAME
= 0xD111,
130 CHUNK_ANIMATION_POSE_KEYFRAME
= 0xD112,
131 CHUNK_ANIMAITON_POSE_REF
= 0xD113,
133 CHUNK_TABLE_EXTREMES
= 0xE000,
136 enum VertexElementType
148 VET_COLOUR_ARGB
= 10,
152 enum VertexElementSemantic
155 VES_BLEND_WEIGHTS
= 2,
156 VES_BLEND_INDICES
= 3,
160 VES_TEXTURE_COORDINATES
= 7,
165 enum SubMeshOperation
170 SMO_TRIANGLE_LIST
= 4,
171 SMO_TRIANGLE_STRIP
= 5,
178 VertexElementType type
;
179 VertexElementSemantic semantic
;
183 GeoVectorPropertyUnrecPtr prop
;
185 VertexElement(void) :
188 semantic (VES_POSITION
),
196 typedef std::vector
<VertexElement
> VertexElementStore
;
197 typedef std::vector
<std::vector
<UInt32
> > BufferVertexMap
;
203 VertexElementStore vertexElements
;
204 SubMeshOperation meshOp
;
208 GeoIntegralPropertyUnrecPtr propIdx
;
210 GeometryUnrecPtr mesh
;
214 sharedVertex (false ),
217 meshOp (SMO_TRIANGLE_LIST
),
228 typedef std::vector
<SubMeshInfo
> SubMeshStore
;
230 typedef std::map
<std::string
, MaterialUnrecPtr
> MaterialMap
;
232 std::string
getVertexElementTypeString (VertexElementType veType
);
233 std::string
getVertexElementSemanticString(VertexElementSemantic veSemantic
);
234 std::string
getSubMeshOperationString (SubMeshOperation meshOp
);
237 void readMesh (void);
238 void readSubMesh (SubMeshStore
&subMeshInfo
,
239 VertexElementStore
&sharedVertexElements
,
242 void readSubMeshOperation (SubMeshInfo
&smInfo
);
243 void readSubMeshBoneAssignment (SubMeshInfo
&smInfo
,
245 Int16
&boneWeightVE
);
246 void readSubMeshTextureAlias (void);
247 void readGeometry (VertexElementStore
&vertexElements
);
248 void readGeometryVertexDeclaration(VertexElementStore
&vertexElements
,
249 BufferVertexMap
&bufferMap
);
250 void readGeometryVertexElement (VertexElementStore
&vertexElements
,
251 BufferVertexMap
&bufferMap
);
252 void readGeometryVertexBuffer (UInt32 vertCount
,
253 VertexElementStore
&vertexElements
,
254 BufferVertexMap
&bufferMap
);
255 void readGeometryVertexBufferData (UInt32 vertCount
,
257 VertexElementStore
&vertexElements
,
258 BufferVertexMap
&bufferMap
);
260 void readMeshSkeletonLink (SubMeshStore
&subMeshInfo
);
261 void readMeshBoneAssignment (VertexElementStore
&vertexElements
,
263 Int16
&boneWeightVE
);
264 void readMeshLOD (void);
265 void readMeshLODUsage (void);
266 void readMeshLODManual (void);
267 void readMeshLODGenerated (void);
268 void readMeshBounds (void);
269 void readSubMeshNameTable (SubMeshStore
&subMeshInfo
);
270 void readSubMeshNameTableElement (SubMeshStore
&subMeshInfo
);
271 void readEdgeLists (void);
272 void readPoses (void);
273 void readAnimations (void);
274 void readTableExtremes (void);
276 void readBoneAssignment (VertexElementStore
&vertexElements
,
278 Int16
&boneWeightVE
);
279 void verifyBoneAssignment (VertexElementStore
&vertexElements
,
281 Int16
&boneWeightVE
);
283 void constructSubMesh (SubMeshInfo
&smInfo
,
284 VertexElementStore
&vertexElements
);
285 void constructMaterial (SubMeshInfo
&smInfo
);
287 static const std::string _versionString
;
289 const OgreOptions
&_options
;
294 SkeletonUnrecPtr _skel
;
299 #endif // _OSGOGREMESHREADER_H_