CFx SDK Documentation 2026 SP0
Loading...
Searching...
No Matches
GsLightNode.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2024, 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-2024 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 //DOM-IGNORE-BEGIN
43
44 OdGeMatrix3d m_model2World; // In case light isn't in model space
49 std::map< OdUInt32, OdGiLightTraitsData* > m_mapVpDepTraitsData;
50
51 enum
52 {
57 };
58
59 //DOM-IGNORE-END
60protected:
61 void update();
62
63 void contextualUpdate(OdGsUpdateContext& ctx);
64
66
68
69public:
71
76
84 OdGsLightNode(OdGsBaseModel* pModel, const OdGiDrawable* pUnderlyingDrawable, bool bSetGsNode = true);
85public:
86
92 void setModelTransform(const OdGeMatrix3d& xform) { m_model2World = xform; }
93
98
105 void setLightOwner(OdGsUpdateContext& ctx, OdGsContainerNode* pParent);
106
115 bool isOwnedBy(OdGsUpdateContext& ctx, OdGsContainerNode* pParent) const;
116
124 bool isOwnedBy(const OdGsNode *pOwner) const { return m_pLightParent == pOwner; }
125
130
135
141 virtual bool isLight() const;
142
150 OdGiPointLightTraitsData* pointLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
151
159 OdGiSpotLightTraitsData* spotLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
160
168 OdGiDistantLightTraitsData* distantLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
169
177 OdGiWebLightTraitsData* webLightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
178
184 OdGiLightTraitsData* lightTraitsData( OdUInt32 viewportID = (OdUInt32)ULONG_MAX );
185
186 // OdGsNode virtual overrides
187
195 virtual void invalidate(OdGsContainerNode* pParent, OdGsViewImpl* pView, OdUInt32 mask);
196
204 virtual void update(OdGsUpdateContext& ctx, OdGsContainerNode* pParent,
206
214 virtual bool saveClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer) const;
215
223 virtual bool loadClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer);
224
230
238 static bool drawableIsLight(const OdGiDrawable *pDrawable);
239};
240
245
250
251inline bool OdGsLightNode::isLight() const
252{
253 return true;
254}
255
257{
259 return NULL;
261 {
262 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
263 if( it != m_mapVpDepTraitsData.end() )
264 {
265 return (OdGiPointLightTraitsData*)(it->second);
266 }
267 }
269}
271{
273 return NULL;
275 {
276 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
277 if( it != m_mapVpDepTraitsData.end() )
278 {
279 return (OdGiSpotLightTraitsData*)(it->second);
280 }
281 }
283}
285{
287 return NULL;
289 {
290 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
291 if( it != m_mapVpDepTraitsData.end() )
292 {
293 return (OdGiDistantLightTraitsData*)(it->second);
294 }
295 }
297}
299{
301 return NULL;
303 {
304 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
305 if( it != m_mapVpDepTraitsData.end() )
306 {
307 return (OdGiWebLightTraitsData*)(it->second);
308 }
309 }
311}
313{
315 {
316 std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.find( viewportID );
317 if( it != m_mapVpDepTraitsData.end() )
318 {
319 return it->second;
320 }
321 }
322 return m_pLightTraits;
323}
324
326{
327 if( !GETBIT(m_flags, kViewportDependentLight) ) return;
328 if( !data || !vdData ) return;
329 data->setOn( vdData->vpDepOn() && !GETBIT(m_flags, kLightDrawableIsInvisible) );
330 data->setIntensity( data->intensity() * ( 1.0 - vdData->vpDepDimming() ) );
331}
332
337
339{
340 for( std::map< OdUInt32, OdGiLightTraitsData* >::iterator it = m_mapVpDepTraitsData.begin(); it != m_mapVpDepTraitsData.end(); ++it )
341 {
343 }
344 m_mapVpDepTraitsData.clear();
345}
346
347#include "TD_PackPop.h"
348
349#endif // __OD_GS_LIGHT_NODE__
#define GS_TOOLKIT_EXPORT
Definition GsExport.h:37
OdSmartPtr< OdGsLightNode > OdGsLightNodePtr
unsigned int OdUInt32
#define GETBIT(flags, bit)
Definition OdaDefs.h:517
static void deleteLightTraitsData(OdGiLightTraitsData *pLightTraits)
static LightType drawableLightType(const OdGiDrawable *pDrawable)
virtual bool isLight() const
OdGsEntityNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=false)
OdGsLightNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable, bool bSetGsNode=true)
LightInsertPath m_lightInsertParents
Definition GsLightNode.h:48
bool isOwnedBy(OdGsUpdateContext &ctx, OdGsContainerNode *pParent) const
virtual void invalidate(OdGsContainerNode *pParent, OdGsViewImpl *pView, OdUInt32 mask)
OdGeMatrix3d modelTransform() const
Definition GsLightNode.h:97
OdGiDistantLightTraitsData * distantLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
void setLightOwner(OdGsUpdateContext &ctx, OdGsContainerNode *pParent)
void adjustViewportDependentLightTraitsData(OdGiLightTraitsVpDepData *vdData, OdGiLightTraitsData *data)
std::map< OdUInt32, OdGiLightTraitsData * > m_mapVpDepTraitsData
Definition GsLightNode.h:49
OdGiPointLightTraitsData * pointLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
void setModelTransform(const OdGeMatrix3d &xform)
Definition GsLightNode.h:92
@ kViewportDependentNeedUpdate
Definition GsLightNode.h:54
@ kLightDrawableIsInvisible
Definition GsLightNode.h:55
@ kViewportDependentLight
Definition GsLightNode.h:53
OdGiLightTraitsData * m_pLightTraits
Definition GsLightNode.h:45
void updateViewportDependent(OdGsViewImpl *pView)
OdGiLightTraitsData * lightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
ODRX_DECLARE_MEMBERS(OdGsLightNode)
virtual void update(OdGsUpdateContext &ctx, OdGsContainerNode *pParent, OdSiSpatialIndex *)
virtual bool saveClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer) const
void clearVpDepTraitsMap()
virtual bool isLight() const
OdGsNode * getLightOwner() const
static bool drawableIsLight(const OdGiDrawable *pDrawable)
OdVector< OdIntPtr, OdMemoryAllocator< OdIntPtr > > LightInsertPath
Definition GsLightNode.h:47
virtual bool loadClientNodeState(OdGsFiler *pFiler, OdGsBaseVectorizer *pVectorizer)
void contextualUpdate(OdGsUpdateContext &ctx)
OdGsNode * m_pLightParent
Definition GsLightNode.h:46
OdGeMatrix3d m_model2World
Definition GsLightNode.h:44
OdGiLightTraitsData::LightType lightType()
OdGiWebLightTraitsData * webLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
bool isOwnedBy(const OdGsNode *pOwner) const
OdGiSpotLightTraitsData * spotLightTraitsData(OdUInt32 viewportID=(OdUInt32) ULONG_MAX)
friend class OdGsViewImpl
Definition GsNode.h:62
OdUInt32 m_flags
Definition GsNode.h:93
OdGiDrawablePtr underlyingDrawable() const
Definition GsNode.h:400
friend class OdGsBaseModel
Definition GsNode.h:61
OdGsNode(OdGsBaseModel *pModel, const OdGiDrawable *pUnderlyingDrawable)
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition gles2_ext.h:110
GLenum GLint GLuint mask
Definition gles2_ext.h:262