CFx SDK Documentation  2020SP3
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
OdGeVector3d
Definition: GeVector3d.h:54
OdGsFiler::wrVector3d
virtual void wrVector3d(const OdGeVector3d &vec)
OdUInt8
unsigned char OdUInt8
Definition: OdPlatformSettings.h:759
OdGsFiler::rdVector3d
virtual void rdVector3d(OdGeVector3d &vec) const
OdTrVisLightDef::m_linearAttenuation
float m_linearAttenuation
Definition: TrVisLightDef.h:57
OdTrVisLightDef::m_position
OdGePoint3d m_position
Definition: TrVisLightDef.h:50
OdTrVisLightDef::m_specularFactor
float m_specularFactor
Definition: TrVisLightDef.h:63
OdTrVisLightDef::m_direction
OdGeVector3d m_direction
Definition: TrVisLightDef.h:52
OdTrVisLightDef::load
void load(OdGsFiler *pFiler)
Definition: TrVisLightDef.h:99
OdGeVector3d::isEqualTo
bool isEqualTo(const OdGeVector3d &vect, const OdGeTol &tol=OdGeContext::gTol) const
TD_PackPop.h
OdTrVisLightDef::m_constantAttenuation
float m_constantAttenuation
Definition: TrVisLightDef.h:56
OdTrVisLightDef::m_type
enum OdTrVisLightDef::LightType m_type
OdGsFiler::rdBool
virtual bool rdBool() const
OdTrVisLightDef::m_color
float m_color[3]
Definition: TrVisLightDef.h:54
OdGePoint3d
Definition: GePoint3d.h:55
GePoint3d.h
OdTrVisLightDef::eq
bool eq(const OdTrVisLightDef &dl2) const
Definition: TrVisLightDef.h:71
TrVisDefs.h
OdTrVisLightDef::kDistant
@ kDistant
Definition: TrVisLightDef.h:43
OdTrVisLightDef::save
void save(OdGsFiler *pFiler) const
Definition: TrVisLightDef.h:83
OdTrVisLightDef::kSpot
@ kSpot
Definition: TrVisLightDef.h:45
TD_PackPush.h
OdTrVisFPEqual
OD_FORCEINLINE bool OdTrVisFPEqual(float a, float b, float tol=1.e-8f)
Definition: TrVisDefs.h:221
GeVector3d.h
OdGsFiler::wrPoint3d
virtual void wrPoint3d(const OdGePoint3d &pt)
GsFiler.h
OdTrVisLightDef::m_quadraticAttenuation
float m_quadraticAttenuation
Definition: TrVisLightDef.h:58
OdGsFiler::wrUInt8
virtual void wrUInt8(OdUInt8 val)
OdGsFiler::wrBool
virtual void wrBool(bool bVal)
OdTrVisLightDef::LightType
LightType
Definition: TrVisLightDef.h:42
OdTrVisLightDef::m_spotCutoff
float m_spotCutoff
Definition: TrVisLightDef.h:60
OdGsFiler::rdFloat
virtual float rdFloat() const
OdTrVisLightDef
Definition: TrVisLightDef.h:39
OdGsFiler::rdUInt8
virtual OdUInt8 rdUInt8() const
OdGePoint3d::isEqualTo
bool isEqualTo(const OdGePoint3d &point, const OdGeTol &tol=OdGeContext::gTol) const
OdGsFiler::rdPoint3d
virtual void rdPoint3d(OdGePoint3d &pt) const
OdGsFiler
Definition: GsFiler.h:63
OdTrVisLightDef::kPoint
@ kPoint
Definition: TrVisLightDef.h:44
OdTrVisLightDef::m_bDefLight
bool m_bDefLight
Definition: TrVisLightDef.h:48
OdGsFiler::wrFloat
virtual void wrFloat(float val)
OdTrVisLightDef::m_spotExponent
float m_spotExponent
Definition: TrVisLightDef.h:61