CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
GsLightNode.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_GS_LIGHT_NODE__
25#define __OD_GS_LIGHT_NODE__
26
27#include "TD_PackPush.h"
28
29#include "Gs/GsEntityNode.h"
31
32#define STL_USING_MAP
33#include "OdaSTL.h"
34
35// Lights are entities that have some special meaning
36
40{
41protected:
42 OdGeMatrix3d m_model2World; // In case light isn't in model space
47 std::map< OdUInt32, OdGiLightTraitsData* > m_mapVpDepTraitsData;
48
49 enum
50 {
51 kViewportDependentLight = (OdGsEntityNode::kLastFlag << 1),
52 kViewportDependentNeedUpdate = (OdGsEntityNode::kLastFlag << 2),
53 kLightDrawableIsInvisible = (OdGsEntityNode::kLastFlag << 3),
54 kLastFlag = kLightDrawableIsInvisible
55 };
56protected:
57 void update();
58
59 void contextualUpdate(OdGsUpdateContext& ctx);
60
61 void adjustViewportDependentLightTraitsData( OdGiLightTraitsVpDepData* vdData, OdGiLightTraitsData* data );
62
63 void clearVpDepTraitsMap();
64
65public:
67
72
80 OdGsLightNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
81public:
82
88 void setModelTransform(const OdGeMatrix3d& xform) { m_model2World = xform; }
89
93 OdGeMatrix3d modelTransform() const { return m_model2World; }
94
101 void setLightOwner(OdGsUpdateContext& ctx, OdGsContainerNode* pParent);
102
111 bool isOwnedBy(OdGsUpdateContext& ctx, OdGsContainerNode* pParent) const;
112
120 bool isOwnedBy(const OdGsNode *pOwner) const { return m_pLightParent == pOwner; }
121
125 OdGsNode *getLightOwner() const { return m_pLightParent; }
126
131
137 virtual bool isLight() const;
138
146 OdGiPointLightTraitsData* pointLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
147
155 OdGiSpotLightTraitsData* spotLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
156
164 OdGiDistantLightTraitsData* distantLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
165
173 OdGiWebLightTraitsData* webLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
174
180 OdGiLightTraitsData* lightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
181
182 // OdGsNode virtual overrides
183
191 virtual void invalidate(OdGsContainerNode* pParent, OdGsViewImpl* pView, OdUInt32 mask);
192
200 virtual void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent,
202
210 virtual bool saveClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer) const;
211
219 virtual bool loadClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer);
220
226
234 static bool drawableIsLight(const OdGiDrawable *pDrawable);
235};
236
241
243{
245}
246
247inline bool OdGsLightNode::isLight() const
248{
249 return true;
250}
251
253{
255 return NULL;
257 {
258 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
259 if( it != m_mapVpDepTraitsData.end() )
260 {
261 return (OdGiPointLightTraitsData*)(it->second);
262 }
263 }
265}
267{
269 return NULL;
271 {
272 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
273 if( it != m_mapVpDepTraitsData.end() )
274 {
275 return (OdGiSpotLightTraitsData*)(it->second);
276 }
277 }
279}
281{
283 return NULL;
285 {
286 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
287 if( it != m_mapVpDepTraitsData.end() )
288 {
289 return (OdGiDistantLightTraitsData*)(it->second);
290 }
291 }
293}
295{
297 return NULL;
299 {
300 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
301 if( it != m_mapVpDepTraitsData.end() )
302 {
303 return (OdGiWebLightTraitsData*)(it->second);
304 }
305 }
307}
309{
311 {
312 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
313 if( it != m_mapVpDepTraitsData.end() )
314 {
315 return it->second;
316 }
317 }
318 return m_pLightTraits;
319}
320
322{
323 if( !GETBIT(m_flags, kViewportDependentLight) ) return;
324 if( !data || !vdData ) return;
325 data->setOn( vdData->vpDepOn() && !GETBIT(m_flags, kLightDrawableIsInvisible) );
326 data->setIntensity( data->intensity() * ( 1.0 - vdData->vpDepDimming() ) );
327}
328
329inline bool OdGsLightNode::drawableIsLight(const OdGiDrawable *pDrawable)
330{
332}
333
335{
336 for( std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.begin(); it != m_mapVpDepTraitsData.end(); ++it )
337 {
339 }
340 m_mapVpDepTraitsData.clear();
341}
342
343#include "TD_PackPop.h"
344
345#endif // __OD_GS_LIGHT_NODE__
#define GS_TOOLKIT_EXPORT
Definition: GsExport.h:37
OdSmartPtr< OdGsLightNode > OdGsLightNodePtr
Definition: GsLightNode.h:240
unsigned int OdUInt32
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
static void deleteLightTraitsData(OdGiLightTraitsData *pLightTraits)
LightType type() const
static LightType drawableLightType(const OdGiDrawable *pDrawable)
virtual bool isLight() const
Definition: GsEntityNode.h:832
OdGsLightNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
LightInsertPath m_lightInsertParents
Definition: GsLightNode.h:46
bool isOwnedBy(OdGsUpdateContext &ctx, OdGsContainerNode *pParent) const
virtual void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
OdGeMatrix3d modelTransform() const
Definition: GsLightNode.h:93
@ kLightDrawableIsInvisible
Definition: GsLightNode.h:53
@ kViewportDependentLight
Definition: GsLightNode.h:51
OdGiDistantLightTraitsData * distantLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
Definition: GsLightNode.h:280
void setLightOwner(OdGsUpdateContext &ctx, OdGsContainerNode *pParent)
void adjustViewportDependentLightTraitsData(OdGiLightTraitsVpDepData *vdData, OdGiLightTraitsData *data)
Definition: GsLightNode.h:321
std::map< OdUInt32, OdGiLightTraitsData * > m_mapVpDepTraitsData
Definition: GsLightNode.h:47
OdGiPointLightTraitsData * pointLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
Definition: GsLightNode.h:252
void setModelTransform(const OdGeMatrix3d &xform)
Definition: GsLightNode.h:88
OdGiLightTraitsData * m_pLightTraits
Definition: GsLightNode.h:43
void updateViewportDependent(OdGsViewImpl *pView)
OdGiLightTraitsData * lightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
Definition: GsLightNode.h:308
ODRX_DECLARE_MEMBERS(OdGsLightNode)
virtual void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *)
virtual bool saveClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer) const
void clearVpDepTraitsMap()
Definition: GsLightNode.h:334
virtual bool isLight() const
Definition: GsLightNode.h:247
OdGsNode * getLightOwner() const
Definition: GsLightNode.h:125
static bool drawableIsLight(const OdGiDrawable *pDrawable)
Definition: GsLightNode.h:329
OdVector< OdIntPtr, OdMemoryAllocator< OdIntPtr > > LightInsertPath
Definition: GsLightNode.h:45
virtual bool loadClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer)
void contextualUpdate(OdGsUpdateContext &ctx)
OdGsNode * m_pLightParent
Definition: GsLightNode.h:44
OdGeMatrix3d m_model2World
Definition: GsLightNode.h:42
OdGiLightTraitsData::LightType lightType()
Definition: GsLightNode.h:242
OdGiWebLightTraitsData * webLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
Definition: GsLightNode.h:294
bool isOwnedBy(const OdGsNode *pOwner) const
Definition: GsLightNode.h:120
OdGiSpotLightTraitsData * spotLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
Definition: GsLightNode.h:266
OdUInt32 m_flags
Definition: GsNode.h:91
OdGiDrawablePtr underlyingDrawable() const
Definition: GsNode.h:364
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition: gles2_ext.h:110
GLenum GLint GLuint mask
Definition: gles2_ext.h:262