2
Copyright (c) 2009 NetAllied Systems GmbH
4
This file is part of dae2ogre.
6
Licensed under the MIT Open Source License,
7
for details please see LICENSE file or the website
8
http://www.opensource.org/licenses/mit-license.php
11
#ifndef __DAE2OGRE_OGREWRITER_H__
12
#define __DAE2OGRE_OGREWRITER_H__
14
#include "DAE2OgrePrerequisites.h"
16
#include "COLLADAFWIWriter.h"
17
#include "COLLADAFWUniqueId.h"
18
#include "COLLADAFWVisualScene.h"
19
#include "COLLADAFWLibraryNodes.h"
20
#include "COLLADAFWMaterial.h"
21
#include "COLLADAFWEffect.h"
22
#include "COLLADAFWImage.h"
24
#include "COLLADABUURI.h"
25
#include "Math/COLLADABUMathMatrix4.h"
36
class OgreWriter : public COLLADAFW::IWriter
45
typedef std::list<COLLADAFW::LibraryNodes> LibraryNodesList;
47
struct InstanceGeometryInfo
49
InstanceGeometryInfo( COLLADAFW::InstanceGeometry* _fwInstanceGeometry, const COLLADABU::Math::Matrix4& _worldMatrix)
50
: fwInstanceGeometry(_fwInstanceGeometry), worldMatrix(_worldMatrix) {}
51
COLLADAFW::InstanceGeometry* fwInstanceGeometry;
52
COLLADABU::Math::Matrix4 worldMatrix;
55
typedef std::multimap<COLLADAFW::UniqueId, InstanceGeometryInfo> GeometryUniqueIdInstanceGeometryInfoMap;
57
/** Maps unique ids of framework materials to the corresponding framework material.*/
58
typedef std::map<COLLADAFW::UniqueId, COLLADAFW::Material> UniqueIdFWMaterialMap;
60
/** Maps unique ids of framework images to the corresponding framework image.*/
61
typedef std::map<COLLADAFW::UniqueId, COLLADAFW::Image> UniqueIdFWImageMap;
63
/** Maps unique ids of framework effects to the corresponding framework material.*/
64
typedef std::map<COLLADAFW::UniqueId, COLLADAFW::Effect> UniqueIdFWEffectMap;
75
COLLADABU::URI mInputFile;
76
COLLADABU::URI mOutputFile;
79
const COLLADAFW::VisualScene* mVisualScene;
80
LibraryNodesList mLibrayNodesList;
82
GeometryUniqueIdInstanceGeometryInfoMap mGeometryUniqueIdInstanceGeometryInfoMap;
84
UniqueIdFWMaterialMap mUniqueIdFWMaterialMap;
85
UniqueIdFWImageMap mUniqueIdFWImageMap;
86
UniqueIdFWEffectMap mUniqueIdFWEffectMap;
89
OgreWriter( const COLLADABU::URI& inputFile, const COLLADABU::URI& outputFile );
90
virtual ~OgreWriter();
93
static void reportError(const String& method, const String& message, Severity severity);
99
/** Deletes the entire scene.
100
@param errorMessage A message containing informations about the error that occurred.
102
void cancel(const String& errorMessage);;
104
/** Prepare to receive data.*/
107
/** Remove all objects that don't have an object. Deletes unused visual scenes.*/
110
/** When this method is called, the writer must write the global document asset.
111
@return The writer should return true, if writing succeeded, false otherwise.*/
112
virtual bool writeGlobalAsset ( const COLLADAFW::FileInfo* asset );
114
/** Writes the entire visual scene.
115
@return True on succeeded, false otherwise.*/
116
virtual bool writeVisualScene ( const COLLADAFW::VisualScene* visualScene );
118
/** Writes the scene.
119
@return True on succeeded, false otherwise.*/
120
virtual bool writeScene ( const COLLADAFW::Scene* scene );
122
/** Handles all nodes in the library nodes.
123
@return True on succeeded, false otherwise.*/
124
virtual bool writeLibraryNodes( const COLLADAFW::LibraryNodes* libraryNodes );
126
/** Writes the geometry.
127
@return True on succeeded, false otherwise.*/
128
virtual bool writeGeometry ( const COLLADAFW::Geometry* geometry );
130
/** Writes the material.
131
@return True on succeeded, false otherwise.*/
132
virtual bool writeMaterial( const COLLADAFW::Material* material );
134
/** Writes the effect.
135
@return True on succeeded, false otherwise.*/
136
virtual bool writeEffect( const COLLADAFW::Effect* effect );
138
/** Writes the camera.
139
@return True on succeeded, false otherwise.*/
140
virtual bool writeCamera( const COLLADAFW::Camera* camera );
142
/** Writes the image.
143
@return True on succeeded, false otherwise.*/
144
virtual bool writeImage( const COLLADAFW::Image* image );
146
/** Writes the light.
147
@return True on succeeded, false otherwise.*/
148
virtual bool writeLight( const COLLADAFW::Light* light );
150
/** Writes the animation.
151
@return True on succeeded, false otherwise.*/
152
virtual bool writeAnimation( const COLLADAFW::Animation* animation );
154
/** Writes the animation.
155
@return True on succeeded, false otherwise.*/
156
virtual bool writeAnimationList( const COLLADAFW::AnimationList* animationList );
158
/** Writes the skin controller data.
159
@return True on succeeded, false otherwise.*/
160
virtual bool writeSkinControllerData( const COLLADAFW::SkinControllerData* skinControllerData );
162
/** Writes the controller.
163
@return True on succeeded, false otherwise.*/
164
virtual bool writeController( const COLLADAFW::Controller* Controller );
166
/** When this method is called, the writer must write the formulas. All the formulas of the entire
167
COLLADA file are contained in @a formulas.
168
@return The writer should return true, if writing succeeded, false otherwise.*/
169
virtual bool writeFormulas( const COLLADAFW::Formulas* formulas ){return true;}
171
/** When this method is called, the writer must write the kinematics scene.
172
@return The writer should return true, if writing succeeded, false otherwise.*/
173
virtual bool writeKinematicsScene( const COLLADAFW::KinematicsScene* kinematicsScene ){return true;};
178
friend class BaseWriter;
180
GeometryUniqueIdInstanceGeometryInfoMap& getGeometryUniqueIdInstanceGeometryInfoMap() { return mGeometryUniqueIdInstanceGeometryInfoMap; }
182
UniqueIdFWMaterialMap& getUniqueIdFWMaterialMap() { return mUniqueIdFWMaterialMap; }
184
UniqueIdFWImageMap& getUniqueIdFWImageMap() { return mUniqueIdFWImageMap; }
186
UniqueIdFWEffectMap& getUniqueIdFWEffectMap() { return mUniqueIdFWEffectMap; }
188
const COLLADABU::URI& getInputFile() const { return mInputFile; }
190
const COLLADABU::URI& getOutputFile() const { return mOutputFile; }
194
/** Disable default copy ctor. */
195
OgreWriter( const OgreWriter& pre );
196
/** Disable default assignment operator. */
197
const OgreWriter& operator= ( const OgreWriter& pre );
200
} // namespace DAE2Ogre
202
#endif // __DAE2OGRE_OGREWRITER_H__