CFx SDK Documentation  2022 SP0
TrVisLightDef.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 // GLES2 device light definition
24 
25 #ifndef ODTRVISLIGHTDEF
26 #define ODTRVISLIGHTDEF
27 
28 #include "TD_PackPush.h"
29 
30 #include "TrVisDefs.h"
31 #include "Ge/GeVector3d.h"
32 #include "Ge/GePoint3d.h"
33 #include "Gs/GsFiler.h"
34 
39 {
40  // Type of light
41  enum LightType
42  {
43  kDistant = 0,
45  kSpot
46  } m_type;
47  // Default light marker
49  // Light position
51  // Light direction vector
53  // Light color
54  float m_color[3];
55  // Attenuations
59  // Spot light parameters
60  float m_spotCutoff;
62  // Factor for specular highlighting
64 
65  bool eq(const OdTrVisLightDef &dl2) const;
66 
67  void save(OdGsFiler *pFiler) const;
68  void load(OdGsFiler *pFiler);
69 };
70 
71 inline bool OdTrVisLightDef::eq(const OdTrVisLightDef &dl2) const
72 {
73  return (m_type == dl2.m_type) && (m_bDefLight == dl2.m_bDefLight) &&
75  OdTrVisFPEqual(m_color[0], dl2.m_color[0]) && OdTrVisFPEqual(m_color[1], dl2.m_color[1]) &&
80 }
81 
82 
83 inline void OdTrVisLightDef::save(OdGsFiler *pFiler) const {
84  pFiler->wrUInt8 ((OdUInt8)m_type );
85  pFiler->wrBool (m_bDefLight );
86  pFiler->wrPoint3d (m_position );
87  pFiler->wrVector3d(m_direction );
88  pFiler->wrFloat (m_color[0] );
89  pFiler->wrFloat (m_color[1] );
90  pFiler->wrFloat (m_color[2] );
91  pFiler->wrFloat (m_constantAttenuation );
92  pFiler->wrFloat (m_linearAttenuation );
94  pFiler->wrFloat (m_spotCutoff );
95  pFiler->wrFloat (m_spotExponent );
96  pFiler->wrFloat (m_specularFactor );
97 }
98 
99 inline void OdTrVisLightDef::load(OdGsFiler *pFiler) {
100  m_type = (LightType)pFiler->rdUInt8();
101  m_bDefLight = pFiler->rdBool();
102  pFiler->rdPoint3d(m_position);
103  pFiler->rdVector3d(m_direction);
104  m_color[0] = pFiler->rdFloat();
105  m_color[1] = pFiler->rdFloat();
106  m_color[2] = pFiler->rdFloat();
107  m_constantAttenuation = pFiler->rdFloat();
108  m_linearAttenuation = pFiler->rdFloat();
109  m_quadraticAttenuation = pFiler->rdFloat();
110  m_spotCutoff = pFiler->rdFloat();
111  m_spotExponent = pFiler->rdFloat();
112  m_specularFactor = pFiler->rdFloat();
113 }
114 
115 
116 #include "TD_PackPop.h"
117 
118 #endif // ODTRVISLIGHTDEF
unsigned char OdUInt8
OD_FORCEINLINE bool OdTrVisFPEqual(float a, float b, float tol=1.e-8f)
Definition: TrVisDefs.h:221
bool isEqualTo(const OdGePoint3d &point, const OdGeTol &tol=OdGeContext::gTol) const
bool isEqualTo(const OdGeVector3d &vect, const OdGeTol &tol=OdGeContext::gTol) const
virtual void wrPoint3d(const OdGePoint3d &pt)
virtual void wrFloat(float val)
virtual void rdVector3d(OdGeVector3d &vec) const
virtual OdUInt8 rdUInt8() const
virtual float rdFloat() const
virtual void wrUInt8(OdUInt8 val)
virtual bool rdBool() const
virtual void rdPoint3d(OdGePoint3d &pt) const
virtual void wrBool(bool bVal)
virtual void wrVector3d(const OdGeVector3d &vec)
OdGeVector3d m_direction
Definition: TrVisLightDef.h:52
enum OdTrVisLightDef::LightType m_type
OdGePoint3d m_position
Definition: TrVisLightDef.h:50
float m_color[3]
Definition: TrVisLightDef.h:54
void load(OdGsFiler *pFiler)
Definition: TrVisLightDef.h:99
float m_linearAttenuation
Definition: TrVisLightDef.h:57
void save(OdGsFiler *pFiler) const
Definition: TrVisLightDef.h:83
bool eq(const OdTrVisLightDef &dl2) const
Definition: TrVisLightDef.h:71
float m_specularFactor
Definition: TrVisLightDef.h:63
float m_constantAttenuation
Definition: TrVisLightDef.h:56
float m_quadraticAttenuation
Definition: TrVisLightDef.h:58