domNode.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. /*
  2. * Copyright 2006 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
  5. * file except in compliance with the License. You may obtain a copy of the License at:
  6. * http://research.scea.com/scea_shared_source_license.html
  7. *
  8. * Unless required by applicable law or agreed to in writing, software distributed under the License
  9. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing permissions and limitations under the
  11. * License.
  12. */
  13. #ifndef __domNode_h__
  14. #define __domNode_h__
  15. #include <dae/daeDocument.h>
  16. #include <dom/domTypes.h>
  17. #include <dom/domElements.h>
  18. #include <dom/domAsset.h>
  19. #include <dom/domLookat.h>
  20. #include <dom/domMatrix.h>
  21. #include <dom/domRotate.h>
  22. #include <dom/domScale.h>
  23. #include <dom/domSkew.h>
  24. #include <dom/domTranslate.h>
  25. #include <dom/domInstance_camera.h>
  26. #include <dom/domInstance_controller.h>
  27. #include <dom/domInstance_geometry.h>
  28. #include <dom/domInstance_light.h>
  29. #include <dom/domInstance_node.h>
  30. #include <dom/domNode.h>
  31. #include <dom/domExtra.h>
  32. class DAE;
  33. /**
  34. * Nodes embody the hierarchical relationship of elements in the scene.
  35. */
  36. class domNode : public daeElement
  37. {
  38. public:
  39. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::NODE; }
  40. static daeInt ID() { return 681; }
  41. virtual daeInt typeID() const { return ID(); }
  42. protected: // Attributes
  43. /**
  44. * The id attribute is a text string containing the unique identifier of
  45. * this element. This value must be unique within the instance document.
  46. * Optional attribute.
  47. */
  48. xsID attrId;
  49. /**
  50. * The name attribute is the text string name of this element. Optional attribute.
  51. */
  52. xsNCName attrName;
  53. /**
  54. * The sid attribute is a text string value containing the sub-identifier
  55. * of this element. This value must be unique within the scope of the parent
  56. * element. Optional attribute.
  57. */
  58. xsNCName attrSid;
  59. /**
  60. * The type attribute indicates the type of the node element. The default
  61. * value is “NODE”. Optional attribute.
  62. */
  63. domNodeType attrType;
  64. /**
  65. * The layer attribute indicates the names of the layers to which this node
  66. * belongs. For example, a value of “foreground glowing” indicates that
  67. * this node belongs to both the ‘foreground’ layer and the ‘glowing’
  68. * layer. The default value is empty, indicating that the node doesn’t
  69. * belong to any layer. Optional attribute.
  70. */
  71. domListOfNames attrLayer;
  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. * Used to store information needed for some content model objects.
  142. */
  143. daeTArray< daeCharArray * > _CMData;
  144. public: //Accessors and Mutators
  145. /**
  146. * Gets the id attribute.
  147. * @return Returns a xsID of the id attribute.
  148. */
  149. xsID getId() const { return attrId; }
  150. /**
  151. * Sets the id attribute.
  152. * @param atId The new value for the id attribute.
  153. */
  154. void setId( xsID atId ) { *(daeStringRef*)&attrId = atId; _validAttributeArray[0] = true;
  155. if( _document != NULL ) _document->changeElementID( this, attrId );
  156. }
  157. /**
  158. * Gets the name attribute.
  159. * @return Returns a xsNCName of the name attribute.
  160. */
  161. xsNCName getName() const { return attrName; }
  162. /**
  163. * Sets the name attribute.
  164. * @param atName The new value for the name attribute.
  165. */
  166. void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[1] = true; }
  167. /**
  168. * Gets the sid attribute.
  169. * @return Returns a xsNCName of the sid attribute.
  170. */
  171. xsNCName getSid() const { return attrSid; }
  172. /**
  173. * Sets the sid attribute.
  174. * @param atSid The new value for the sid attribute.
  175. */
  176. void setSid( xsNCName atSid ) { *(daeStringRef*)&attrSid = atSid; _validAttributeArray[2] = true; }
  177. /**
  178. * Gets the type attribute.
  179. * @return Returns a domNodeType of the type attribute.
  180. */
  181. domNodeType getType() const { return attrType; }
  182. /**
  183. * Sets the type attribute.
  184. * @param atType The new value for the type attribute.
  185. */
  186. void setType( domNodeType atType ) { attrType = atType; _validAttributeArray[3] = true; }
  187. /**
  188. * Gets the layer array attribute.
  189. * @return Returns a domListOfNames reference of the layer array attribute.
  190. */
  191. domListOfNames &getLayer() { return attrLayer; }
  192. /**
  193. * Gets the layer array attribute.
  194. * @return Returns a constant domListOfNames reference of the layer array attribute.
  195. */
  196. const domListOfNames &getLayer() const { return attrLayer; }
  197. /**
  198. * Sets the layer array attribute.
  199. * @param atLayer The new value for the layer array attribute.
  200. */
  201. void setLayer( const domListOfNames &atLayer ) { attrLayer = atLayer; _validAttributeArray[4] = true; }
  202. /**
  203. * Gets the asset element.
  204. * @return a daeSmartRef to the asset element.
  205. */
  206. const domAssetRef getAsset() const { return elemAsset; }
  207. /**
  208. * Gets the lookat element array.
  209. * @return Returns a reference to the array of lookat elements.
  210. */
  211. domLookat_Array &getLookat_array() { return elemLookat_array; }
  212. /**
  213. * Gets the lookat element array.
  214. * @return Returns a constant reference to the array of lookat elements.
  215. */
  216. const domLookat_Array &getLookat_array() const { return elemLookat_array; }
  217. /**
  218. * Gets the matrix element array.
  219. * @return Returns a reference to the array of matrix elements.
  220. */
  221. domMatrix_Array &getMatrix_array() { return elemMatrix_array; }
  222. /**
  223. * Gets the matrix element array.
  224. * @return Returns a constant reference to the array of matrix elements.
  225. */
  226. const domMatrix_Array &getMatrix_array() const { return elemMatrix_array; }
  227. /**
  228. * Gets the rotate element array.
  229. * @return Returns a reference to the array of rotate elements.
  230. */
  231. domRotate_Array &getRotate_array() { return elemRotate_array; }
  232. /**
  233. * Gets the rotate element array.
  234. * @return Returns a constant reference to the array of rotate elements.
  235. */
  236. const domRotate_Array &getRotate_array() const { return elemRotate_array; }
  237. /**
  238. * Gets the scale element array.
  239. * @return Returns a reference to the array of scale elements.
  240. */
  241. domScale_Array &getScale_array() { return elemScale_array; }
  242. /**
  243. * Gets the scale element array.
  244. * @return Returns a constant reference to the array of scale elements.
  245. */
  246. const domScale_Array &getScale_array() const { return elemScale_array; }
  247. /**
  248. * Gets the skew element array.
  249. * @return Returns a reference to the array of skew elements.
  250. */
  251. domSkew_Array &getSkew_array() { return elemSkew_array; }
  252. /**
  253. * Gets the skew element array.
  254. * @return Returns a constant reference to the array of skew elements.
  255. */
  256. const domSkew_Array &getSkew_array() const { return elemSkew_array; }
  257. /**
  258. * Gets the translate element array.
  259. * @return Returns a reference to the array of translate elements.
  260. */
  261. domTranslate_Array &getTranslate_array() { return elemTranslate_array; }
  262. /**
  263. * Gets the translate element array.
  264. * @return Returns a constant reference to the array of translate elements.
  265. */
  266. const domTranslate_Array &getTranslate_array() const { return elemTranslate_array; }
  267. /**
  268. * Gets the instance_camera element array.
  269. * @return Returns a reference to the array of instance_camera elements.
  270. */
  271. domInstance_camera_Array &getInstance_camera_array() { return elemInstance_camera_array; }
  272. /**
  273. * Gets the instance_camera element array.
  274. * @return Returns a constant reference to the array of instance_camera elements.
  275. */
  276. const domInstance_camera_Array &getInstance_camera_array() const { return elemInstance_camera_array; }
  277. /**
  278. * Gets the instance_controller element array.
  279. * @return Returns a reference to the array of instance_controller elements.
  280. */
  281. domInstance_controller_Array &getInstance_controller_array() { return elemInstance_controller_array; }
  282. /**
  283. * Gets the instance_controller element array.
  284. * @return Returns a constant reference to the array of instance_controller elements.
  285. */
  286. const domInstance_controller_Array &getInstance_controller_array() const { return elemInstance_controller_array; }
  287. /**
  288. * Gets the instance_geometry element array.
  289. * @return Returns a reference to the array of instance_geometry elements.
  290. */
  291. domInstance_geometry_Array &getInstance_geometry_array() { return elemInstance_geometry_array; }
  292. /**
  293. * Gets the instance_geometry element array.
  294. * @return Returns a constant reference to the array of instance_geometry elements.
  295. */
  296. const domInstance_geometry_Array &getInstance_geometry_array() const { return elemInstance_geometry_array; }
  297. /**
  298. * Gets the instance_light element array.
  299. * @return Returns a reference to the array of instance_light elements.
  300. */
  301. domInstance_light_Array &getInstance_light_array() { return elemInstance_light_array; }
  302. /**
  303. * Gets the instance_light element array.
  304. * @return Returns a constant reference to the array of instance_light elements.
  305. */
  306. const domInstance_light_Array &getInstance_light_array() const { return elemInstance_light_array; }
  307. /**
  308. * Gets the instance_node element array.
  309. * @return Returns a reference to the array of instance_node elements.
  310. */
  311. domInstance_node_Array &getInstance_node_array() { return elemInstance_node_array; }
  312. /**
  313. * Gets the instance_node element array.
  314. * @return Returns a constant reference to the array of instance_node elements.
  315. */
  316. const domInstance_node_Array &getInstance_node_array() const { return elemInstance_node_array; }
  317. /**
  318. * Gets the node element array.
  319. * @return Returns a reference to the array of node elements.
  320. */
  321. domNode_Array &getNode_array() { return elemNode_array; }
  322. /**
  323. * Gets the node element array.
  324. * @return Returns a constant reference to the array of node elements.
  325. */
  326. const domNode_Array &getNode_array() const { return elemNode_array; }
  327. /**
  328. * Gets the extra element array.
  329. * @return Returns a reference to the array of extra elements.
  330. */
  331. domExtra_Array &getExtra_array() { return elemExtra_array; }
  332. /**
  333. * Gets the extra element array.
  334. * @return Returns a constant reference to the array of extra elements.
  335. */
  336. const domExtra_Array &getExtra_array() const { return elemExtra_array; }
  337. /**
  338. * Gets the _contents array.
  339. * @return Returns a reference to the _contents element array.
  340. */
  341. daeElementRefArray &getContents() { return _contents; }
  342. /**
  343. * Gets the _contents array.
  344. * @return Returns a constant reference to the _contents element array.
  345. */
  346. const daeElementRefArray &getContents() const { return _contents; }
  347. protected:
  348. /**
  349. * Constructor
  350. */
  351. 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() {}
  352. /**
  353. * Destructor
  354. */
  355. virtual ~domNode() { daeElement::deleteCMDataArray(_CMData); }
  356. /**
  357. * Overloaded assignment operator
  358. */
  359. virtual domNode &operator=( const domNode &cpy ) { (void)cpy; return *this; }
  360. public: // STATIC METHODS
  361. /**
  362. * Creates an instance of this class and returns a daeElementRef referencing it.
  363. * @return a daeElementRef referencing an instance of this object.
  364. */
  365. static DLLSPEC daeElementRef create(DAE& dae);
  366. /**
  367. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  368. * If a daeMetaElement already exists it will return that instead of creating a new one.
  369. * @return A daeMetaElement describing this COLLADA element.
  370. */
  371. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  372. };
  373. #endif