source: OGRE/trunk/ogrenew/Tools/XMLConverter/include/OgreXMLMeshSerializer.h @ 657

Revision 657, 4.0 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://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
33namespace 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 pMesh The pre-created Mesh object to be populated.
55        */
56        void importMesh(const String& filename, Mesh* pMesh);
57
58        /** Exports a mesh to the named XML file. */
59        void exportMesh(const Mesh* pMesh, const String& filename);
60
61    protected:
62        // State for export
63        TiXmlDocument* mXMLDoc;
64        // State for import
65        Mesh* mpMesh;
66
67        // Internal methods
68        void writeMesh(const Mesh* pMesh);
69        void writeSubMesh(TiXmlElement* mSubmeshesNode, const SubMesh* s);
70        void writeGeometry(TiXmlElement* mParentNode, const VertexData* pData);
71        void writeSkeletonLink(TiXmlElement* mMeshNode, const String& skelName);
72        void writeBoneAssignment(TiXmlElement* mBoneAssignNode, const VertexBoneAssignment* assign);
73                void writeLodInfo(TiXmlElement* mMeshNode, const Mesh* pMesh);
74                void writeLodUsageManual(TiXmlElement* usageNode, unsigned short levelNum,
75                        const MeshLodUsage& usage);
76                void writeLodUsageGenerated(TiXmlElement* usageNode, unsigned short levelNum, 
77                        const MeshLodUsage& usage, const Mesh* pMesh);
78        void writeSubMeshNames(TiXmlElement* mMeshNode, const Mesh* m);
79
80        void readSubMeshes(TiXmlElement* mSubmeshesNode);
81        void readGeometry(TiXmlElement* mGeometryNode, VertexData* pData);
82        void readSkeletonLink(TiXmlElement* mSkelNode);
83        void readBoneAssignments(TiXmlElement* mBoneAssignmentsNode);
84        void readBoneAssignments(TiXmlElement* mBoneAssignmentsNode, SubMesh* sm);
85                void readLodInfo(TiXmlElement*  lodNode);
86                void readLodUsageManual(TiXmlElement* manualNode, unsigned short index);
87                void readLodUsageGenerated(TiXmlElement* genNode, unsigned short index);
88                void readSubMeshNames(TiXmlElement* mMeshNamesNode, Mesh* sm);
89
90
91    };
92
93
94
95
96}
97
98
99
100#endif
Note: See TracBrowser for help on using the repository browser.