2
Copyright (c) 2008-2009 NetAllied Systems GmbH
4
This file is part of COLLADASaxFrameworkLoader.
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 __COLLADASAXFWL_NODELOADER_H__
12
#define __COLLADASAXFWL_NODELOADER_H__
14
#include "COLLADASaxFWLPrerequisites.h"
15
#include "COLLADASaxFWLHelperLoaderBase.h"
16
#include "COLLADASaxFWLFileLoader.h"
17
#include "COLLADASaxFWLXmlTypes.h"
18
#include "COLLADASaxFWLTransformationLoader.h"
20
#include "COLLADAFWInstanceBindingBase.h"
21
#include "COLLADAFWInstanceGeometry.h"
22
#include "COLLADAFWInstanceController.h"
35
namespace COLLADASaxFWL
38
/** Imports the entire visual scene and sends it to the writer. */
39
class NodeLoader : public HelperLoaderBase
45
typedef std::stack<COLLADAFW::Node*> NodeStack;
47
/** Set of MaterialBindings*/
48
typedef std::set<COLLADAFW::MaterialBinding> MaterialBindingsSet;
50
/** Set of TextureCoordinateBinding*/
51
typedef std::set<COLLADAFW::TextureCoordinateBinding> TextureCoordinateBindingSet;
55
/** Stack of nodes to traverse back in node hierarchy. Array and contents will be delete in destructor.*/
58
/** Instance with material (geometry) currently being filled.*/
59
COLLADAFW::InstanceGeometry* mCurrentInstanceGeometry;
61
/** Instance with material (controller) currently being filled.*/
62
COLLADAFW::InstanceController* mCurrentInstanceController;
66
/** Transformation loader that helps to load transformations.*/
67
TransformationLoader mTransformationLoader;
69
/** Material binding currently being filled.*/
70
COLLADAFW::MaterialBinding* mCurrentMaterialBinding;
72
/** Set of all material bindings of the current instance geometry.*/
73
MaterialBindingsSet mCurrentMaterialBindings;
75
/** Set of all TextureCoordinate bindings of the current instance geometry.*/
76
TextureCoordinateBindingSet mCurrentTextureCoordinateBindings;
78
/** The material info of the geometry instantiated in the current instance geometry.*/
79
GeometryMaterialIdInfo* mCurrentMaterialInfo;
83
/** The InstanceControllerData of the current instance controller.*/
84
Loader::InstanceControllerData *mCurrentInstanceControllerData;
92
virtual ~NodeLoader();
94
/** Sax callback function for the beginning of nodes, as child of a node.*/
95
virtual bool begin__node( const node__AttributeData& attributeData );
97
/** Sax callback function for the ending of nodes, as child of a node.*/
98
virtual bool end__node();
101
/** Sax callback function for the beginning of a translate element.*/
102
virtual bool begin__translate( const translate__AttributeData& attributeData );
104
/** Sax callback function for the ending of a translate element.*/
105
virtual bool end__translate();
107
/** Sax callback function for the float data of a translate element.*/
108
virtual bool data__translate( const float* data, size_t length );
111
/** Sax callback function for the beginning of a rotate element.*/
112
virtual bool begin__rotate( const rotate__AttributeData& attributeData );
114
/** Sax callback function for the ending of a rotate element.*/
115
virtual bool end__rotate();
117
/** Sax callback function for the float data of a rotate element.*/
118
virtual bool data__rotate( const float* data, size_t length );
121
/** Sax callback function for the beginning of a matrix element.*/
122
virtual bool begin__matrix( const matrix__AttributeData& attributeData );
124
/** Sax callback function for the ending of a matrix element.*/
125
virtual bool end__matrix();
127
/** Sax callback function for the float data of a rotate element.*/
128
virtual bool data__matrix( const float* data, size_t length );
131
/** Sax callback function for the beginning of a scale element.*/
132
virtual bool begin__scale( const scale__AttributeData& attributeData );
134
/** Sax callback function for the ending of a scale element.*/
135
virtual bool end__scale();
137
/** Sax callback function for the float data of a scale element.*/
138
virtual bool data__scale( const float* data, size_t length );
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 );
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 );
148
/** Sax callback function for the beginning of an instance geometry element.*/
149
virtual bool begin__instance_geometry( const instance_geometry__AttributeData& attributeData );
151
/** Sax callback function for the ending of an instance geometry element.*/
152
virtual bool end__instance_geometry();
155
/** We do not need to do anything here.*/
156
virtual bool begin__bind_material();
158
/** We do not need to do anything here.*/
159
virtual bool end__bind_material();
161
/** We do not need to do anything here.*/
162
virtual bool begin__bind_material__technique_common(){return true;}
164
/** We do not need to do anything here.*/
165
virtual bool end__bind_material__technique_common(){return true;}
167
/** Create new current bind material and set basic attributes.*/
168
virtual bool begin__instance_material( const instance_material__AttributeData& attributeData );
170
/** We store all instance_material informations in a set.*/
171
virtual bool end__instance_material();
174
/** We store all bind vertex informations in a set.*/
175
virtual bool begin__bind_vertex_input( const bind_vertex_input__AttributeData& attributeData );
177
/** We do not need to do anything here.*/
178
virtual bool end__bind_vertex_input(){return true; }
181
/** Sax callback function for the beginning of an instance node element.*/
182
virtual bool begin__instance_node( const instance_node__AttributeData& attributeData );
184
/** We don't need to do anything here.*/
185
virtual bool end__instance_node();
188
/** Appends the instance camera to the current node.*/
189
virtual bool begin__instance_camera( const instance_camera__AttributeData& attributeData );
191
/** We don't need to do anything here.*/
192
virtual bool end__instance_camera();
195
/** Appends the instance light to the current node.*/
196
virtual bool begin__instance_light( const instance_light__AttributeData& attributeData );
198
/** Set the current parsing position. */
199
virtual bool end__instance_light();
202
virtual bool begin__instance_controller( const instance_controller__AttributeData& attributeData );
203
virtual bool end__instance_controller();
206
virtual bool begin__skeleton(){return true;}
207
virtual bool end__skeleton(){return true;}
209
virtual bool data__skeleton( COLLADABU::URI value );
213
/** This method handles the beginning of a node element, independent of its parent.*/
214
bool beginNode( const node__AttributeData& attributeData );
216
/** This method handles the ending of a node element, independent of its parent.*/
221
/** Disable default copy ctor. */
222
NodeLoader( const NodeLoader& pre );
224
/** Disable default assignment operator. */
225
const NodeLoader& operator= ( const NodeLoader& pre );
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;
230
/** This method handles the beginning of a transformation independent of its type.*/
231
template<class Transformationtype>
232
bool beginTransformation( const char* sid);
234
/** This method handles the ending of a transformation independent of its type.*/
235
bool endTransformation();
237
/** Assigns the bound materials to the current instance with material (geometry or controller).*/
238
bool endInstanceWithMaterial();
243
} // namespace COLLADASAXFWL
245
#endif // __COLLADASAXFWL_NODELOADER_H__