domPolygons.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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 __domPolygons_h__
  14. #define __domPolygons_h__
  15. #include <dae/daeDocument.h>
  16. #include <dom/domTypes.h>
  17. #include <dom/domElements.h>
  18. #include <dom/domP.h>
  19. #include <dom/domExtra.h>
  20. #include <dom/domInputLocalOffset.h>
  21. class DAE;
  22. /**
  23. * The polygons element provides the information needed to bind vertex attributes
  24. * together and then organize those vertices into individual polygons. The
  25. * polygons described can contain arbitrary numbers of vertices. These polygons
  26. * may be self intersecting and may also contain holes.
  27. */
  28. class domPolygons : public daeElement
  29. {
  30. public:
  31. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::POLYGONS; }
  32. static daeInt ID() { return 620; }
  33. virtual daeInt typeID() const { return ID(); }
  34. public:
  35. class domPh;
  36. typedef daeSmartRef<domPh> domPhRef;
  37. typedef daeTArray<domPhRef> domPh_Array;
  38. /**
  39. * The ph element descripes a polygon with holes.
  40. */
  41. class domPh : public daeElement
  42. {
  43. public:
  44. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::PH; }
  45. static daeInt ID() { return 621; }
  46. virtual daeInt typeID() const { return ID(); }
  47. public:
  48. class domH;
  49. typedef daeSmartRef<domH> domHRef;
  50. typedef daeTArray<domHRef> domH_Array;
  51. /**
  52. * The h element represents a hole in the polygon specified. There must be
  53. * at least one h element.
  54. */
  55. class domH : public daeElement
  56. {
  57. public:
  58. virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::H; }
  59. static daeInt ID() { return 622; }
  60. virtual daeInt typeID() const { return ID(); }
  61. protected: // Value
  62. /**
  63. * The domListOfUInts value of the text data of this element.
  64. */
  65. domListOfUInts _value;
  66. public: //Accessors and Mutators
  67. /**
  68. * Gets the _value array.
  69. * @return Returns a domListOfUInts reference of the _value array.
  70. */
  71. domListOfUInts &getValue() { return _value; }
  72. /**
  73. * Gets the _value array.
  74. * @return Returns a constant domListOfUInts reference of the _value array.
  75. */
  76. const domListOfUInts &getValue() const { return _value; }
  77. /**
  78. * Sets the _value array.
  79. * @param val The new value for the _value array.
  80. */
  81. void setValue( const domListOfUInts &val ) { _value = val; }
  82. protected:
  83. /**
  84. * Constructor
  85. */
  86. domH(DAE& dae) : daeElement(dae), _value() {}
  87. /**
  88. * Destructor
  89. */
  90. virtual ~domH() {}
  91. /**
  92. * Overloaded assignment operator
  93. */
  94. virtual domH &operator=( const domH &cpy ) { (void)cpy; return *this; }
  95. public: // STATIC METHODS
  96. /**
  97. * Creates an instance of this class and returns a daeElementRef referencing it.
  98. * @return a daeElementRef referencing an instance of this object.
  99. */
  100. static DLLSPEC daeElementRef create(DAE& dae);
  101. /**
  102. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  103. * If a daeMetaElement already exists it will return that instead of creating a new one.
  104. * @return A daeMetaElement describing this COLLADA element.
  105. */
  106. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  107. };
  108. protected: // Elements
  109. /**
  110. * Theere may only be one p element. @see domP
  111. */
  112. domPRef elemP;
  113. /**
  114. * The h element represents a hole in the polygon specified. There must be
  115. * at least one h element. @see domH
  116. */
  117. domH_Array elemH_array;
  118. public: //Accessors and Mutators
  119. /**
  120. * Gets the p element.
  121. * @return a daeSmartRef to the p element.
  122. */
  123. const domPRef getP() const { return elemP; }
  124. /**
  125. * Gets the h element array.
  126. * @return Returns a reference to the array of h elements.
  127. */
  128. domH_Array &getH_array() { return elemH_array; }
  129. /**
  130. * Gets the h element array.
  131. * @return Returns a constant reference to the array of h elements.
  132. */
  133. const domH_Array &getH_array() const { return elemH_array; }
  134. protected:
  135. /**
  136. * Constructor
  137. */
  138. domPh(DAE& dae) : daeElement(dae), elemP(), elemH_array() {}
  139. /**
  140. * Destructor
  141. */
  142. virtual ~domPh() {}
  143. /**
  144. * Overloaded assignment operator
  145. */
  146. virtual domPh &operator=( const domPh &cpy ) { (void)cpy; return *this; }
  147. public: // STATIC METHODS
  148. /**
  149. * Creates an instance of this class and returns a daeElementRef referencing it.
  150. * @return a daeElementRef referencing an instance of this object.
  151. */
  152. static DLLSPEC daeElementRef create(DAE& dae);
  153. /**
  154. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  155. * If a daeMetaElement already exists it will return that instead of creating a new one.
  156. * @return A daeMetaElement describing this COLLADA element.
  157. */
  158. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  159. };
  160. protected: // Attributes
  161. /**
  162. * The name attribute is the text string name of this element. Optional attribute.
  163. */
  164. xsNCName attrName;
  165. /**
  166. * The count attribute indicates the number of polygon primitives. Required
  167. * attribute.
  168. */
  169. domUint attrCount;
  170. /**
  171. * The material attribute declares a symbol for a material. This symbol is
  172. * bound to a material at the time of instantiation. If the material attribute
  173. * is not specified then the lighting and shading results are application
  174. * defined. Optional attribute.
  175. */
  176. xsNCName attrMaterial;
  177. protected: // Elements
  178. /**
  179. * The input element may occur any number of times. This input is a local
  180. * input with the offset and set attributes. @see domInput
  181. */
  182. domInputLocalOffset_Array elemInput_array;
  183. /**
  184. * The p element may occur any number of times. @see domP
  185. */
  186. domP_Array elemP_array;
  187. /**
  188. * The ph element descripes a polygon with holes. @see domPh
  189. */
  190. domPh_Array elemPh_array;
  191. /**
  192. * The extra element may appear any number of times. @see domExtra
  193. */
  194. domExtra_Array elemExtra_array;
  195. /**
  196. * Used to preserve order in elements that do not specify strict sequencing of sub-elements.
  197. */
  198. daeElementRefArray _contents;
  199. /**
  200. * Used to preserve order in elements that have a complex content model.
  201. */
  202. daeUIntArray _contentsOrder;
  203. /**
  204. * Used to store information needed for some content model objects.
  205. */
  206. daeTArray< daeCharArray * > _CMData;
  207. public: //Accessors and Mutators
  208. /**
  209. * Gets the name attribute.
  210. * @return Returns a xsNCName of the name attribute.
  211. */
  212. xsNCName getName() const { return attrName; }
  213. /**
  214. * Sets the name attribute.
  215. * @param atName The new value for the name attribute.
  216. */
  217. void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[0] = true; }
  218. /**
  219. * Gets the count attribute.
  220. * @return Returns a domUint of the count attribute.
  221. */
  222. domUint getCount() const { return attrCount; }
  223. /**
  224. * Sets the count attribute.
  225. * @param atCount The new value for the count attribute.
  226. */
  227. void setCount( domUint atCount ) { attrCount = atCount; _validAttributeArray[1] = true; }
  228. /**
  229. * Gets the material attribute.
  230. * @return Returns a xsNCName of the material attribute.
  231. */
  232. xsNCName getMaterial() const { return attrMaterial; }
  233. /**
  234. * Sets the material attribute.
  235. * @param atMaterial The new value for the material attribute.
  236. */
  237. void setMaterial( xsNCName atMaterial ) { *(daeStringRef*)&attrMaterial = atMaterial; _validAttributeArray[2] = true; }
  238. /**
  239. * Gets the input element array.
  240. * @return Returns a reference to the array of input elements.
  241. */
  242. domInputLocalOffset_Array &getInput_array() { return elemInput_array; }
  243. /**
  244. * Gets the input element array.
  245. * @return Returns a constant reference to the array of input elements.
  246. */
  247. const domInputLocalOffset_Array &getInput_array() const { return elemInput_array; }
  248. /**
  249. * Gets the p element array.
  250. * @return Returns a reference to the array of p elements.
  251. */
  252. domP_Array &getP_array() { return elemP_array; }
  253. /**
  254. * Gets the p element array.
  255. * @return Returns a constant reference to the array of p elements.
  256. */
  257. const domP_Array &getP_array() const { return elemP_array; }
  258. /**
  259. * Gets the ph element array.
  260. * @return Returns a reference to the array of ph elements.
  261. */
  262. domPh_Array &getPh_array() { return elemPh_array; }
  263. /**
  264. * Gets the ph element array.
  265. * @return Returns a constant reference to the array of ph elements.
  266. */
  267. const domPh_Array &getPh_array() const { return elemPh_array; }
  268. /**
  269. * Gets the extra element array.
  270. * @return Returns a reference to the array of extra elements.
  271. */
  272. domExtra_Array &getExtra_array() { return elemExtra_array; }
  273. /**
  274. * Gets the extra element array.
  275. * @return Returns a constant reference to the array of extra elements.
  276. */
  277. const domExtra_Array &getExtra_array() const { return elemExtra_array; }
  278. /**
  279. * Gets the _contents array.
  280. * @return Returns a reference to the _contents element array.
  281. */
  282. daeElementRefArray &getContents() { return _contents; }
  283. /**
  284. * Gets the _contents array.
  285. * @return Returns a constant reference to the _contents element array.
  286. */
  287. const daeElementRefArray &getContents() const { return _contents; }
  288. protected:
  289. /**
  290. * Constructor
  291. */
  292. domPolygons(DAE& dae) : daeElement(dae), attrName(), attrCount(), attrMaterial(), elemInput_array(), elemP_array(), elemPh_array(), elemExtra_array() {}
  293. /**
  294. * Destructor
  295. */
  296. virtual ~domPolygons() { daeElement::deleteCMDataArray(_CMData); }
  297. /**
  298. * Overloaded assignment operator
  299. */
  300. virtual domPolygons &operator=( const domPolygons &cpy ) { (void)cpy; return *this; }
  301. public: // STATIC METHODS
  302. /**
  303. * Creates an instance of this class and returns a daeElementRef referencing it.
  304. * @return a daeElementRef referencing an instance of this object.
  305. */
  306. static DLLSPEC daeElementRef create(DAE& dae);
  307. /**
  308. * Creates a daeMetaElement object that describes this element in the meta object reflection framework.
  309. * If a daeMetaElement already exists it will return that instead of creating a new one.
  310. * @return A daeMetaElement describing this COLLADA element.
  311. */
  312. static DLLSPEC daeMetaElement* registerElement(DAE& dae);
  313. };
  314. #endif