~ubuntu-branches/ubuntu/wily/opencollada/wily-proposed

« back to all changes in this revision

Viewing changes to dae2ogre/include/DAE2OgreOgreWriter.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2015-05-14 17:23:27 UTC
  • Revision ID: package-import@ubuntu.com-20150514172327-f862u8envms01fra
Tags: upstream-0.1.0~20140703.ddf8f47+dfsg1
ImportĀ upstreamĀ versionĀ 0.1.0~20140703.ddf8f47+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 2009 NetAllied Systems GmbH
 
3
 
 
4
This file is part of dae2ogre.
 
5
 
 
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
 
9
*/
 
10
 
 
11
#ifndef __DAE2OGRE_OGREWRITER_H__
 
12
#define __DAE2OGRE_OGREWRITER_H__
 
13
 
 
14
#include "DAE2OgrePrerequisites.h"
 
15
 
 
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"
 
23
 
 
24
#include "COLLADABUURI.h"
 
25
#include "Math/COLLADABUMathMatrix4.h"
 
26
 
 
27
#include <stack>
 
28
#include <list>
 
29
#include <map>
 
30
 
 
31
namespace DAE2Ogre
 
32
{
 
33
 
 
34
        class BaseWriter;
 
35
 
 
36
        class OgreWriter : public COLLADAFW::IWriter
 
37
        {
 
38
        public:
 
39
                enum Runs
 
40
                {
 
41
                        SCENEGRAPH_RUN,
 
42
                        GEOMETRY_RUN
 
43
                };
 
44
 
 
45
                typedef std::list<COLLADAFW::LibraryNodes> LibraryNodesList;
 
46
 
 
47
                struct InstanceGeometryInfo
 
48
                {
 
49
                        InstanceGeometryInfo( COLLADAFW::InstanceGeometry* _fwInstanceGeometry, const COLLADABU::Math::Matrix4& _worldMatrix)
 
50
                                :  fwInstanceGeometry(_fwInstanceGeometry), worldMatrix(_worldMatrix) {}
 
51
                        COLLADAFW::InstanceGeometry* fwInstanceGeometry;
 
52
                        COLLADABU::Math::Matrix4 worldMatrix;
 
53
                };
 
54
 
 
55
                typedef std::multimap<COLLADAFW::UniqueId, InstanceGeometryInfo> GeometryUniqueIdInstanceGeometryInfoMap;
 
56
 
 
57
                /** Maps unique ids of framework materials to the corresponding framework material.*/
 
58
                typedef std::map<COLLADAFW::UniqueId, COLLADAFW::Material> UniqueIdFWMaterialMap;
 
59
 
 
60
                /** Maps unique ids of framework images to the corresponding framework image.*/
 
61
                typedef std::map<COLLADAFW::UniqueId, COLLADAFW::Image> UniqueIdFWImageMap;
 
62
 
 
63
                /** Maps unique ids of framework effects to the corresponding framework material.*/
 
64
                typedef std::map<COLLADAFW::UniqueId, COLLADAFW::Effect> UniqueIdFWEffectMap;
 
65
 
 
66
                enum Severity
 
67
                {
 
68
                        SEVERITY_INFORMATION,
 
69
                        SEVERITY_WARNING,
 
70
                        _SEVERITY_ERROR
 
71
                };
 
72
 
 
73
 
 
74
        private:
 
75
                COLLADABU::URI mInputFile;
 
76
                COLLADABU::URI mOutputFile;
 
77
                Runs mCurrentRun;
 
78
 
 
79
                const COLLADAFW::VisualScene* mVisualScene;
 
80
                LibraryNodesList mLibrayNodesList;
 
81
 
 
82
                GeometryUniqueIdInstanceGeometryInfoMap mGeometryUniqueIdInstanceGeometryInfoMap;
 
83
 
 
84
                UniqueIdFWMaterialMap mUniqueIdFWMaterialMap;
 
85
                UniqueIdFWImageMap mUniqueIdFWImageMap;
 
86
                UniqueIdFWEffectMap mUniqueIdFWEffectMap;
 
87
        
 
88
        public:
 
89
                OgreWriter( const COLLADABU::URI& inputFile, const COLLADABU::URI& outputFile );
 
90
                virtual ~OgreWriter();
 
91
 
 
92
        public:
 
93
                static void reportError(const String& method, const String& message, Severity severity);
 
94
 
 
95
        public:
 
96
 
 
97
                bool write();
 
98
 
 
99
                /** Deletes the entire scene.
 
100
                @param errorMessage A message containing informations about the error that occurred.
 
101
                */
 
102
                void cancel(const String& errorMessage);;
 
103
 
 
104
                /** Prepare to receive data.*/
 
105
                void start();;
 
106
 
 
107
                /** Remove all objects that don't have an object. Deletes unused visual scenes.*/
 
108
                void finish();;
 
109
 
 
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 );
 
113
 
 
114
                /** Writes the entire visual scene.
 
115
                @return True on succeeded, false otherwise.*/
 
116
                virtual bool writeVisualScene ( const COLLADAFW::VisualScene* visualScene );
 
117
 
 
118
                /** Writes the scene.
 
119
                @return True on succeeded, false otherwise.*/
 
120
                virtual bool writeScene ( const COLLADAFW::Scene* scene );
 
121
 
 
122
                /** Handles all nodes in the library nodes.
 
123
                @return True on succeeded, false otherwise.*/
 
124
                virtual bool writeLibraryNodes( const COLLADAFW::LibraryNodes* libraryNodes );
 
125
 
 
126
                /** Writes the geometry.
 
127
                @return True on succeeded, false otherwise.*/
 
128
                virtual bool writeGeometry ( const COLLADAFW::Geometry* geometry );
 
129
 
 
130
                /** Writes the material.
 
131
                @return True on succeeded, false otherwise.*/
 
132
                virtual bool writeMaterial( const COLLADAFW::Material* material );
 
133
 
 
134
                /** Writes the effect.
 
135
                @return True on succeeded, false otherwise.*/
 
136
                virtual bool writeEffect( const COLLADAFW::Effect* effect );
 
137
 
 
138
                /** Writes the camera.
 
139
                @return True on succeeded, false otherwise.*/
 
140
                virtual bool writeCamera( const COLLADAFW::Camera* camera );
 
141
 
 
142
                /** Writes the image.
 
143
                @return True on succeeded, false otherwise.*/
 
144
                virtual bool writeImage( const COLLADAFW::Image* image );
 
145
 
 
146
                /** Writes the light.
 
147
                @return True on succeeded, false otherwise.*/
 
148
                virtual bool writeLight( const COLLADAFW::Light* light );
 
149
 
 
150
                /** Writes the animation.
 
151
                @return True on succeeded, false otherwise.*/
 
152
                virtual bool writeAnimation( const COLLADAFW::Animation* animation );
 
153
 
 
154
                /** Writes the animation.
 
155
                @return True on succeeded, false otherwise.*/
 
156
                virtual bool writeAnimationList( const COLLADAFW::AnimationList* animationList );
 
157
 
 
158
                /** Writes the skin controller data.
 
159
                @return True on succeeded, false otherwise.*/
 
160
                virtual bool writeSkinControllerData( const COLLADAFW::SkinControllerData* skinControllerData );
 
161
 
 
162
                /** Writes the controller.
 
163
                @return True on succeeded, false otherwise.*/
 
164
                virtual bool writeController( const COLLADAFW::Controller* Controller );
 
165
 
 
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;}
 
170
 
 
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;};
 
174
 
 
175
 
 
176
        
 
177
        protected:
 
178
                friend class BaseWriter;
 
179
 
 
180
                GeometryUniqueIdInstanceGeometryInfoMap& getGeometryUniqueIdInstanceGeometryInfoMap() { return mGeometryUniqueIdInstanceGeometryInfoMap; }
 
181
 
 
182
                UniqueIdFWMaterialMap& getUniqueIdFWMaterialMap() { return mUniqueIdFWMaterialMap; }
 
183
 
 
184
                UniqueIdFWImageMap& getUniqueIdFWImageMap() { return mUniqueIdFWImageMap; }
 
185
 
 
186
                UniqueIdFWEffectMap& getUniqueIdFWEffectMap() { return mUniqueIdFWEffectMap; }
 
187
 
 
188
                const COLLADABU::URI& getInputFile() const { return mInputFile; }
 
189
 
 
190
                const COLLADABU::URI& getOutputFile() const { return mOutputFile; }
 
191
 
 
192
 
 
193
        private:
 
194
        /** Disable default copy ctor. */
 
195
                OgreWriter( const OgreWriter& pre );
 
196
        /** Disable default assignment operator. */
 
197
                const OgreWriter& operator= ( const OgreWriter& pre );
 
198
 
 
199
        };
 
200
} // namespace DAE2Ogre
 
201
 
 
202
#endif // __DAE2OGRE_OGREWRITER_H__