CFx SDK Documentation  2022 SP0
GiLightTraitsData.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, 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 Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 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 
36 {
37  bool m_bOn;
38  double m_dIntensity;
39  OdCmEntityColor m_color;
40  OdGiShadowParameters m_shadowParameters;
41 
42 public:
43  enum LightType
44  {
50  };
51 
52  static LightType drawableLightType(const OdGiDrawable *pDrawable);
53 protected:
55 
56 protected:
58  : m_bOn(false)
59  , m_dIntensity(0.0)
61  {}
62 
63 public:
64  bool isOn() const { return m_bOn; }
65  void setOn(bool value) { m_bOn = value; }
66 
67  double intensity() const { return m_dIntensity; }
68  void setIntensity(double dIntensity) { m_dIntensity = dIntensity; }
69 
70  OdCmEntityColor color() const { return m_color; }
71  void setColor(const OdCmEntityColor& color) { m_color = color; }
72 
73  OdGiShadowParameters shadowParameters() const { return m_shadowParameters; }
74  void setShadowParameters(const OdGiShadowParameters& params) { m_shadowParameters = params; }
75 
76  LightType type() const { return m_type; }
77 
78  void save(OdGsFiler * pFiler) const;
79  void load(OdGsFiler * pFiler);
80 
81  static void deleteLightTraitsData(OdGiLightTraitsData* pLightTraits);
82 };
83 
85 {
86  const LightType lightType = (pDrawable) ? (LightType)pDrawable->drawableType() : kInvalidLight;
87  switch (lightType)
88  {
89  case kPointLight:
90  case kSpotLight:
91  case kDistantLight:
92  case kWebLight:
93  return lightType;
94  default:
95  return kInvalidLight;
96  }
97 }
98 
99 inline void OdGiLightTraitsData::save(OdGsFiler *pFiler) const {
100  pFiler->wrBool(isOn());
101  pFiler->wrDouble(intensity());
102  pFiler->wrUInt32(color().color());
103  m_shadowParameters.save(pFiler);
104 }
105 
106 inline void OdGiLightTraitsData::load(OdGsFiler *pFiler) {
107  setOn(pFiler->rdBool());
108  setIntensity(pFiler->rdDouble());
109  { OdCmEntityColor lightColor; lightColor.setColor(pFiler->rdUInt32()); setColor(lightColor); }
110  m_shadowParameters.load(pFiler);
111 }
112 
118 {
119  OdGePoint3d m_position;
120  OdGiLightAttenuation m_attenuation;
121  // Photometric data
122  double m_dPhysIntensity;
123  OdGiColorRGB m_lampColor;
124  bool m_bHasTarget;
125  OdGePoint3d m_target;
126  bool m_bHemisphere;
127 
128 public:
130  : m_dPhysIntensity(1500.0)
131  , m_lampColor(1.0, 1.0, 1.0)
132  , m_bHasTarget(false)
133  , m_bHemisphere(false)
134  {
136  }
137 
138  OdGePoint3d position() const { return m_position; }
139  void setPosition(const OdGePoint3d& pos) { m_position = pos; }
140 
141  OdGiLightAttenuation attenuation() const { return m_attenuation; }
142  void setAttenuation(const OdGiLightAttenuation& atten) { m_attenuation = atten; }
143 
144  double physicalIntensity() const { return m_dPhysIntensity; }
145  void setPhysicalIntensity(double intensity) { m_dPhysIntensity = intensity; }
146 
147  OdGiColorRGB lampColor() const { return m_lampColor; }
148  void setLampColor(const OdGiColorRGB& color) { m_lampColor = color; }
149 
150  bool hasTarget() const { return m_bHasTarget; }
151  void setHasTarget(bool bTarget) { m_bHasTarget = bTarget; }
152 
153  OdGePoint3d targetLocation() const { return m_target; }
154  void setTargetLocation(const OdGePoint3d &loc) { m_target = loc; }
155 
156  void setHemisphericalDistribution(bool bHemisphere) { m_bHemisphere = bHemisphere; }
157  bool hemisphericalDistribution() const { return m_bHemisphere; }
158 
159  inline void save(OdGsFiler *pFiler) const {
161  pFiler->wrPoint3d(position());
162  attenuation().save(pFiler);
163  pFiler->wrDouble(physicalIntensity());
164  pFiler->wrDouble(m_lampColor.red);
165  pFiler->wrDouble(m_lampColor.green);
166  pFiler->wrDouble(m_lampColor.blue);
167  pFiler->wrBool(hasTarget());
168  pFiler->wrPoint3d(targetLocation());
170  }
171 
172  inline void load(OdGsFiler *pFiler) {
174  pFiler->rdPoint3d(m_position);
175  m_attenuation.load(pFiler);
176  setPhysicalIntensity(pFiler->rdDouble());
177  m_lampColor.red = pFiler->rdDouble();
178  m_lampColor.green = pFiler->rdDouble();
179  m_lampColor.blue = pFiler->rdDouble();
180  setHasTarget(pFiler->rdBool());
181  pFiler->rdPoint3d(m_target);
183  }
184 };
185 
191 {
192  OdGePoint3d m_position, m_target;
193  OdGiLightAttenuation m_attenuation;
194  double m_dHotspot, m_dFalloff;
195  // Photometric data
196  double m_dPhysIntensity;
197  OdGiColorRGB m_lampColor;
198 
199 public:
201  : m_dHotspot(0.0)
202  , m_dFalloff(0.0)
203  , m_dPhysIntensity(1500.0)
204  , m_lampColor(1.0, 1.0, 1.0)
205  {
206  m_type = kSpotLight;
207  }
208 
209  OdGePoint3d position() const { return m_position; }
210  void setPosition(const OdGePoint3d& pos) { m_position = pos; }
211 
212  OdGePoint3d target() const { return m_target; }
213  void setTarget(const OdGePoint3d& trg) { m_target = trg; }
214 
215  OdGiLightAttenuation attenuation() const { return m_attenuation; }
216  void setAttenuation(const OdGiLightAttenuation& atten) { m_attenuation = atten; }
217 
218  bool setHotspotAndFalloff(double hotSpot, double falloff);
219  double hotspot() const { return m_dHotspot; }
220  double falloff() const { return m_dFalloff; }
221 
222  double physicalIntensity() const { return m_dPhysIntensity; }
223  void setPhysicalIntensity(double intensity) { m_dPhysIntensity = intensity; }
224 
225  OdGiColorRGB lampColor() const { return m_lampColor; }
226  void setLampColor(const OdGiColorRGB& color) { m_lampColor = color; }
227 
228  void save(OdGsFiler *pFiler) const {
230  pFiler->wrPoint3d(position());
231  pFiler->wrPoint3d(target());
232  attenuation().save(pFiler);
233  pFiler->wrDouble(physicalIntensity());
234  pFiler->wrDouble(hotspot());
235  pFiler->wrDouble(falloff());
236  pFiler->wrDouble(m_lampColor.red);
237  pFiler->wrDouble(m_lampColor.green);
238  pFiler->wrDouble(m_lampColor.blue);
239  }
240 
241  void load(OdGsFiler *pFiler) {
243  pFiler->rdPoint3d(m_position);
244  pFiler->rdPoint3d(m_target);
245  m_attenuation.load(pFiler);
246  setPhysicalIntensity(pFiler->rdDouble());
247  m_dHotspot = pFiler->rdDouble();
248  m_dFalloff = pFiler->rdDouble();
249  m_lampColor.red = pFiler->rdDouble();
250  m_lampColor.green = pFiler->rdDouble();
251  m_lampColor.blue = pFiler->rdDouble();
252  }
253 };
254 
259 inline bool OdGiSpotLightTraitsData::setHotspotAndFalloff(double hotspot, double falloff)
260 {
261  if((hotspot > falloff) ||
262  (hotspot < 0.0) || (falloff < 0.0) ||
263  (OdaToDegree(hotspot) > 160.0) || (OdaToDegree(falloff) > 160.0))
264  return false;
265  m_dHotspot = hotspot;
266  m_dFalloff = falloff;
267  return true;
268 }
269 
275 {
276  OdGeVector3d m_direction;
277  bool m_bIsSunlight;
278  // Photometric data
279  double m_dPhysIntensity;
280  OdGiColorRGB m_lampColor;
281  //OdGiSkyParameters m_skyParams; // Unused
282 
283 public:
285  : m_bIsSunlight(false)
286  , m_dPhysIntensity(1500.0)
287  , m_lampColor(1.0, 1.0, 1.0)
288  {
290  }
291 
292  OdGeVector3d direction() const { return m_direction; }
293  void setDirection(const OdGeVector3d& dir) { m_direction = dir; }
294 
295  bool isSunlight() const { return m_bIsSunlight; }
296  void setSunlight(bool val) { m_bIsSunlight = val; }
297 
298  double physicalIntensity() const { return m_dPhysIntensity; }
299  void setPhysicalIntensity(double intensity) { m_dPhysIntensity = intensity; }
300 
301  OdGiColorRGB lampColor() const { return m_lampColor; }
302  void setLampColor(const OdGiColorRGB& color) { m_lampColor = color; }
303 
304  void skyParameters(OdGiSkyParameters & /*params*/) const { /*params = m_skyParams;*/ }
305  void setSkyParameters(const OdGiSkyParameters & /*params*/) { /*m_skyParams = params;*/ }
306 
307  void save(OdGsFiler *pFiler) const {
309  pFiler->wrVector3d(direction());
310  pFiler->wrBool(isSunlight());
311  pFiler->wrDouble(physicalIntensity());
312  pFiler->wrDouble(m_lampColor.red);
313  pFiler->wrDouble(m_lampColor.green);
314  pFiler->wrDouble(m_lampColor.blue);
315  }
316 
317  void load(OdGsFiler *pFiler) {
319  pFiler->rdVector3d(m_direction);
320  setSunlight(pFiler->rdBool());
321  setPhysicalIntensity(pFiler->rdDouble());
322  m_lampColor.red = pFiler->rdDouble();
323  m_lampColor.green = pFiler->rdDouble();
324  m_lampColor.blue = pFiler->rdDouble();
325  }
326 };
327 
333 {
334  OdString m_webFile;
335  OdGeVector3d m_webRotate;
336  double m_dFlux;
337  OdGiWebLightTraits::WebFileType m_webFileType;
338  OdGiWebLightTraits::WebSymmetry m_webSymmetry;
339  bool m_bHorzAng90to270;
340 
341 public:
344  , m_dFlux(0.0)
345  , m_webFileType(OdGiWebLightTraits::kTypeA)
346  , m_webSymmetry(OdGiWebLightTraits::kNoSymmetry)
347  , m_bHorzAng90to270(false)
348  {
349  m_type = kWebLight;
350  }
351 
352  const OdString &webFile() const { return m_webFile; }
353  void setWebFile(const OdString &fileName) { m_webFile = fileName; }
354 
355  const OdGeVector3d& webRotation() const { return m_webRotate; }
356  void setWebRotation(const OdGeVector3d& rot) { m_webRotate = rot; }
357 
358  double webFlux() const { return m_dFlux; }
359  void setWebFlux(double flux) { m_dFlux = flux; }
360 
361  OdGiWebLightTraits::WebFileType webFileType() const { return m_webFileType; }
363 
364  OdGiWebLightTraits::WebSymmetry webSymmetry() const { return m_webSymmetry; }
365  void setWebSymmetry(OdGiWebLightTraits::WebSymmetry sym) { m_webSymmetry = sym; }
366 
367  bool webHorzAng90to270() const { return m_bHorzAng90to270; }
368  void setWebHorzAng90to270(bool bHA) { m_bHorzAng90to270 = bHA; }
369 
370  inline void save(OdGsFiler *pFiler) const {
372  pFiler->wrString(webFile());
373  pFiler->wrVector3d(webRotation());
374  pFiler->wrDouble(webFlux());
375  pFiler->wrUInt8((OdUInt8)webFileType());
376  pFiler->wrUInt8((OdUInt8)webSymmetry());
377  pFiler->wrBool(webHorzAng90to270());
378  }
379 
380  inline void load(OdGsFiler *pFiler) {
382  pFiler->rdString(m_webFile);
383  pFiler->rdVector3d(m_webRotate);
384  setWebFlux(pFiler->rdDouble());
387  setWebHorzAng90to270(pFiler->rdBool());
388  }
389 };
390 
392 {
393  switch(pLightTraits->type())
394  {
396  delete static_cast<OdGiDistantLightTraitsData*>(pLightTraits);
397  break;
399  delete static_cast<OdGiPointLightTraitsData*>(pLightTraits);
400  break;
402  delete static_cast<OdGiSpotLightTraitsData*>(pLightTraits);
403  break;
405  delete static_cast<OdGiWebLightTraitsData*>(pLightTraits);
406  break;
407  default:
408  {
409  ODA_FAIL_ONCE();
410  }
411  break;
412  }
413 }
414 
420 {
421  OdUInt32 m_nViewportId;
422  OdDbStub* m_pViewportObjectId;
423  bool m_bVpDepOn;
424  double m_dVpDepDimming;
425 
426 public:
428  m_nViewportId( 0 ),
429  m_pViewportObjectId( NULL ),
430  m_bVpDepOn( false ),
431  m_dVpDepDimming( 0.0 )
432  {
433  }
434 
435  OdUInt32 viewportId() const { return m_nViewportId; }
436  void setViewportId( OdUInt32 id ) { m_nViewportId = id; }
437 
438  OdDbStub* viewportObjectId() const { return m_pViewportObjectId; }
439  void setViewportObjectId( OdDbStub* id ) { m_pViewportObjectId = id; }
440 
441  bool vpDepOn() const { return m_bVpDepOn; }
442  void setVpDepOn( bool on ) { m_bVpDepOn = on; }
443 
444  double vpDepDimming() const { return m_dVpDepDimming; }
445  void setVpDepDimming( double dimming ) { m_dVpDepDimming = dimming; }
446 
447  inline void save(OdGsFiler *pFiler) const {
449  pFiler->wrBool( vpDepOn() );
450  pFiler->wrDouble( vpDepDimming() );
451  pFiler->wrUInt32( viewportId() );
452  pFiler->wrHandle( viewportObjectId() );
453  }
454 
455  inline void load(OdGsFiler *pFiler) {
457  setVpDepOn( pFiler->rdBool() );
458  setVpDepDimming( pFiler->rdDouble() );
459  setViewportId( pFiler->rdUInt32() );
460  setViewportObjectId( pFiler->rdHandle() );
461  }
462 };
463 
464 #include "TD_PackPop.h"
465 
466 #endif // __OD_GI_LIGHT_TRAITS_DATA__
#define ODA_FAIL_ONCE()
Definition: DebugStuff.h:66
false
Definition: DimVarDefs.h:165
#define NULL
Definition: GsProperties.h:177
unsigned int OdUInt32
unsigned char OdUInt8
#define OdaToDegree(rad)
Definition: OdaCommon.h:65
void setColor(OdUInt32 color)
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:102
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)
OdDbStub * viewportObjectId() const
void load(OdGsFiler *pFiler)
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)
const OdString & webFile() const
void load(OdGsFiler *pFiler)
void setWebFlux(double flux)
const OdGeVector3d & webRotation() const
OdGiWebLightTraits::WebFileType webFileType() 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 void rdPoint3d(OdGePoint3d &pt) const
virtual void wrBool(bool bVal)
virtual void rdString(OdString &str) const
virtual OdDbStub * rdHandle() const =0
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