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 #include <dae.h> 10 #include <dae/daeDom.h> 11 #include <dom/domLight.h> 12 #include <dae/daeMetaCMPolicy.h> 13 #include <dae/daeMetaSequence.h> 14 #include <dae/daeMetaChoice.h> 15 #include <dae/daeMetaGroup.h> 16 #include <dae/daeMetaAny.h> 17 #include <dae/daeMetaElementAttribute.h> 18 19 daeElementRef 20 domLight::create(DAE& dae) 21 { 22 domLightRef ref = new domLight(dae); 23 return ref; 24 } 25 26 27 daeMetaElement * 28 domLight::registerElement(DAE& dae) 29 { 30 daeMetaElement* meta = dae.getMeta(ID()); 31 if ( meta != NULL ) return meta; 32 33 meta = new daeMetaElement(dae); 34 dae.setMeta(ID(), *meta); 35 meta->setName( "light" ); 36 meta->registerClass(domLight::create); 37 38 daeMetaCMPolicy *cm = NULL; 39 daeMetaElementAttribute *mea = NULL; 40 cm = new daeMetaSequence( meta, cm, 0, 1, 1 ); 41 42 mea = new daeMetaElementAttribute( meta, cm, 0, 0, 1 ); 43 mea->setName( "asset" ); 44 mea->setOffset( daeOffsetOf(domLight,elemAsset) ); 45 mea->setElementType( domAsset::registerElement(dae) ); 46 cm->appendChild( mea ); 47 48 mea = new daeMetaElementAttribute( meta, cm, 1, 1, 1 ); 49 mea->setName( "technique_common" ); 50 mea->setOffset( daeOffsetOf(domLight,elemTechnique_common) ); 51 mea->setElementType( domLight::domTechnique_common::registerElement(dae) ); 52 cm->appendChild( mea ); 53 54 mea = new daeMetaElementArrayAttribute( meta, cm, 2, 0, -1 ); 55 mea->setName( "technique" ); 56 mea->setOffset( daeOffsetOf(domLight,elemTechnique_array) ); 57 mea->setElementType( domTechnique::registerElement(dae) ); 58 cm->appendChild( mea ); 59 60 mea = new daeMetaElementArrayAttribute( meta, cm, 3, 0, -1 ); 61 mea->setName( "extra" ); 62 mea->setOffset( daeOffsetOf(domLight,elemExtra_array) ); 63 mea->setElementType( domExtra::registerElement(dae) ); 64 cm->appendChild( mea ); 65 66 cm->setMaxOrdinal( 3 ); 67 meta->setCMRoot( cm ); 68 69 // Add attribute: id 70 { 71 daeMetaAttribute *ma = new daeMetaAttribute; 72 ma->setName( "id" ); 73 ma->setType( dae.getAtomicTypes().get("xsID")); 74 ma->setOffset( daeOffsetOf( domLight , attrId )); 75 ma->setContainer( meta ); 76 77 meta->appendAttribute(ma); 78 } 79 80 // Add attribute: name 81 { 82 daeMetaAttribute *ma = new daeMetaAttribute; 83 ma->setName( "name" ); 84 ma->setType( dae.getAtomicTypes().get("xsNCName")); 85 ma->setOffset( daeOffsetOf( domLight , attrName )); 86 ma->setContainer( meta ); 87 88 meta->appendAttribute(ma); 89 } 90 91 meta->setElementSize(sizeof(domLight)); 92 meta->validate(); 93 94 return meta; 95 } 96 97 daeElementRef 98 domLight::domTechnique_common::create(DAE& dae) 99 { 100 domLight::domTechnique_commonRef ref = new domLight::domTechnique_common(dae); 101 return ref; 102 } 103 104 105 daeMetaElement * 106 domLight::domTechnique_common::registerElement(DAE& dae) 107 { 108 daeMetaElement* meta = dae.getMeta(ID()); 109 if ( meta != NULL ) return meta; 110 111 meta = new daeMetaElement(dae); 112 dae.setMeta(ID(), *meta); 113 meta->setName( "technique_common" ); 114 meta->registerClass(domLight::domTechnique_common::create); 115 116 meta->setIsInnerClass( true ); 117 daeMetaCMPolicy *cm = NULL; 118 daeMetaElementAttribute *mea = NULL; 119 cm = new daeMetaChoice( meta, cm, 0, 0, 1, 1 ); 120 121 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 122 mea->setName( "ambient" ); 123 mea->setOffset( daeOffsetOf(domLight::domTechnique_common,elemAmbient) ); 124 mea->setElementType( domLight::domTechnique_common::domAmbient::registerElement(dae) ); 125 cm->appendChild( mea ); 126 127 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 128 mea->setName( "directional" ); 129 mea->setOffset( daeOffsetOf(domLight::domTechnique_common,elemDirectional) ); 130 mea->setElementType( domLight::domTechnique_common::domDirectional::registerElement(dae) ); 131 cm->appendChild( mea ); 132 133 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 134 mea->setName( "point" ); 135 mea->setOffset( daeOffsetOf(domLight::domTechnique_common,elemPoint) ); 136 mea->setElementType( domLight::domTechnique_common::domPoint::registerElement(dae) ); 137 cm->appendChild( mea ); 138 139 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 140 mea->setName( "spot" ); 141 mea->setOffset( daeOffsetOf(domLight::domTechnique_common,elemSpot) ); 142 mea->setElementType( domLight::domTechnique_common::domSpot::registerElement(dae) ); 143 cm->appendChild( mea ); 144 145 cm->setMaxOrdinal( 0 ); 146 meta->setCMRoot( cm ); 147 // Ordered list of sub-elements 148 meta->addContents(daeOffsetOf(domLight::domTechnique_common,_contents)); 149 meta->addContentsOrder(daeOffsetOf(domLight::domTechnique_common,_contentsOrder)); 150 151 meta->addCMDataArray(daeOffsetOf(domLight::domTechnique_common,_CMData), 1); 152 meta->setElementSize(sizeof(domLight::domTechnique_common)); 153 meta->validate(); 154 155 return meta; 156 } 157 158 daeElementRef 159 domLight::domTechnique_common::domAmbient::create(DAE& dae) 160 { 161 domLight::domTechnique_common::domAmbientRef ref = new domLight::domTechnique_common::domAmbient(dae); 162 return ref; 163 } 164 165 166 daeMetaElement * 167 domLight::domTechnique_common::domAmbient::registerElement(DAE& dae) 168 { 169 daeMetaElement* meta = dae.getMeta(ID()); 170 if ( meta != NULL ) return meta; 171 172 meta = new daeMetaElement(dae); 173 dae.setMeta(ID(), *meta); 174 meta->setName( "ambient" ); 175 meta->registerClass(domLight::domTechnique_common::domAmbient::create); 176 177 meta->setIsInnerClass( true ); 178 daeMetaCMPolicy *cm = NULL; 179 daeMetaElementAttribute *mea = NULL; 180 cm = new daeMetaSequence( meta, cm, 0, 1, 1 ); 181 182 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 183 mea->setName( "color" ); 184 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domAmbient,elemColor) ); 185 mea->setElementType( domTargetableFloat3::registerElement(dae) ); 186 cm->appendChild( mea ); 187 188 cm->setMaxOrdinal( 0 ); 189 meta->setCMRoot( cm ); 190 191 meta->setElementSize(sizeof(domLight::domTechnique_common::domAmbient)); 192 meta->validate(); 193 194 return meta; 195 } 196 197 daeElementRef 198 domLight::domTechnique_common::domDirectional::create(DAE& dae) 199 { 200 domLight::domTechnique_common::domDirectionalRef ref = new domLight::domTechnique_common::domDirectional(dae); 201 return ref; 202 } 203 204 205 daeMetaElement * 206 domLight::domTechnique_common::domDirectional::registerElement(DAE& dae) 207 { 208 daeMetaElement* meta = dae.getMeta(ID()); 209 if ( meta != NULL ) return meta; 210 211 meta = new daeMetaElement(dae); 212 dae.setMeta(ID(), *meta); 213 meta->setName( "directional" ); 214 meta->registerClass(domLight::domTechnique_common::domDirectional::create); 215 216 meta->setIsInnerClass( true ); 217 daeMetaCMPolicy *cm = NULL; 218 daeMetaElementAttribute *mea = NULL; 219 cm = new daeMetaSequence( meta, cm, 0, 1, 1 ); 220 221 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 222 mea->setName( "color" ); 223 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domDirectional,elemColor) ); 224 mea->setElementType( domTargetableFloat3::registerElement(dae) ); 225 cm->appendChild( mea ); 226 227 cm->setMaxOrdinal( 0 ); 228 meta->setCMRoot( cm ); 229 230 meta->setElementSize(sizeof(domLight::domTechnique_common::domDirectional)); 231 meta->validate(); 232 233 return meta; 234 } 235 236 daeElementRef 237 domLight::domTechnique_common::domPoint::create(DAE& dae) 238 { 239 domLight::domTechnique_common::domPointRef ref = new domLight::domTechnique_common::domPoint(dae); 240 return ref; 241 } 242 243 244 daeMetaElement * 245 domLight::domTechnique_common::domPoint::registerElement(DAE& dae) 246 { 247 daeMetaElement* meta = dae.getMeta(ID()); 248 if ( meta != NULL ) return meta; 249 250 meta = new daeMetaElement(dae); 251 dae.setMeta(ID(), *meta); 252 meta->setName( "point" ); 253 meta->registerClass(domLight::domTechnique_common::domPoint::create); 254 255 meta->setIsInnerClass( true ); 256 daeMetaCMPolicy *cm = NULL; 257 daeMetaElementAttribute *mea = NULL; 258 cm = new daeMetaSequence( meta, cm, 0, 1, 1 ); 259 260 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 261 mea->setName( "color" ); 262 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domPoint,elemColor) ); 263 mea->setElementType( domTargetableFloat3::registerElement(dae) ); 264 cm->appendChild( mea ); 265 266 mea = new daeMetaElementAttribute( meta, cm, 1, 0, 1 ); 267 mea->setName( "constant_attenuation" ); 268 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domPoint,elemConstant_attenuation) ); 269 mea->setElementType( domTargetableFloat::registerElement(dae) ); 270 cm->appendChild( mea ); 271 272 mea = new daeMetaElementAttribute( meta, cm, 2, 0, 1 ); 273 mea->setName( "linear_attenuation" ); 274 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domPoint,elemLinear_attenuation) ); 275 mea->setElementType( domTargetableFloat::registerElement(dae) ); 276 cm->appendChild( mea ); 277 278 mea = new daeMetaElementAttribute( meta, cm, 3, 0, 1 ); 279 mea->setName( "quadratic_attenuation" ); 280 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domPoint,elemQuadratic_attenuation) ); 281 mea->setElementType( domTargetableFloat::registerElement(dae) ); 282 cm->appendChild( mea ); 283 284 cm->setMaxOrdinal( 3 ); 285 meta->setCMRoot( cm ); 286 287 meta->setElementSize(sizeof(domLight::domTechnique_common::domPoint)); 288 meta->validate(); 289 290 return meta; 291 } 292 293 daeElementRef 294 domLight::domTechnique_common::domSpot::create(DAE& dae) 295 { 296 domLight::domTechnique_common::domSpotRef ref = new domLight::domTechnique_common::domSpot(dae); 297 return ref; 298 } 299 300 301 daeMetaElement * 302 domLight::domTechnique_common::domSpot::registerElement(DAE& dae) 303 { 304 daeMetaElement* meta = dae.getMeta(ID()); 305 if ( meta != NULL ) return meta; 306 307 meta = new daeMetaElement(dae); 308 dae.setMeta(ID(), *meta); 309 meta->setName( "spot" ); 310 meta->registerClass(domLight::domTechnique_common::domSpot::create); 311 312 meta->setIsInnerClass( true ); 313 daeMetaCMPolicy *cm = NULL; 314 daeMetaElementAttribute *mea = NULL; 315 cm = new daeMetaSequence( meta, cm, 0, 1, 1 ); 316 317 mea = new daeMetaElementAttribute( meta, cm, 0, 1, 1 ); 318 mea->setName( "color" ); 319 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domSpot,elemColor) ); 320 mea->setElementType( domTargetableFloat3::registerElement(dae) ); 321 cm->appendChild( mea ); 322 323 mea = new daeMetaElementAttribute( meta, cm, 1, 0, 1 ); 324 mea->setName( "constant_attenuation" ); 325 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domSpot,elemConstant_attenuation) ); 326 mea->setElementType( domTargetableFloat::registerElement(dae) ); 327 cm->appendChild( mea ); 328 329 mea = new daeMetaElementAttribute( meta, cm, 2, 0, 1 ); 330 mea->setName( "linear_attenuation" ); 331 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domSpot,elemLinear_attenuation) ); 332 mea->setElementType( domTargetableFloat::registerElement(dae) ); 333 cm->appendChild( mea ); 334 335 mea = new daeMetaElementAttribute( meta, cm, 3, 0, 1 ); 336 mea->setName( "quadratic_attenuation" ); 337 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domSpot,elemQuadratic_attenuation) ); 338 mea->setElementType( domTargetableFloat::registerElement(dae) ); 339 cm->appendChild( mea ); 340 341 mea = new daeMetaElementAttribute( meta, cm, 4, 0, 1 ); 342 mea->setName( "falloff_angle" ); 343 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domSpot,elemFalloff_angle) ); 344 mea->setElementType( domTargetableFloat::registerElement(dae) ); 345 cm->appendChild( mea ); 346 347 mea = new daeMetaElementAttribute( meta, cm, 5, 0, 1 ); 348 mea->setName( "falloff_exponent" ); 349 mea->setOffset( daeOffsetOf(domLight::domTechnique_common::domSpot,elemFalloff_exponent) ); 350 mea->setElementType( domTargetableFloat::registerElement(dae) ); 351 cm->appendChild( mea ); 352 353 cm->setMaxOrdinal( 5 ); 354 meta->setCMRoot( cm ); 355 356 meta->setElementSize(sizeof(domLight::domTechnique_common::domSpot)); 357 meta->validate(); 358 359 return meta; 360 } 361 362