CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GiLightTraitsData.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24#ifndef __OD_GI_LIGHT_TRAITS_DATA__
25#define __OD_GI_LIGHT_TRAITS_DATA__
26
27#include "TD_PackPush.h"
28
29#include "Gi/GiLightTraits.h"
30
38{
39 bool m_bOn;
40 double m_dIntensity;
41 OdCmEntityColor m_color;
42 OdGiShadowParameters m_shadowParameters;
43
44public:
49 {
60 };
61
68 static LightType drawableLightType(const OdGiDrawable *pDrawable);
69protected:
71
72protected:
74 : m_bOn(false)
75 , m_dIntensity(0.0)
77 {}
78
79public:
80
87 bool isOn() const { return m_bOn; }
88
94 void setOn(bool value) { m_bOn = value; }
95
102 double intensity() const { return m_dIntensity; }
103
109 void setIntensity(double dIntensity) { m_dIntensity = dIntensity; }
110
117 OdCmEntityColor color() const { return m_color; }
118
124 void setColor(const OdCmEntityColor& color) { m_color = color; }
125
134 OdGiShadowParameters shadowParameters() const { return m_shadowParameters; }
135
143 void setShadowParameters(const OdGiShadowParameters& params) { m_shadowParameters = params; }
144
151 LightType type() const { return m_type; }
152
158 void save(OdGsFiler * pFiler) const;
159
165 void load(OdGsFiler * pFiler);
166
172 static void deleteLightTraitsData(OdGiLightTraitsData* pLightTraits);
173};
174
176{
177 const LightType lightType = (pDrawable) ? (LightType)pDrawable->drawableType() : kInvalidLight;
178 switch (lightType)
179 {
180 case kPointLight:
181 case kSpotLight:
182 case kDistantLight:
183 case kWebLight:
184 return lightType;
185 default:
186 return kInvalidLight;
187 }
188}
189
190inline void OdGiLightTraitsData::save(OdGsFiler *pFiler) const {
191 pFiler->wrBool(isOn());
192 pFiler->wrDouble(intensity());
193 pFiler->wrUInt32(color().color());
194 m_shadowParameters.save(pFiler);
195}
196
198 setOn(pFiler->rdBool());
199 setIntensity(pFiler->rdDouble());
200 { OdCmEntityColor lightColor; lightColor.setColor(pFiler->rdUInt32()); setColor(lightColor); }
201 m_shadowParameters.load(pFiler);
202}
203
211{
212 OdGePoint3d m_position;
213 OdGiLightAttenuation m_attenuation;
214 // Photometric data
215 double m_dPhysIntensity;
216 OdGiColorRGB m_lampColor;
217 bool m_bHasTarget;
218 OdGePoint3d m_target;
219 bool m_bHemisphere;
220
221public:
222
228 : m_dPhysIntensity(1500.0)
229 , m_lampColor(1.0, 1.0, 1.0)
230 , m_bHasTarget(false)
231 , m_bHemisphere(false)
232 {
234 }
235
242 OdGePoint3d position() const { return m_position; }
243
249 void setPosition(const OdGePoint3d& pos) { m_position = pos; }
250
251
252
259 OdGiLightAttenuation attenuation() const { return m_attenuation; }
260
266 void setAttenuation(const OdGiLightAttenuation& atten) { m_attenuation = atten; }
267
268
269
276 double physicalIntensity() const { return m_dPhysIntensity; }
277
283 void setPhysicalIntensity(double intensity) { m_dPhysIntensity = intensity; }
284
285
286
293 OdGiColorRGB lampColor() const { return m_lampColor; }
294
300 void setLampColor(const OdGiColorRGB& color) { m_lampColor = color; }
301
302
303
310 bool hasTarget() const { return m_bHasTarget; }
311
317 void setHasTarget(bool bTarget) { m_bHasTarget = bTarget; }
318
319
320
327 OdGePoint3d targetLocation() const { return m_target; }
328
334 void setTargetLocation(const OdGePoint3d &loc) { m_target = loc; }
335
336 void setHemisphericalDistribution(bool bHemisphere) { m_bHemisphere = bHemisphere; }
337 bool hemisphericalDistribution() const { return m_bHemisphere; }
338
339
340
346 inline void save(OdGsFiler *pFiler) const {
348 pFiler->wrPoint3d(position());
349 attenuation().save(pFiler);
350 pFiler->wrDouble(physicalIntensity());
351 pFiler->wrDouble(m_lampColor.red);
352 pFiler->wrDouble(m_lampColor.green);
353 pFiler->wrDouble(m_lampColor.blue);
354 pFiler->wrBool(hasTarget());
355 pFiler->wrPoint3d(targetLocation());
357 }
358
364 inline void load(OdGsFiler *pFiler) {
366 pFiler->rdPoint3d(m_position);
367 m_attenuation.load(pFiler);
369 m_lampColor.red = pFiler->rdDouble();
370 m_lampColor.green = pFiler->rdDouble();
371 m_lampColor.blue = pFiler->rdDouble();
372 setHasTarget(pFiler->rdBool());
373 pFiler->rdPoint3d(m_target);
375 }
376};
377
385{
386 OdGePoint3d m_position, m_target;
387 OdGiLightAttenuation m_attenuation;
388 double m_dHotspot, m_dFalloff;
389 // Photometric data
390 double m_dPhysIntensity;
391 OdGiColorRGB m_lampColor;
392
393public:
399 : m_dHotspot(0.0)
400 , m_dFalloff(0.0)
401 , m_dPhysIntensity(1500.0)
402 , m_lampColor(1.0, 1.0, 1.0)
403 {
405 }
406
413 OdGePoint3d position() const { return m_position; }
414
420 void setPosition(const OdGePoint3d& pos) { m_position = pos; }
421
422
423
430 OdGePoint3d target() const { return m_target; }
431
437 void setTarget(const OdGePoint3d& trg) { m_target = trg; }
438
439
440
447 OdGiLightAttenuation attenuation() const { return m_attenuation; }
448
454 void setAttenuation(const OdGiLightAttenuation& atten) { m_attenuation = atten; }
455
456
457
464 bool setHotspotAndFalloff(double hotSpot, double falloff);
465
472 double hotspot() const { return m_dHotspot; }
473
480 double falloff() const { return m_dFalloff; }
481
482
483
490 double physicalIntensity() const { return m_dPhysIntensity; }
491
497 void setPhysicalIntensity(double intensity) { m_dPhysIntensity = intensity; }
498
499
500
507 OdGiColorRGB lampColor() const { return m_lampColor; }
508
514 void setLampColor(const OdGiColorRGB& color) { m_lampColor = color; }
515
516
517
523 void save(OdGsFiler *pFiler) const {
525 pFiler->wrPoint3d(position());
526 pFiler->wrPoint3d(target());
527 attenuation().save(pFiler);
528 pFiler->wrDouble(physicalIntensity());
529 pFiler->wrDouble(hotspot());
530 pFiler->wrDouble(falloff());
531 pFiler->wrDouble(m_lampColor.red);
532 pFiler->wrDouble(m_lampColor.green);
533 pFiler->wrDouble(m_lampColor.blue);
534 }
535
541 void load(OdGsFiler *pFiler) {
543 pFiler->rdPoint3d(m_position);
544 pFiler->rdPoint3d(m_target);
545 m_attenuation.load(pFiler);
547 m_dHotspot = pFiler->rdDouble();
548 m_dFalloff = pFiler->rdDouble();
549 m_lampColor.red = pFiler->rdDouble();
550 m_lampColor.green = pFiler->rdDouble();
551 m_lampColor.blue = pFiler->rdDouble();
552 }
553};
554
559inline bool OdGiSpotLightTraitsData::setHotspotAndFalloff(double hotspot, double falloff)
560{
561 if((hotspot > falloff) ||
562 (hotspot < 0.0) || (falloff < 0.0) ||
563 (OdaToDegree(hotspot) > 160.0) || (OdaToDegree(falloff) > 160.0))
564 return false;
565 m_dHotspot = hotspot;
566 m_dFalloff = falloff;
567 return true;
568}
569
577{
578 OdGeVector3d m_direction;
579 bool m_bIsSunlight;
580 // Photometric data
581 double m_dPhysIntensity;
582 OdGiColorRGB m_lampColor;
583 //OdGiSkyParameters m_skyParams; // Unused
584
585public:
591 : m_bIsSunlight(false)
592 , m_dPhysIntensity(1500.0)
593 , m_lampColor(1.0, 1.0, 1.0)
594 {
596 }
597
598
599
606 OdGeVector3d direction() const { return m_direction; }
607
613 void setDirection(const OdGeVector3d& dir) { m_direction = dir; }
614
615
616
623 bool isSunlight() const { return m_bIsSunlight; }
624
630 void setSunlight(bool val) { m_bIsSunlight = val; }
631
632
633
640 double physicalIntensity() const { return m_dPhysIntensity; }
641
647 void setPhysicalIntensity(double intensity) { m_dPhysIntensity = intensity; }
648
649
650
657 OdGiColorRGB lampColor() const { return m_lampColor; }
658
664 void setLampColor(const OdGiColorRGB& color) { m_lampColor = color; }
665
666
667
671 void skyParameters(OdGiSkyParameters & /*params*/) const { /*params = m_skyParams;*/ }
672
676 void setSkyParameters(const OdGiSkyParameters & /*params*/) { /*m_skyParams = params;*/ }
677
678
679
685 void save(OdGsFiler *pFiler) const {
687 pFiler->wrVector3d(direction());
688 pFiler->wrBool(isSunlight());
689 pFiler->wrDouble(physicalIntensity());
690 pFiler->wrDouble(m_lampColor.red);
691 pFiler->wrDouble(m_lampColor.green);
692 pFiler->wrDouble(m_lampColor.blue);
693 }
694
700 void load(OdGsFiler *pFiler) {
702 pFiler->rdVector3d(m_direction);
703 setSunlight(pFiler->rdBool());
705 m_lampColor.red = pFiler->rdDouble();
706 m_lampColor.green = pFiler->rdDouble();
707 m_lampColor.blue = pFiler->rdDouble();
708 }
709};
710
716{
717 OdString m_webFile;
718 OdGeVector3d m_webRotate;
719 double m_dFlux;
722 bool m_bHorzAng90to270;
723
724public:
727 , m_dFlux(0.0)
728 , m_webFileType(OdGiWebLightTraits::kTypeA)
729 , m_webSymmetry(OdGiWebLightTraits::kNoSymmetry)
730 , m_bHorzAng90to270(false)
731 {
733 }
734
735 const OdString &webFile() const { return m_webFile; }
736 void setWebFile(const OdString &fileName) { m_webFile = fileName; }
737
738 const OdGeVector3d& webRotation() const { return m_webRotate; }
739 void setWebRotation(const OdGeVector3d& rot) { m_webRotate = rot; }
740
741 double webFlux() const { return m_dFlux; }
742 void setWebFlux(double flux) { m_dFlux = flux; }
743
744 OdGiWebLightTraits::WebFileType webFileType() const { return m_webFileType; }
746
747 OdGiWebLightTraits::WebSymmetry webSymmetry() const { return m_webSymmetry; }
748 void setWebSymmetry(OdGiWebLightTraits::WebSymmetry sym) { m_webSymmetry = sym; }
749
750 bool webHorzAng90to270() const { return m_bHorzAng90to270; }
751 void setWebHorzAng90to270(bool bHA) { m_bHorzAng90to270 = bHA; }
752
753 inline void save(OdGsFiler *pFiler) const {
755 pFiler->wrString(webFile());
756 pFiler->wrVector3d(webRotation());
757 pFiler->wrDouble(webFlux());
758 pFiler->wrUInt8((OdUInt8)webFileType());
759 pFiler->wrUInt8((OdUInt8)webSymmetry());
760 pFiler->wrBool(webHorzAng90to270());
761 }
762
763 inline void load(OdGsFiler *pFiler) {
765 pFiler->rdString(m_webFile);
766 pFiler->rdVector3d(m_webRotate);
767 setWebFlux(pFiler->rdDouble());
770 setWebHorzAng90to270(pFiler->rdBool());
771 }
772};
773
775{
776 switch(pLightTraits->type())
777 {
779 delete static_cast<OdGiDistantLightTraitsData*>(pLightTraits);
780 break;
782 delete static_cast<OdGiPointLightTraitsData*>(pLightTraits);
783 break;
785 delete static_cast<OdGiSpotLightTraitsData*>(pLightTraits);
786 break;
788 delete static_cast<OdGiWebLightTraitsData*>(pLightTraits);
789 break;
790 default:
791 {
793 }
794 break;
795 }
796}
797
803{
804 OdUInt32 m_nViewportId;
805 OdDbStub* m_pViewportObjectId;
806 bool m_bVpDepOn;
807 double m_dVpDepDimming;
808
809public:
811 m_nViewportId( 0 ),
812 m_pViewportObjectId( NULL ),
813 m_bVpDepOn( false ),
814 m_dVpDepDimming( 0.0 )
815 {
816 }
817
818 OdUInt32 viewportId() const { return m_nViewportId; }
819 void setViewportId( OdUInt32 id ) { m_nViewportId = id; }
820
821 OdDbStub* viewportObjectId() const { return m_pViewportObjectId; }
822 void setViewportObjectId( OdDbStub* id ) { m_pViewportObjectId = id; }
823
824 bool vpDepOn() const { return m_bVpDepOn; }
825 void setVpDepOn( bool on ) { m_bVpDepOn = on; }
826
827 double vpDepDimming() const { return m_dVpDepDimming; }
828 void setVpDepDimming( double dimming ) { m_dVpDepDimming = dimming; }
829
830 inline void save(OdGsFiler *pFiler) const {
832 pFiler->wrBool( vpDepOn() );
833 pFiler->wrDouble( vpDepDimming() );
834 pFiler->wrUInt32( viewportId() );
835 pFiler->wrHandle( viewportObjectId() );
836 }
837
838 inline void load(OdGsFiler *pFiler) {
840 setVpDepOn( pFiler->rdBool() );
841 setVpDepDimming( pFiler->rdDouble() );
842 setViewportId( pFiler->rdUInt32() );
843 setViewportObjectId( pFiler->rdHandle() );
844 }
845};
846
847template <class LightTraitsDataType>
848inline void transformLightTraitsDataPosition(LightTraitsDataType &traitsData, const OdGeMatrix3d &modelTransform)
849{
850 OdGePoint3d newPos(traitsData.position());
851 newPos.transformBy(modelTransform);
852 traitsData.setPosition(newPos);
853}
854// For Point and Web lights
855template <class LightTraitsDataType>
856inline void transformLightTraitsData(LightTraitsDataType &traitsData, const OdGeMatrix3d &modelTransform)
857{
858 transformLightTraitsDataPosition(traitsData, modelTransform);
859 if (traitsData.hasTarget())
860 {
861 OdGePoint3d newTarget = traitsData.targetLocation();
862 newTarget.transformBy(modelTransform);
863 traitsData.setTargetLocation(newTarget);
864 }
865}
866// Specialization for Spot lights
867template <>
869{
870 transformLightTraitsDataPosition(traitsData, modelTransform);
871 OdGePoint3d newTarget = traitsData.target();
872 newTarget.transformBy(modelTransform);
873 traitsData.setTarget(newTarget);
874}
875// Specialization for Direction lights
876template <>
878{
879 OdGeVector3d newDirection = traitsData.direction();
880 newDirection.transformBy(modelTransform);
881 traitsData.setDirection(newDirection);
882}
883
884#include "TD_PackPop.h"
885
886#endif // __OD_GI_LIGHT_TRAITS_DATA__
#define ODA_FAIL_ONCE()
Definition: DebugStuff.h:89
false
Definition: DimVarDefs.h:165
void transformLightTraitsData(LightTraitsDataType &traitsData, const OdGeMatrix3d &modelTransform)
void transformLightTraitsData< OdGiDistantLightTraitsData >(OdGiDistantLightTraitsData &traitsData, const OdGeMatrix3d &modelTransform)
void transformLightTraitsData< OdGiSpotLightTraitsData >(OdGiSpotLightTraitsData &traitsData, const OdGeMatrix3d &modelTransform)
void transformLightTraitsDataPosition(LightTraitsDataType &traitsData, const OdGeMatrix3d &modelTransform)
unsigned int OdUInt32
unsigned char OdUInt8
#define OdaToDegree(rad)
Definition: OdaCommon.h:65
void setColor(OdUInt32 color)
OdGePoint3d & transformBy(const OdGeMatrix3d &xfm)
OdGeVector3d & transformBy(const OdGeMatrix3d &xfm)
void skyParameters(OdGiSkyParameters &) const
OdGiColorRGB lampColor() const
OdGeVector3d direction() const
void setDirection(const OdGeVector3d &dir)
void setPhysicalIntensity(double intensity)
void setLampColor(const OdGiColorRGB &color)
void setSkyParameters(const OdGiSkyParameters &)
void save(OdGsFiler *pFiler) const
void load(OdGsFiler *pFiler)
virtual DrawableType drawableType() const
Definition: GiDrawable.h:113
void save(OdGsFiler *pFiler) const
void load(OdGsFiler *pFiler)
void setOn(bool value)
void save(OdGsFiler *pFiler) const
void load(OdGsFiler *pFiler)
void setColor(const OdCmEntityColor &color)
void setShadowParameters(const OdGiShadowParameters &params)
double intensity() const
static void deleteLightTraitsData(OdGiLightTraitsData *pLightTraits)
LightType type() const
static LightType drawableLightType(const OdGiDrawable *pDrawable)
OdCmEntityColor color() const
void setIntensity(double dIntensity)
OdGiShadowParameters shadowParameters() const
void setViewportObjectId(OdDbStub *id)
void load(OdGsFiler *pFiler)
OdDbStub * viewportObjectId() const
void save(OdGsFiler *pFiler) const
void setVpDepDimming(double dimming)
void setViewportId(OdUInt32 id)
void save(OdGsFiler *pFiler) const
void setLampColor(const OdGiColorRGB &color)
void setPhysicalIntensity(double intensity)
void setTargetLocation(const OdGePoint3d &loc)
double physicalIntensity() const
void load(OdGsFiler *pFiler)
void setAttenuation(const OdGiLightAttenuation &atten)
OdGePoint3d position() const
OdGePoint3d targetLocation() const
void setHemisphericalDistribution(bool bHemisphere)
bool hemisphericalDistribution() const
OdGiColorRGB lampColor() const
void setPosition(const OdGePoint3d &pos)
OdGiLightAttenuation attenuation() const
void setHasTarget(bool bTarget)
void save(OdGsFiler *pFiler) const
void load(OdGsFiler *pFiler)
void save(OdGsFiler *pFiler) const
OdGiColorRGB lampColor() const
OdGiLightAttenuation attenuation() const
double physicalIntensity() const
void setPosition(const OdGePoint3d &pos)
OdGePoint3d target() const
void setLampColor(const OdGiColorRGB &color)
void load(OdGsFiler *pFiler)
OdGePoint3d position() const
void setAttenuation(const OdGiLightAttenuation &atten)
bool setHotspotAndFalloff(double hotSpot, double falloff)
void setTarget(const OdGePoint3d &trg)
void setPhysicalIntensity(double intensity)
void setWebHorzAng90to270(bool bHA)
OdGiWebLightTraits::WebSymmetry webSymmetry() const
void setWebSymmetry(OdGiWebLightTraits::WebSymmetry sym)
void setWebFileType(OdGiWebLightTraits::WebFileType type)
void load(OdGsFiler *pFiler)
const OdGeVector3d & webRotation() const
void setWebFlux(double flux)
OdGiWebLightTraits::WebFileType webFileType() const
const OdString & webFile() const
void save(OdGsFiler *pFiler) const
void setWebRotation(const OdGeVector3d &rot)
void setWebFile(const OdString &fileName)
virtual void wrPoint3d(const OdGePoint3d &pt)
virtual void wrDouble(double val)
virtual void rdVector3d(OdGeVector3d &vec) const
virtual void wrString(const OdString &str)
virtual OdUInt8 rdUInt8() const
virtual void wrHandle(OdDbStub *pHandle)=0
virtual void wrUInt8(OdUInt8 val)
virtual bool rdBool() const
virtual OdDbStub * rdHandle() const =0
virtual void rdPoint3d(OdGePoint3d &pt) const
virtual void wrBool(bool bVal)
virtual void rdString(OdString &str) const
virtual OdUInt32 rdUInt32() const
virtual void wrVector3d(const OdGeVector3d &vec)
virtual double rdDouble() const
virtual void wrUInt32(OdUInt32 val)
GLenum GLint * params
Definition: gles2_ext.h:184
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
GLsizei const GLfloat * value
Definition: gles2_ext.h:302