1 /*
2  *  Copyright (C) 2005-2007  MakeHuman Project
3  *
4  *  This program is free software; you  can  redistribute  it  and/or
5  *  modify  it  under  the terms of the GNU General Public License as
6  *  published by the Free Software Foundation; either  version  3  of
7  *  the License, or (at your option) any later version.
8  *
9  *  This  program  is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the  implied  warranty  of
11  *  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  *  General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software Foun-
16  *  dation, Inc., 59 Temple Place, Suite 330, Boston,  MA  02111-1307
17  *  USA
18  *
19  *  File: OgreXMLExporter.h
20  *  Project: MakeHuman <info@makehuman.org>, http://www.makehuman.org/
21  *  Library: ANIMORPH
22  *
23  *  For individual developers look into the AUTHORS file.
24  *
25  */
26 
27 #ifndef OGREXMLEXPORTER_H
28 #define OGREXMLEXPORTER_H 1
29 
30 #ifdef HAVE_CONFIG_H
31   #include <config.h>
32 #endif
33 #include "xmlParser.h"
34 #include <iostream>
35 #include <fstream>
36 #include "Mesh.h"
37 #include "Matrix.h"
38 #include "util.h"
39 
40 using std::ostringstream;
41 using std::string;
42 
43 
44 namespace Animorph {
45 
46 class OgreXMLExporter
47 {
48 protected:
49   Mesh &mesh;
50   Matrix tm;
51 
52   void InsertASubmeshNode(XMLNode *xNodeSubmeshes,XMLNode *xNodeSubmesh, int index_material);
53   void CreateLibraryMaterialsNode(struct XMLNode *xNode_library_materials,XMLNode *xNode_library_effects);
54   void CreatePolygons(XMLNode *xNode_mesh ,string name);
55 
56 public:
57    /*!
58    * \param _mesh construct ColladaExporter from a Mesh object
59    */
OgreXMLExporter(Animorph::Mesh & _mesh)60   OgreXMLExporter (Animorph::Mesh &_mesh) : mesh (_mesh)
61   {
62     tm.identity ();
63   }
64 
65   /*!
66    * \param tm the Matrix which transformates the Mesh before exporting
67    */
setTransformationMatrix(Matrix & tm)68   void setTransformationMatrix (Matrix &tm) {this->tm = tm;}
69 
70   /// export the Mesh and MTL file in the same file .mesh.xml
71   /*!
72    * \param filename the file to save
73    * \return true if file is saved
74    * \return false if file couldn't be saved
75   */
76   bool exportFile (const string& filename);
77 
78 
79 };
80 }
81 #endif
82