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

« back to all changes in this revision

Viewing changes to COLLADASaxFrameworkLoader/include/COLLADASaxFWLNodeLoader.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) 2008-2009 NetAllied Systems GmbH
 
3
 
 
4
    This file is part of COLLADASaxFrameworkLoader.
 
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 __COLLADASAXFWL_NODELOADER_H__
 
12
#define __COLLADASAXFWL_NODELOADER_H__
 
13
 
 
14
#include "COLLADASaxFWLPrerequisites.h"
 
15
#include "COLLADASaxFWLHelperLoaderBase.h"
 
16
#include "COLLADASaxFWLFileLoader.h"
 
17
#include "COLLADASaxFWLXmlTypes.h"
 
18
#include "COLLADASaxFWLTransformationLoader.h"
 
19
 
 
20
#include "COLLADAFWInstanceBindingBase.h"
 
21
#include "COLLADAFWInstanceGeometry.h"
 
22
#include "COLLADAFWInstanceController.h"
 
23
 
 
24
#include <stack>
 
25
#include <set>
 
26
 
 
27
 
 
28
namespace COLLADAFW
 
29
 
30
        class Transformation;
 
31
        class Node;
 
32
}
 
33
 
 
34
 
 
35
namespace COLLADASaxFWL
 
36
{
 
37
 
 
38
        /** Imports the entire visual scene and sends it to the writer. */
 
39
        class NodeLoader : public HelperLoaderBase
 
40
        {
 
41
 
 
42
        private:
 
43
                
 
44
        /** Stack of nodes.*/
 
45
                typedef std::stack<COLLADAFW::Node*> NodeStack;
 
46
 
 
47
                /** Set of MaterialBindings*/
 
48
        typedef std::set<COLLADAFW::MaterialBinding> MaterialBindingsSet;
 
49
 
 
50
                /** Set of TextureCoordinateBinding*/
 
51
                typedef std::set<COLLADAFW::TextureCoordinateBinding> TextureCoordinateBindingSet;
 
52
 
 
53
    protected:
 
54
 
 
55
                /** Stack of nodes to traverse back in node hierarchy. Array and contents will be delete in destructor.*/
 
56
                NodeStack mNodeStack;
 
57
 
 
58
        /** Instance with material (geometry) currently being filled.*/
 
59
        COLLADAFW::InstanceGeometry* mCurrentInstanceGeometry;
 
60
 
 
61
        /** Instance with material (controller) currently being filled.*/
 
62
        COLLADAFW::InstanceController* mCurrentInstanceController;
 
63
 
 
64
    private:
 
65
 
 
66
        /** Transformation loader that helps to load transformations.*/
 
67
                TransformationLoader mTransformationLoader;
 
68
 
 
69
                /** Material binding currently being filled.*/
 
70
                COLLADAFW::MaterialBinding* mCurrentMaterialBinding;
 
71
 
 
72
                /** Set of all material bindings of the current instance geometry.*/
 
73
                MaterialBindingsSet mCurrentMaterialBindings;
 
74
 
 
75
                /** Set of all TextureCoordinate bindings of the current instance geometry.*/
 
76
                TextureCoordinateBindingSet mCurrentTextureCoordinateBindings;
 
77
 
 
78
                /** The material info of the geometry instantiated in the current instance geometry.*/
 
79
                GeometryMaterialIdInfo* mCurrentMaterialInfo;
 
80
 
 
81
    protected:
 
82
 
 
83
                /** The InstanceControllerData of the current instance controller.*/
 
84
                Loader::InstanceControllerData *mCurrentInstanceControllerData;
 
85
 
 
86
        public:
 
87
 
 
88
                /** Constructor. */
 
89
                NodeLoader();
 
90
 
 
91
                /** Destructor. */
 
92
                virtual ~NodeLoader();
 
93
 
 
94
        /** Sax callback function for the beginning of nodes, as child of a node.*/
 
95
        virtual bool begin__node( const node__AttributeData& attributeData );
 
96
 
 
97
        /** Sax callback function for the ending of nodes, as child of a node.*/
 
98
        virtual bool end__node();
 
99
 
 
100
 
 
101
        /** Sax callback function for the beginning of a translate element.*/
 
102
        virtual bool begin__translate( const translate__AttributeData& attributeData );
 
103
 
 
104
        /** Sax callback function for the ending of a translate element.*/
 
105
        virtual bool end__translate();
 
106
 
 
107
        /** Sax callback function for the float data of a translate element.*/
 
108
        virtual bool data__translate( const float* data, size_t length );
 
109
 
 
110
 
 
111
        /** Sax callback function for the beginning of a rotate element.*/
 
112
        virtual bool begin__rotate( const rotate__AttributeData& attributeData );
 
113
 
 
114
        /** Sax callback function for the ending of a rotate element.*/
 
115
        virtual bool end__rotate();
 
116
 
 
117
        /** Sax callback function for the float data of a rotate element.*/
 
118
        virtual bool data__rotate( const float* data, size_t length );
 
119
 
 
120
 
 
121
        /** Sax callback function for the beginning of a matrix element.*/
 
122
        virtual bool begin__matrix( const matrix__AttributeData& attributeData );
 
123
 
 
124
        /** Sax callback function for the ending of a matrix element.*/
 
125
        virtual bool end__matrix();
 
126
 
 
127
        /** Sax callback function for the float data of a rotate element.*/
 
128
        virtual bool data__matrix( const float* data, size_t length );
 
129
 
 
130
 
 
131
        /** Sax callback function for the beginning of a scale element.*/
 
132
        virtual bool begin__scale( const scale__AttributeData& attributeData );
 
133
 
 
134
        /** Sax callback function for the ending of a scale element.*/
 
135
        virtual bool end__scale();
 
136
 
 
137
        /** Sax callback function for the float data of a scale element.*/
 
138
        virtual bool data__scale( const float* data, size_t length );
 
139
 
 
140
        virtual bool begin__skew( const skew__AttributeData& attributeData );
 
141
        virtual bool end__skew();
 
142
        virtual bool data__skew( const float* data, size_t length );
 
143
 
 
144
        virtual bool begin__lookat( const lookat__AttributeData& attributeData );
 
145
        virtual bool end__lookat();
 
146
        virtual bool data__lookat( const float* data, size_t length );
 
147
 
 
148
        /** Sax callback function for the beginning of an instance geometry element.*/
 
149
        virtual bool begin__instance_geometry( const instance_geometry__AttributeData& attributeData );
 
150
 
 
151
        /** Sax callback function for the ending of an instance geometry element.*/
 
152
        virtual bool end__instance_geometry();
 
153
 
 
154
 
 
155
        /** We do not need to do anything here.*/
 
156
        virtual bool begin__bind_material();
 
157
 
 
158
        /** We do not need to do anything here.*/
 
159
        virtual bool end__bind_material();
 
160
 
 
161
        /** We do not need to do anything here.*/
 
162
        virtual bool begin__bind_material__technique_common(){return true;}
 
163
 
 
164
        /** We do not need to do anything here.*/
 
165
        virtual bool end__bind_material__technique_common(){return true;}
 
166
 
 
167
        /** Create new current bind material and set basic attributes.*/
 
168
        virtual bool begin__instance_material( const instance_material__AttributeData& attributeData );
 
169
 
 
170
        /** We store all instance_material informations in a set.*/
 
171
        virtual bool end__instance_material();
 
172
 
 
173
 
 
174
        /** We store all bind vertex informations in a set.*/
 
175
        virtual bool begin__bind_vertex_input( const bind_vertex_input__AttributeData& attributeData );
 
176
 
 
177
        /** We do not need to do anything here.*/
 
178
        virtual bool end__bind_vertex_input(){return true; }
 
179
 
 
180
 
 
181
        /** Sax callback function for the beginning of an instance node element.*/
 
182
        virtual bool begin__instance_node( const instance_node__AttributeData& attributeData );
 
183
 
 
184
        /** We don't need to do anything here.*/
 
185
        virtual bool end__instance_node();
 
186
 
 
187
 
 
188
        /** Appends the instance camera to the current node.*/
 
189
        virtual bool begin__instance_camera( const instance_camera__AttributeData& attributeData );
 
190
 
 
191
        /** We don't need to do anything here.*/
 
192
        virtual bool end__instance_camera();
 
193
 
 
194
 
 
195
        /** Appends the instance light to the current node.*/
 
196
        virtual bool begin__instance_light( const instance_light__AttributeData& attributeData );
 
197
 
 
198
        /** Set the current parsing position. */
 
199
        virtual bool end__instance_light();
 
200
 
 
201
 
 
202
        virtual bool begin__instance_controller( const instance_controller__AttributeData& attributeData );
 
203
        virtual bool end__instance_controller();
 
204
 
 
205
 
 
206
        virtual bool begin__skeleton(){return true;}
 
207
        virtual bool end__skeleton(){return true;}
 
208
 
 
209
        virtual bool data__skeleton( COLLADABU::URI value );
 
210
 
 
211
    protected:
 
212
 
 
213
                /** This method handles the beginning of a node element, independent of its parent.*/
 
214
                bool beginNode( const node__AttributeData& attributeData );
 
215
 
 
216
                /** This method handles the ending of a node element, independent of its parent.*/
 
217
                bool endNode();
 
218
 
 
219
        private:
 
220
 
 
221
                /** Disable default copy ctor. */
 
222
                NodeLoader( const NodeLoader& pre );
 
223
 
 
224
                /** Disable default assignment operator. */
 
225
                const NodeLoader& operator= ( const NodeLoader& pre );
 
226
 
 
227
                /** Store a root node, i.e. a node that does not has a node as parent.*/
 
228
                virtual void handleRootNode( COLLADAFW::Node* rootNode ) = 0;
 
229
 
 
230
                /** This method handles the beginning of a transformation independent of its type.*/
 
231
                template<class Transformationtype> 
 
232
                bool beginTransformation( const char* sid);
 
233
 
 
234
                /** This method handles the ending of a transformation independent of its type.*/
 
235
                bool endTransformation();
 
236
 
 
237
                /** Assigns the bound materials to the current instance with material (geometry or controller).*/
 
238
                bool endInstanceWithMaterial();
 
239
 
 
240
 
 
241
        };
 
242
 
 
243
} // namespace COLLADASAXFWL
 
244
 
 
245
#endif // __COLLADASAXFWL_NODELOADER_H__