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 |
|
---|
26 | #ifndef __XMLMeshSerializer_H__
|
---|
27 | #define __XMLMeshSerializer_H__
|
---|
28 |
|
---|
29 | #include "OgreXMLPrerequisites.h"
|
---|
30 | #include "OgreMesh.h"
|
---|
31 |
|
---|
32 |
|
---|
33 | namespace Ogre {
|
---|
34 |
|
---|
35 | /** Class for serializing a Mesh to/from XML.
|
---|
36 | @remarks
|
---|
37 | This class behaves the same way as MeshSerializer in the main project,
|
---|
38 | but is here to allow conversions to / from XML. This class is
|
---|
39 | deliberately not included in the main project because <UL>
|
---|
40 | <LI>Dependence on Xerces would unnecessarily bloat the main library</LI>
|
---|
41 | <LI>Runtime use of XML is discouraged because of the parsing overhead</LI></UL>
|
---|
42 | This class gives people the option of saving out a Mesh as XML for examination
|
---|
43 | and possible editing. It can then be converted back to the native format
|
---|
44 | for maximum runtime efficiency.
|
---|
45 | */
|
---|
46 | class XMLMeshSerializer
|
---|
47 | {
|
---|
48 | public:
|
---|
49 |
|
---|
50 | XMLMeshSerializer();
|
---|
51 | virtual ~XMLMeshSerializer();
|
---|
52 | /** Imports a Mesh from the given XML file.
|
---|
53 | @param filename The name of the file to import, expected to be in XML format.
|
---|
54 | @param colourElementType The vertex element to use for packed colours
|
---|
55 | @param pMesh The pre-created Mesh object to be populated.
|
---|
56 | */
|
---|
57 | void importMesh(const String& filename, VertexElementType colourElementType, Mesh* pMesh);
|
---|
58 |
|
---|
59 | /** Exports a mesh to the named XML file. */
|
---|
60 | void exportMesh(const Mesh* pMesh, const String& filename);
|
---|
61 |
|
---|
62 | protected:
|
---|
63 | // State for export
|
---|
64 | TiXmlDocument* mXMLDoc;
|
---|
65 | // State for import
|
---|
66 | Mesh* mpMesh;
|
---|
67 | VertexElementType mColourElementType;
|
---|
68 |
|
---|
69 | // Internal methods
|
---|
70 | void writeMesh(const Mesh* pMesh);
|
---|
71 | void writeSubMesh(TiXmlElement* mSubmeshesNode, const SubMesh* s);
|
---|
72 | void writeGeometry(TiXmlElement* mParentNode, const VertexData* pData);
|
---|
73 | void writeSkeletonLink(TiXmlElement* mMeshNode, const String& skelName);
|
---|
74 | void writeBoneAssignment(TiXmlElement* mBoneAssignNode, const VertexBoneAssignment* assign);
|
---|
75 | void writeTextureAliases(TiXmlElement* mSubmeshesNode, const SubMesh* s);
|
---|
76 | void writeLodInfo(TiXmlElement* mMeshNode, const Mesh* pMesh);
|
---|
77 | void writeLodUsageManual(TiXmlElement* usageNode, unsigned short levelNum,
|
---|
78 | const MeshLodUsage& usage);
|
---|
79 | void writeLodUsageGenerated(TiXmlElement* usageNode, unsigned short levelNum,
|
---|
80 | const MeshLodUsage& usage, const Mesh* pMesh);
|
---|
81 | void writeSubMeshNames(TiXmlElement* mMeshNode, const Mesh* m);
|
---|
82 | void writePoses(TiXmlElement* meshNode, const Mesh* m);
|
---|
83 | void writeAnimations(TiXmlElement* meshNode, const Mesh* m);
|
---|
84 | void writeMorphKeyFrames(TiXmlElement* trackNode, const VertexAnimationTrack* track);
|
---|
85 | void writePoseKeyFrames(TiXmlElement* trackNode, const VertexAnimationTrack* track);
|
---|
86 |
|
---|
87 | void readSubMeshes(TiXmlElement* mSubmeshesNode);
|
---|
88 | void readGeometry(TiXmlElement* mGeometryNode, VertexData* pData);
|
---|
89 | void readSkeletonLink(TiXmlElement* mSkelNode);
|
---|
90 | void readBoneAssignments(TiXmlElement* mBoneAssignmentsNode);
|
---|
91 | void readBoneAssignments(TiXmlElement* mBoneAssignmentsNode, SubMesh* sm);
|
---|
92 | void readTextureAliases(TiXmlElement* mTextureAliasesNode, SubMesh* sm);
|
---|
93 | void readLodInfo(TiXmlElement* lodNode);
|
---|
94 | void readLodUsageManual(TiXmlElement* manualNode, unsigned short index);
|
---|
95 | void readLodUsageGenerated(TiXmlElement* genNode, unsigned short index);
|
---|
96 | void readSubMeshNames(TiXmlElement* mMeshNamesNode, Mesh* sm);
|
---|
97 | void readPoses(TiXmlElement* posesNode, Mesh *m);
|
---|
98 | void readAnimations(TiXmlElement* mAnimationsNode, Mesh *m);
|
---|
99 | void readTracks(TiXmlElement* tracksNode, Mesh *m, Animation* anim);
|
---|
100 | void readMorphKeyFrames(TiXmlElement* keyframesNode, VertexAnimationTrack* track,
|
---|
101 | size_t vertexCount);
|
---|
102 | void readPoseKeyFrames(TiXmlElement* keyframesNode, VertexAnimationTrack* track);
|
---|
103 |
|
---|
104 |
|
---|
105 | };
|
---|
106 |
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 |
|
---|
114 | #endif
|
---|