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 __domLight_h__ 10 #define __domLight_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/domTechnique.h> 18 #include <dom/domExtra.h> 19 #include <dom/domTargetableFloat3.h> 20 #include <dom/domTargetableFloat.h> 21 class DAE; 22 23 /** 24 * The light element declares a light source that illuminates the scene. Light 25 * sources have many different properties and radiate light in many different 26 * patterns and frequencies. 27 */ 28 class domLight : public daeElement 29 { 30 public: 31 virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::LIGHT; } 32 static daeInt ID() { return 638; } 33 virtual daeInt typeID() const { return ID(); } 34 public: 35 class domTechnique_common; 36 37 typedef daeSmartRef<domTechnique_common> domTechnique_commonRef; 38 typedef daeTArray<domTechnique_commonRef> domTechnique_common_Array; 39 40 /** 41 * The technique_common element specifies the light information for the common 42 * profile which all COLLADA implementations need to support. 43 */ 44 class domTechnique_common : public daeElement 45 { 46 public: 47 virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::TECHNIQUE_COMMON; } 48 static daeInt ID() { return 639; } 49 virtual daeInt typeID() const { return ID(); } 50 public: 51 class domAmbient; 52 53 typedef daeSmartRef<domAmbient> domAmbientRef; 54 typedef daeTArray<domAmbientRef> domAmbient_Array; 55 56 /** 57 * The ambient element declares the parameters required to describe an ambient 58 * light source. An ambient light is one that lights everything evenly, 59 * regardless of location or orientation. 60 */ 61 class domAmbient : public daeElement 62 { 63 public: 64 virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::AMBIENT; } 65 static daeInt ID() { return 640; } 66 virtual daeInt typeID() const { return ID(); } 67 68 protected: // Element 69 /** 70 * The color element contains three floating point numbers specifying the 71 * color of the light. The color element must occur exactly once. @see domColor 72 */ 73 domTargetableFloat3Ref elemColor; 74 75 public: //Accessors and Mutators 76 /** 77 * Gets the color element. 78 * @return a daeSmartRef to the color element. 79 */ 80 const domTargetableFloat3Ref getColor() const { return elemColor; } 81 protected: 82 /** 83 * Constructor 84 */ 85 domAmbient(DAE& dae) : daeElement(dae), elemColor() {} 86 /** 87 * Destructor 88 */ 89 virtual ~domAmbient() {} 90 /** 91 * Overloaded assignment operator 92 */ 93 virtual domAmbient &operator=( const domAmbient &cpy ) { (void)cpy; return *this; } 94 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 109 class domDirectional; 110 111 typedef daeSmartRef<domDirectional> domDirectionalRef; 112 typedef daeTArray<domDirectionalRef> domDirectional_Array; 113 114 /** 115 * The directional element declares the parameters required to describe a 116 * directional light source. A directional light is one that lights everything 117 * from the same direction, regardless of location. The lights default 118 * direction vector in local coordinates is [0,0,-1], pointing down the -Z 119 * axis. The actual direction of the light is defined by the transform of 120 * the node where the light is instantiated. 121 */ 122 class domDirectional : public daeElement 123 { 124 public: 125 virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::DIRECTIONAL; } 126 static daeInt ID() { return 641; } 127 virtual daeInt typeID() const { return ID(); } 128 129 protected: // Element 130 /** 131 * The color element contains three floating point numbers specifying the 132 * color of the light. The color element must occur exactly once. @see domColor 133 */ 134 domTargetableFloat3Ref elemColor; 135 136 public: //Accessors and Mutators 137 /** 138 * Gets the color element. 139 * @return a daeSmartRef to the color element. 140 */ 141 const domTargetableFloat3Ref getColor() const { return elemColor; } 142 protected: 143 /** 144 * Constructor 145 */ 146 domDirectional(DAE& dae) : daeElement(dae), elemColor() {} 147 /** 148 * Destructor 149 */ 150 virtual ~domDirectional() {} 151 /** 152 * Overloaded assignment operator 153 */ 154 virtual domDirectional &operator=( const domDirectional &cpy ) { (void)cpy; return *this; } 155 156 public: // STATIC METHODS 157 /** 158 * Creates an instance of this class and returns a daeElementRef referencing it. 159 * @return a daeElementRef referencing an instance of this object. 160 */ 161 static DLLSPEC daeElementRef create(DAE& dae); 162 /** 163 * Creates a daeMetaElement object that describes this element in the meta object reflection framework. 164 * If a daeMetaElement already exists it will return that instead of creating a new one. 165 * @return A daeMetaElement describing this COLLADA element. 166 */ 167 static DLLSPEC daeMetaElement* registerElement(DAE& dae); 168 }; 169 170 class domPoint; 171 172 typedef daeSmartRef<domPoint> domPointRef; 173 typedef daeTArray<domPointRef> domPoint_Array; 174 175 /** 176 * The point element declares the parameters required to describe a point 177 * light source. A point light source radiates light in all directions from 178 * a known location in space. The intensity of a point light source is attenuated 179 * as the distance to the light source increases. The position of the light 180 * is defined by the transform of the node in which it is instantiated. 181 */ 182 class domPoint : public daeElement 183 { 184 public: 185 virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::POINT; } 186 static daeInt ID() { return 642; } 187 virtual daeInt typeID() const { return ID(); } 188 189 protected: // Elements 190 /** 191 * The color element contains three floating point numbers specifying the 192 * color of the light. The color element must occur exactly once. @see domColor 193 */ 194 domTargetableFloat3Ref elemColor; 195 /** 196 * The constant_attenuation is used to calculate the total attenuation of 197 * this light given a distance. The equation used is A = constant_attenuation 198 * + Dist*linear_attenuation + Dist^2*quadratic_attenuation. @see domConstant_attenuation 199 */ 200 domTargetableFloatRef elemConstant_attenuation; 201 /** 202 * The linear_attenuation is used to calculate the total attenuation of this 203 * light given a distance. The equation used is A = constant_attenuation 204 * + Dist*linear_attenuation + Dist^2*quadratic_attenuation. @see domLinear_attenuation 205 */ 206 domTargetableFloatRef elemLinear_attenuation; 207 /** 208 * The quadratic_attenuation is used to calculate the total attenuation of 209 * this light given a distance. The equation used is A = constant_attenuation 210 * + Dist*linear_attenuation + Dist^2*quadratic_attenuation. @see domQuadratic_attenuation 211 */ 212 domTargetableFloatRef elemQuadratic_attenuation; 213 214 public: //Accessors and Mutators 215 /** 216 * Gets the color element. 217 * @return a daeSmartRef to the color element. 218 */ 219 const domTargetableFloat3Ref getColor() const { return elemColor; } 220 /** 221 * Gets the constant_attenuation element. 222 * @return a daeSmartRef to the constant_attenuation element. 223 */ 224 const domTargetableFloatRef getConstant_attenuation() const { return elemConstant_attenuation; } 225 /** 226 * Gets the linear_attenuation element. 227 * @return a daeSmartRef to the linear_attenuation element. 228 */ 229 const domTargetableFloatRef getLinear_attenuation() const { return elemLinear_attenuation; } 230 /** 231 * Gets the quadratic_attenuation element. 232 * @return a daeSmartRef to the quadratic_attenuation element. 233 */ 234 const domTargetableFloatRef getQuadratic_attenuation() const { return elemQuadratic_attenuation; } 235 protected: 236 /** 237 * Constructor 238 */ 239 domPoint(DAE& dae) : daeElement(dae), elemColor(), elemConstant_attenuation(), elemLinear_attenuation(), elemQuadratic_attenuation() {} 240 /** 241 * Destructor 242 */ 243 virtual ~domPoint() {} 244 /** 245 * Overloaded assignment operator 246 */ 247 virtual domPoint &operator=( const domPoint &cpy ) { (void)cpy; return *this; } 248 249 public: // STATIC METHODS 250 /** 251 * Creates an instance of this class and returns a daeElementRef referencing it. 252 * @return a daeElementRef referencing an instance of this object. 253 */ 254 static DLLSPEC daeElementRef create(DAE& dae); 255 /** 256 * Creates a daeMetaElement object that describes this element in the meta object reflection framework. 257 * If a daeMetaElement already exists it will return that instead of creating a new one. 258 * @return A daeMetaElement describing this COLLADA element. 259 */ 260 static DLLSPEC daeMetaElement* registerElement(DAE& dae); 261 }; 262 263 class domSpot; 264 265 typedef daeSmartRef<domSpot> domSpotRef; 266 typedef daeTArray<domSpotRef> domSpot_Array; 267 268 /** 269 * The spot element declares the parameters required to describe a spot light 270 * source. A spot light source radiates light in one direction from a known 271 * location in space. The light radiates from the spot light source in a 272 * cone shape. The intensity of the light is attenuated as the radiation 273 * angle increases away from the direction of the light source. The intensity 274 * of a spot light source is also attenuated as the distance to the light 275 * source increases. The position of the light is defined by the transform 276 * of the node in which it is instantiated. The lights default direction 277 * vector in local coordinates is [0,0,-1], pointing down the -Z axis. The 278 * actual direction of the light is defined by the transform of the node 279 * where the light is instantiated. 280 */ 281 class domSpot : public daeElement 282 { 283 public: 284 virtual COLLADA_TYPE::TypeEnum getElementType() const { return COLLADA_TYPE::SPOT; } 285 static daeInt ID() { return 643; } 286 virtual daeInt typeID() const { return ID(); } 287 288 protected: // Elements 289 /** 290 * The color element contains three floating point numbers specifying the 291 * color of the light. The color element must occur exactly once. @see domColor 292 */ 293 domTargetableFloat3Ref elemColor; 294 /** 295 * The constant_attenuation is used to calculate the total attenuation of 296 * this light given a distance. The equation used is A = constant_attenuation 297 * + Dist*linear_attenuation + Dist^2*quadratic_attenuation. @see domConstant_attenuation 298 */ 299 domTargetableFloatRef elemConstant_attenuation; 300 /** 301 * The linear_attenuation is used to calculate the total attenuation of this 302 * light given a distance. The equation used is A = constant_attenuation 303 * + Dist*linear_attenuation + Dist^2*quadratic_attenuation. @see domLinear_attenuation 304 */ 305 domTargetableFloatRef elemLinear_attenuation; 306 /** 307 * The quadratic_attenuation is used to calculate the total attenuation of 308 * this light given a distance. The equation used is A = constant_attenuation 309 * + Dist*linear_attenuation + Dist^2*quadratic_attenuation. @see domQuadratic_attenuation 310 */ 311 domTargetableFloatRef elemQuadratic_attenuation; 312 /** 313 * The falloff_angle is used to specify the amount of attenuation based on 314 * the direction of the light. @see domFalloff_angle 315 */ 316 domTargetableFloatRef elemFalloff_angle; 317 /** 318 * The falloff_exponent is used to specify the amount of attenuation based 319 * on the direction of the light. @see domFalloff_exponent 320 */ 321 domTargetableFloatRef elemFalloff_exponent; 322 323 public: //Accessors and Mutators 324 /** 325 * Gets the color element. 326 * @return a daeSmartRef to the color element. 327 */ 328 const domTargetableFloat3Ref getColor() const { return elemColor; } 329 /** 330 * Gets the constant_attenuation element. 331 * @return a daeSmartRef to the constant_attenuation element. 332 */ 333 const domTargetableFloatRef getConstant_attenuation() const { return elemConstant_attenuation; } 334 /** 335 * Gets the linear_attenuation element. 336 * @return a daeSmartRef to the linear_attenuation element. 337 */ 338 const domTargetableFloatRef getLinear_attenuation() const { return elemLinear_attenuation; } 339 /** 340 * Gets the quadratic_attenuation element. 341 * @return a daeSmartRef to the quadratic_attenuation element. 342 */ 343 const domTargetableFloatRef getQuadratic_attenuation() const { return elemQuadratic_attenuation; } 344 /** 345 * Gets the falloff_angle element. 346 * @return a daeSmartRef to the falloff_angle element. 347 */ 348 const domTargetableFloatRef getFalloff_angle() const { return elemFalloff_angle; } 349 /** 350 * Gets the falloff_exponent element. 351 * @return a daeSmartRef to the falloff_exponent element. 352 */ 353 const domTargetableFloatRef getFalloff_exponent() const { return elemFalloff_exponent; } 354 protected: 355 /** 356 * Constructor 357 */ 358 domSpot(DAE& dae) : daeElement(dae), elemColor(), elemConstant_attenuation(), elemLinear_attenuation(), elemQuadratic_attenuation(), elemFalloff_angle(), elemFalloff_exponent() {} 359 /** 360 * Destructor 361 */ 362 virtual ~domSpot() {} 363 /** 364 * Overloaded assignment operator 365 */ 366 virtual domSpot &operator=( const domSpot &cpy ) { (void)cpy; return *this; } 367 368 public: // STATIC METHODS 369 /** 370 * Creates an instance of this class and returns a daeElementRef referencing it. 371 * @return a daeElementRef referencing an instance of this object. 372 */ 373 static DLLSPEC daeElementRef create(DAE& dae); 374 /** 375 * Creates a daeMetaElement object that describes this element in the meta object reflection framework. 376 * If a daeMetaElement already exists it will return that instead of creating a new one. 377 * @return A daeMetaElement describing this COLLADA element. 378 */ 379 static DLLSPEC daeMetaElement* registerElement(DAE& dae); 380 }; 381 382 383 384 protected: // Elements 385 /** 386 * The ambient element declares the parameters required to describe an ambient 387 * light source. An ambient light is one that lights everything evenly, 388 * regardless of location or orientation. @see domAmbient 389 */ 390 domAmbientRef elemAmbient; 391 /** 392 * The directional element declares the parameters required to describe a 393 * directional light source. A directional light is one that lights everything 394 * from the same direction, regardless of location. The lights default 395 * direction vector in local coordinates is [0,0,-1], pointing down the -Z 396 * axis. The actual direction of the light is defined by the transform of 397 * the node where the light is instantiated. @see domDirectional 398 */ 399 domDirectionalRef elemDirectional; 400 /** 401 * The point element declares the parameters required to describe a point 402 * light source. A point light source radiates light in all directions from 403 * a known location in space. The intensity of a point light source is attenuated 404 * as the distance to the light source increases. The position of the light 405 * is defined by the transform of the node in which it is instantiated. @see 406 * domPoint 407 */ 408 domPointRef elemPoint; 409 /** 410 * The spot element declares the parameters required to describe a spot light 411 * source. A spot light source radiates light in one direction from a known 412 * location in space. The light radiates from the spot light source in a 413 * cone shape. The intensity of the light is attenuated as the radiation 414 * angle increases away from the direction of the light source. The intensity 415 * of a spot light source is also attenuated as the distance to the light 416 * source increases. The position of the light is defined by the transform 417 * of the node in which it is instantiated. The lights default direction 418 * vector in local coordinates is [0,0,-1], pointing down the -Z axis. The 419 * actual direction of the light is defined by the transform of the node 420 * where the light is instantiated. @see domSpot 421 */ 422 domSpotRef elemSpot; 423 /** 424 * Used to preserve order in elements that do not specify strict sequencing of sub-elements. 425 */ 426 daeElementRefArray _contents; 427 /** 428 * Used to preserve order in elements that have a complex content model. 429 */ 430 daeUIntArray _contentsOrder; 431 432 /** 433 * Used to store information needed for some content model objects. 434 */ 435 daeTArray< daeCharArray * > _CMData; 436 437 438 public: //Accessors and Mutators 439 /** 440 * Gets the ambient element. 441 * @return a daeSmartRef to the ambient element. 442 */ 443 const domAmbientRef getAmbient() const { return elemAmbient; } 444 /** 445 * Gets the directional element. 446 * @return a daeSmartRef to the directional element. 447 */ 448 const domDirectionalRef getDirectional() const { return elemDirectional; } 449 /** 450 * Gets the point element. 451 * @return a daeSmartRef to the point element. 452 */ 453 const domPointRef getPoint() const { return elemPoint; } 454 /** 455 * Gets the spot element. 456 * @return a daeSmartRef to the spot element. 457 */ 458 const domSpotRef getSpot() const { return elemSpot; } 459 /** 460 * Gets the _contents array. 461 * @return Returns a reference to the _contents element array. 462 */ 463 daeElementRefArray &getContents() { return _contents; } 464 /** 465 * Gets the _contents array. 466 * @return Returns a constant reference to the _contents element array. 467 */ 468 const daeElementRefArray &getContents() const { return _contents; } 469 470 protected: 471 /** 472 * Constructor 473 */ 474 domTechnique_common(DAE& dae) : daeElement(dae), elemAmbient(), elemDirectional(), elemPoint(), elemSpot() {} 475 /** 476 * Destructor 477 */ 478 virtual ~domTechnique_common() { daeElement::deleteCMDataArray(_CMData); } 479 /** 480 * Overloaded assignment operator 481 */ 482 virtual domTechnique_common &operator=( const domTechnique_common &cpy ) { (void)cpy; return *this; } 483 484 public: // STATIC METHODS 485 /** 486 * Creates an instance of this class and returns a daeElementRef referencing it. 487 * @return a daeElementRef referencing an instance of this object. 488 */ 489 static DLLSPEC daeElementRef create(DAE& dae); 490 /** 491 * Creates a daeMetaElement object that describes this element in the meta object reflection framework. 492 * If a daeMetaElement already exists it will return that instead of creating a new one. 493 * @return A daeMetaElement describing this COLLADA element. 494 */ 495 static DLLSPEC daeMetaElement* registerElement(DAE& dae); 496 }; 497 498 499 protected: // Attributes 500 /** 501 * The id attribute is a text string containing the unique identifier of 502 * this element. This value must be unique within the instance document. 503 * Optional attribute. 504 */ 505 xsID attrId; 506 /** 507 * The name attribute is the text string name of this element. Optional attribute. 508 */ 509 xsNCName attrName; 510 511 protected: // Elements 512 /** 513 * The light element may contain an asset element. @see domAsset 514 */ 515 domAssetRef elemAsset; 516 /** 517 * The technique_common element specifies the light information for the common 518 * profile which all COLLADA implementations need to support. @see domTechnique_common 519 */ 520 domTechnique_commonRef elemTechnique_common; 521 /** 522 * This element may contain any number of non-common profile techniques. 523 * @see domTechnique 524 */ 525 domTechnique_Array elemTechnique_array; 526 /** 527 * The extra element may appear any number of times. @see domExtra 528 */ 529 domExtra_Array elemExtra_array; 530 531 public: //Accessors and Mutators 532 /** 533 * Gets the id attribute. 534 * @return Returns a xsID of the id attribute. 535 */ 536 xsID getId() const { return attrId; } 537 /** 538 * Sets the id attribute. 539 * @param atId The new value for the id attribute. 540 */ 541 void setId( xsID atId ) { *(daeStringRef*)&attrId = atId; _validAttributeArray[0] = true; 542 if( _document != NULL ) _document->changeElementID( this, attrId ); 543 } 544 545 /** 546 * Gets the name attribute. 547 * @return Returns a xsNCName of the name attribute. 548 */ 549 xsNCName getName() const { return attrName; } 550 /** 551 * Sets the name attribute. 552 * @param atName The new value for the name attribute. 553 */ 554 void setName( xsNCName atName ) { *(daeStringRef*)&attrName = atName; _validAttributeArray[1] = true; } 555 556 /** 557 * Gets the asset element. 558 * @return a daeSmartRef to the asset element. 559 */ 560 const domAssetRef getAsset() const { return elemAsset; } 561 /** 562 * Gets the technique_common element. 563 * @return a daeSmartRef to the technique_common element. 564 */ 565 const domTechnique_commonRef getTechnique_common() const { return elemTechnique_common; } 566 /** 567 * Gets the technique element array. 568 * @return Returns a reference to the array of technique elements. 569 */ 570 domTechnique_Array &getTechnique_array() { return elemTechnique_array; } 571 /** 572 * Gets the technique element array. 573 * @return Returns a constant reference to the array of technique elements. 574 */ 575 const domTechnique_Array &getTechnique_array() const { return elemTechnique_array; } 576 /** 577 * Gets the extra element array. 578 * @return Returns a reference to the array of extra elements. 579 */ 580 domExtra_Array &getExtra_array() { return elemExtra_array; } 581 /** 582 * Gets the extra element array. 583 * @return Returns a constant reference to the array of extra elements. 584 */ 585 const domExtra_Array &getExtra_array() const { return elemExtra_array; } 586 protected: 587 /** 588 * Constructor 589 */ 590 domLight(DAE& dae) : daeElement(dae), attrId(), attrName(), elemAsset(), elemTechnique_common(), elemTechnique_array(), elemExtra_array() {} 591 /** 592 * Destructor 593 */ 594 virtual ~domLight() {} 595 /** 596 * Overloaded assignment operator 597 */ 598 virtual domLight &operator=( const domLight &cpy ) { (void)cpy; return *this; } 599 600 public: // STATIC METHODS 601 /** 602 * Creates an instance of this class and returns a daeElementRef referencing it. 603 * @return a daeElementRef referencing an instance of this object. 604 */ 605 static DLLSPEC daeElementRef create(DAE& dae); 606 /** 607 * Creates a daeMetaElement object that describes this element in the meta object reflection framework. 608 * If a daeMetaElement already exists it will return that instead of creating a new one. 609 * @return A daeMetaElement describing this COLLADA element. 610 */ 611 static DLLSPEC daeMetaElement* registerElement(DAE& dae); 612 }; 613 614 615 #endif 616