• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright 2006 Sony Computer Entertainment Inc.
3 *
4 * Licensed under the MIT Open Source License, for details please see license.txt or the website
5 * http://www.opensource.org/licenses/mit-license.php
6 *
7 */
8 
9 #ifndef __domNode_h__
10 #define __domNode_h__
11 
12 #include <dae/daeDocument.h>
13 #include <dom/domTypes.h>
14 #include <dom/domElements.h>
15 
16 #include <dom/domAsset.h>
17 #include <dom/domLookat.h>
18 #include <dom/domMatrix.h>
19 #include <dom/domRotate.h>
20 #include <dom/domScale.h>
21 #include <dom/domSkew.h>
22 #include <dom/domTranslate.h>
23 #include <dom/domInstance_camera.h>
24 #include <dom/domInstance_controller.h>
25 #include <dom/domInstance_geometry.h>
26 #include <dom/domInstance_light.h>
27 #include <dom/domInstance_node.h>
28 #include <dom/domNode.h>
29 #include <dom/domExtra.h>
30 class DAE;
31 
32 /**
33  * Nodes embody the hierarchical relationship of elements in the scene.
34  */
35 class domNode : public daeElement
36 {
37 public:
getElementType()38 	virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::NODE; }
ID()39 	static daeInt ID() { return 681; }
typeID()40 	virtual daeInt typeID() const { return ID(); }
41 protected:  // Attributes
42 /**
43  *  The id attribute is a text string containing the unique identifier of
44  * this element.  This value must be unique within the instance document.
45  * Optional attribute.
46  */
47 	xsID attrId;
48 /**
49  *  The name attribute is the text string name of this element. Optional attribute.
50  */
51 	xsNCName attrName;
52 /**
53  *  The sid attribute is a text string value containing the sub-identifier
54  * of this element.  This value must be unique within the scope of the parent
55  * element. Optional attribute.
56  */
57 	xsNCName attrSid;
58 /**
59  *  The type attribute indicates the type of the node element. The default
60  * value is “NODE”.  Optional attribute.
61  */
62 	domNodeType attrType;
63 /**
64  *  The layer attribute indicates the names of the layers to which this node
65  * belongs.  For example,  a value of “foreground glowing” indicates that
66  * this node belongs to both the ‘foreground’ layer  and the ‘glowing’
67  * layer.  The default value is empty, indicating that the node doesn’t
68  * belong to  any layer.  Optional attribute.
69  */
70 	domListOfNames attrLayer;
71 
72 protected:  // Elements
73 /**
74  *  The node element may contain an asset element.  @see domAsset
75  */
76 	domAssetRef elemAsset;
77 /**
78  *  The node element may contain any number of lookat elements.  @see domLookat
79  */
80 	domLookat_Array elemLookat_array;
81 /**
82  *  The node element may contain any number of matrix elements.  @see domMatrix
83  */
84 	domMatrix_Array elemMatrix_array;
85 /**
86  *  The node element may contain any number of rotate elements.  @see domRotate
87  */
88 	domRotate_Array elemRotate_array;
89 /**
90  *  The node element may contain any number of scale elements.  @see domScale
91  */
92 	domScale_Array elemScale_array;
93 /**
94  *  The node element may contain any number of skew elements.  @see domSkew
95  */
96 	domSkew_Array elemSkew_array;
97 /**
98  *  The node element may contain any number of translate elements.  @see domTranslate
99  */
100 	domTranslate_Array elemTranslate_array;
101 /**
102  *  The node element may instance any number of camera objects.  @see domInstance_camera
103  */
104 	domInstance_camera_Array elemInstance_camera_array;
105 /**
106  *  The node element may instance any number of controller objects.  @see
107  * domInstance_controller
108  */
109 	domInstance_controller_Array elemInstance_controller_array;
110 /**
111  *  The node element may instance any number of geometry objects.  @see domInstance_geometry
112  */
113 	domInstance_geometry_Array elemInstance_geometry_array;
114 /**
115  *  The node element may instance any number of light objects.  @see domInstance_light
116  */
117 	domInstance_light_Array elemInstance_light_array;
118 /**
119  *  The node element may instance any number of node elements or hierarchies
120  * objects.  @see domInstance_node
121  */
122 	domInstance_node_Array elemInstance_node_array;
123 /**
124  *  The node element may be hierarchical and be the parent of any number of
125  * other node elements.  @see domNode
126  */
127 	domNode_Array elemNode_array;
128 /**
129  *  The extra element may appear any number of times.  @see domExtra
130  */
131 	domExtra_Array elemExtra_array;
132 	/**
133 	 * Used to preserve order in elements that do not specify strict sequencing of sub-elements.
134 	 */
135 	daeElementRefArray _contents;
136 	/**
137 	 * Used to preserve order in elements that have a complex content model.
138 	 */
139 	daeUIntArray       _contentsOrder;
140 
141 	/**
142 	 * Used to store information needed for some content model objects.
143 	 */
144 	daeTArray< daeCharArray * > _CMData;
145 
146 
147 public:	//Accessors and Mutators
148 	/**
149 	 * Gets the id attribute.
150 	 * @return Returns a xsID of the id attribute.
151 	 */
getId()152 	xsID getId() const { return attrId; }
153 	/**
154 	 * Sets the id attribute.
155 	 * @param atId The new value for the id attribute.
156 	 */
setId(xsID atId)157 	void setId( xsID atId ) { *(daeStringRef*)&attrId = atId; _validAttributeArray[0] = true;
158 		if( _document != NULL ) _document->changeElementID( this, attrId );
159 	}
160 
161 	/**
162 	 * Gets the name attribute.
163 	 * @return Returns a xsNCName of the name attribute.
164 	 */
getName()165 	xsNCName getName() const { return attrName; }
166 	/**
167 	 * Sets the name attribute.
168 	 * @param atName The new value for the name attribute.
169 	 */
setName(xsNCName atName)170 	void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[1] = true; }
171 
172 	/**
173 	 * Gets the sid attribute.
174 	 * @return Returns a xsNCName of the sid attribute.
175 	 */
getSid()176 	xsNCName getSid() const { return attrSid; }
177 	/**
178 	 * Sets the sid attribute.
179 	 * @param atSid The new value for the sid attribute.
180 	 */
setSid(xsNCName atSid)181 	void setSid( xsNCName atSid ) { *(daeStringRef*)&attrSid = atSid; _validAttributeArray[2] = true; }
182 
183 	/**
184 	 * Gets the type attribute.
185 	 * @return Returns a domNodeType of the type attribute.
186 	 */
getType()187 	domNodeType getType() const { return attrType; }
188 	/**
189 	 * Sets the type attribute.
190 	 * @param atType The new value for the type attribute.
191 	 */
setType(domNodeType atType)192 	void setType( domNodeType atType ) { attrType = atType; _validAttributeArray[3] = true; }
193 
194 	/**
195 	 * Gets the layer array attribute.
196 	 * @return Returns a domListOfNames reference of the layer array attribute.
197 	 */
getLayer()198 	domListOfNames &getLayer() { return attrLayer; }
199 	/**
200 	 * Gets the layer array attribute.
201 	 * @return Returns a constant domListOfNames reference of the layer array attribute.
202 	 */
getLayer()203 	const domListOfNames &getLayer() const { return attrLayer; }
204 	/**
205 	 * Sets the layer array attribute.
206 	 * @param atLayer The new value for the layer array attribute.
207 	 */
setLayer(const domListOfNames & atLayer)208 	void setLayer( const domListOfNames &atLayer ) { attrLayer = atLayer; _validAttributeArray[4] = true; }
209 
210 	/**
211 	 * Gets the asset element.
212 	 * @return a daeSmartRef to the asset element.
213 	 */
getAsset()214 	const domAssetRef getAsset() const { return elemAsset; }
215 	/**
216 	 * Gets the lookat element array.
217 	 * @return Returns a reference to the array of lookat elements.
218 	 */
getLookat_array()219 	domLookat_Array &getLookat_array() { return elemLookat_array; }
220 	/**
221 	 * Gets the lookat element array.
222 	 * @return Returns a constant reference to the array of lookat elements.
223 	 */
getLookat_array()224 	const domLookat_Array &getLookat_array() const { return elemLookat_array; }
225 	/**
226 	 * Gets the matrix element array.
227 	 * @return Returns a reference to the array of matrix elements.
228 	 */
getMatrix_array()229 	domMatrix_Array &getMatrix_array() { return elemMatrix_array; }
230 	/**
231 	 * Gets the matrix element array.
232 	 * @return Returns a constant reference to the array of matrix elements.
233 	 */
getMatrix_array()234 	const domMatrix_Array &getMatrix_array() const { return elemMatrix_array; }
235 	/**
236 	 * Gets the rotate element array.
237 	 * @return Returns a reference to the array of rotate elements.
238 	 */
getRotate_array()239 	domRotate_Array &getRotate_array() { return elemRotate_array; }
240 	/**
241 	 * Gets the rotate element array.
242 	 * @return Returns a constant reference to the array of rotate elements.
243 	 */
getRotate_array()244 	const domRotate_Array &getRotate_array() const { return elemRotate_array; }
245 	/**
246 	 * Gets the scale element array.
247 	 * @return Returns a reference to the array of scale elements.
248 	 */
getScale_array()249 	domScale_Array &getScale_array() { return elemScale_array; }
250 	/**
251 	 * Gets the scale element array.
252 	 * @return Returns a constant reference to the array of scale elements.
253 	 */
getScale_array()254 	const domScale_Array &getScale_array() const { return elemScale_array; }
255 	/**
256 	 * Gets the skew element array.
257 	 * @return Returns a reference to the array of skew elements.
258 	 */
getSkew_array()259 	domSkew_Array &getSkew_array() { return elemSkew_array; }
260 	/**
261 	 * Gets the skew element array.
262 	 * @return Returns a constant reference to the array of skew elements.
263 	 */
getSkew_array()264 	const domSkew_Array &getSkew_array() const { return elemSkew_array; }
265 	/**
266 	 * Gets the translate element array.
267 	 * @return Returns a reference to the array of translate elements.
268 	 */
getTranslate_array()269 	domTranslate_Array &getTranslate_array() { return elemTranslate_array; }
270 	/**
271 	 * Gets the translate element array.
272 	 * @return Returns a constant reference to the array of translate elements.
273 	 */
getTranslate_array()274 	const domTranslate_Array &getTranslate_array() const { return elemTranslate_array; }
275 	/**
276 	 * Gets the instance_camera element array.
277 	 * @return Returns a reference to the array of instance_camera elements.
278 	 */
getInstance_camera_array()279 	domInstance_camera_Array &getInstance_camera_array() { return elemInstance_camera_array; }
280 	/**
281 	 * Gets the instance_camera element array.
282 	 * @return Returns a constant reference to the array of instance_camera elements.
283 	 */
getInstance_camera_array()284 	const domInstance_camera_Array &getInstance_camera_array() const { return elemInstance_camera_array; }
285 	/**
286 	 * Gets the instance_controller element array.
287 	 * @return Returns a reference to the array of instance_controller elements.
288 	 */
getInstance_controller_array()289 	domInstance_controller_Array &getInstance_controller_array() { return elemInstance_controller_array; }
290 	/**
291 	 * Gets the instance_controller element array.
292 	 * @return Returns a constant reference to the array of instance_controller elements.
293 	 */
getInstance_controller_array()294 	const domInstance_controller_Array &getInstance_controller_array() const { return elemInstance_controller_array; }
295 	/**
296 	 * Gets the instance_geometry element array.
297 	 * @return Returns a reference to the array of instance_geometry elements.
298 	 */
getInstance_geometry_array()299 	domInstance_geometry_Array &getInstance_geometry_array() { return elemInstance_geometry_array; }
300 	/**
301 	 * Gets the instance_geometry element array.
302 	 * @return Returns a constant reference to the array of instance_geometry elements.
303 	 */
getInstance_geometry_array()304 	const domInstance_geometry_Array &getInstance_geometry_array() const { return elemInstance_geometry_array; }
305 	/**
306 	 * Gets the instance_light element array.
307 	 * @return Returns a reference to the array of instance_light elements.
308 	 */
getInstance_light_array()309 	domInstance_light_Array &getInstance_light_array() { return elemInstance_light_array; }
310 	/**
311 	 * Gets the instance_light element array.
312 	 * @return Returns a constant reference to the array of instance_light elements.
313 	 */
getInstance_light_array()314 	const domInstance_light_Array &getInstance_light_array() const { return elemInstance_light_array; }
315 	/**
316 	 * Gets the instance_node element array.
317 	 * @return Returns a reference to the array of instance_node elements.
318 	 */
getInstance_node_array()319 	domInstance_node_Array &getInstance_node_array() { return elemInstance_node_array; }
320 	/**
321 	 * Gets the instance_node element array.
322 	 * @return Returns a constant reference to the array of instance_node elements.
323 	 */
getInstance_node_array()324 	const domInstance_node_Array &getInstance_node_array() const { return elemInstance_node_array; }
325 	/**
326 	 * Gets the node element array.
327 	 * @return Returns a reference to the array of node elements.
328 	 */
getNode_array()329 	domNode_Array &getNode_array() { return elemNode_array; }
330 	/**
331 	 * Gets the node element array.
332 	 * @return Returns a constant reference to the array of node elements.
333 	 */
getNode_array()334 	const domNode_Array &getNode_array() const { return elemNode_array; }
335 	/**
336 	 * Gets the extra element array.
337 	 * @return Returns a reference to the array of extra elements.
338 	 */
getExtra_array()339 	domExtra_Array &getExtra_array() { return elemExtra_array; }
340 	/**
341 	 * Gets the extra element array.
342 	 * @return Returns a constant reference to the array of extra elements.
343 	 */
getExtra_array()344 	const domExtra_Array &getExtra_array() const { return elemExtra_array; }
345 	/**
346 	 * Gets the _contents array.
347 	 * @return Returns a reference to the _contents element array.
348 	 */
getContents()349 	daeElementRefArray &getContents() { return _contents; }
350 	/**
351 	 * Gets the _contents array.
352 	 * @return Returns a constant reference to the _contents element array.
353 	 */
getContents()354 	const daeElementRefArray &getContents() const { return _contents; }
355 
356 protected:
357 	/**
358 	 * Constructor
359 	 */
domNode(DAE & dae)360 	domNode(DAE& dae) : daeElement(dae), attrId(), attrName(), attrSid(), attrType(), attrLayer(), elemAsset(), elemLookat_array(), elemMatrix_array(), elemRotate_array(), elemScale_array(), elemSkew_array(), elemTranslate_array(), elemInstance_camera_array(), elemInstance_controller_array(), elemInstance_geometry_array(), elemInstance_light_array(), elemInstance_node_array(), elemNode_array(), elemExtra_array() {}
361 	/**
362 	 * Destructor
363 	 */
~domNode()364 	virtual ~domNode() { daeElement::deleteCMDataArray(_CMData); }
365 	/**
366 	 * Overloaded assignment operator
367 	 */
368 	virtual domNode &operator=( const domNode &cpy ) { (void)cpy; return *this; }
369 
370 public: // STATIC METHODS
371 	/**
372 	 * Creates an instance of this class and returns a daeElementRef referencing it.
373 	 * @return a daeElementRef referencing an instance of this object.
374 	 */
375 	static DLLSPEC daeElementRef create(DAE& dae);
376 	/**
377 	 * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
378 	 * If a daeMetaElement already exists it will return that instead of creating a new one.
379 	 * @return A daeMetaElement describing this COLLADA element.
380 	 */
381 	static DLLSPEC daeMetaElement* registerElement(DAE& dae);
382 };
383 
384 
385 #endif
386