Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Public Member Functions
Graphic3d_CLight Class Reference

Generic light source definition. This class defines arbitrary light source - see Graphic3d_TypeOfLightSource enumeration. Some parameters are applicable only to particular light type; calling methods unrelated to current type will throw an exception. More...

#include <Graphic3d_CLight.hxx>

Inheritance diagram for Graphic3d_CLight:
Inheritance graph
[legend]

Public Member Functions

 Graphic3d_CLight (Graphic3d_TypeOfLightSource theType)
 Empty constructor, which should be followed by light source properties configuration.
 
void CopyFrom (const occ::handle< Graphic3d_CLight > &theLight)
 Copy parameters from another light source excluding source type.
 
Graphic3d_TypeOfLightSource Type () const
 Returns the Type of the Light, cannot be changed after object construction.
 
const TCollection_AsciiStringName () const
 Returns light source name; empty string by default.
 
void SetName (const TCollection_AsciiString &theName)
 Sets light source name.
 
const Quantity_ColorColor () const
 Returns the color of the light source; WHITE by default.
 
void SetColor (const Quantity_Color &theColor)
 Defines the color of a light source by giving the basic color.
 
bool IsEnabled () const
 Check that the light source is turned on; TRUE by default. This flag affects all occurrences of light sources, where it was registered and activated; so that it is possible defining an active light in View which is actually in disabled state.
 
void SetEnabled (bool theIsOn)
 Change enabled state of the light state. This call does not remove or deactivate light source in Views/Viewers; instead it turns it OFF so that it just have no effect.
 
bool ToCastShadows () const
 Return TRUE if shadow casting is enabled; FALSE by default. Has no effect in Ray-Tracing rendering mode.
 
void SetCastShadows (bool theToCast)
 Enable/disable shadow casting.
 
bool IsHeadlight () const
 Returns true if the light is a headlight; FALSE by default. Headlight flag means that light position/direction are defined not in a World coordinate system, but relative to the camera orientation.
 
bool Headlight () const
 Alias for IsHeadlight().
 
void SetHeadlight (bool theValue)
 Setup headlight flag.
 
positional/spot light properties
const gp_PntPosition () const
 Returns location of positional/spot light; (0, 0, 0) by default.
 
void SetPosition (const gp_Pnt &thePosition)
 Setup location of positional/spot light.
 
void Position (double &theX, double &theY, double &theZ) const
 Returns location of positional/spot light.
 
void SetPosition (double theX, double theY, double theZ)
 Setup location of positional/spot light.
 
float ConstAttenuation () const
 Returns constant attenuation factor of positional/spot light source; 1.0f by default. Distance attenuation factors of reducing positional/spot light intensity depending on the distance from its position:
 
float LinearAttenuation () const
 Returns linear attenuation factor of positional/spot light source; 0.0 by default. Distance attenuation factors of reducing positional/spot light intensity depending on the distance from its position:
 
void Attenuation (double &theConstAttenuation, double &theLinearAttenuation) const
 Returns the attenuation factors.
 
void SetAttenuation (float theConstAttenuation, float theLinearAttenuation)
 Defines the coefficients of attenuation; values should be >= 0.0 and their summ should not be equal to 0.
 
directional/spot light additional properties
gp_Dir Direction () const
 Returns direction of directional/spot light.
 
void SetDirection (const gp_Dir &theDir)
 Sets direction of directional/spot light.
 
void Direction (double &theVx, double &theVy, double &theVz) const
 Returns the theVx, theVy, theVz direction of the light source.
 
void SetDirection (double theVx, double theVy, double theVz)
 Sets direction of directional/spot light.
 
const gp_PntDisplayPosition () const
 Returns location of positional/spot/directional light, which is the same as returned by Position().
 
void SetDisplayPosition (const gp_Pnt &thePosition)
 Setup location of positional/spot/directional light, which is the same as SetPosition() but allows directional light source (technically having no position, but this point can be used for displaying light source presentation).
 
spotlight additional definition parameters
float Angle () const
 Returns an angle in radians of the cone created by the spot; 30 degrees by default.
 
void SetAngle (float theAngle)
 Angle in radians of the cone created by the spot, should be within range (0.0, M_PI).
 
float Concentration () const
 Returns intensity distribution of the spot light, within [0.0, 1.0] range; 1.0 by default. This coefficient should be converted into spotlight exponent within [0.0, 128.0] range:
 
void SetConcentration (float theConcentration)
 Defines the coefficient of concentration; value should be within range [0.0, 1.0].
 
Ray-Tracing / Path-Tracing light properties
float Intensity () const
 Returns the intensity of light source; 1.0 by default.
 
void SetIntensity (float theValue)
 Modifies the intensity of light source, which should be > 0.0.
 
float Smoothness () const
 Returns the smoothness of light source (either smoothing angle for directional light or smoothing radius in case of positional light); 0.0 by default.
 
void SetSmoothRadius (float theValue)
 Modifies the smoothing radius of positional/spot light; should be >= 0.0.
 
void SetSmoothAngle (float theValue)
 Modifies the smoothing angle (in radians) of directional light source; should be within range [0.0, M_PI/2].
 
bool HasRange () const
 Returns TRUE if maximum distance of point light source is defined.
 
float Range () const
 Returns maximum distance on which point light source affects to objects and is considered during illumination calculations. 0.0 means disabling range considering at all without any distance limits. Has sense only for point light sources (positional and spot).
 
void SetRange (float theValue)
 Modifies maximum distance on which point light source affects to objects and is considered during illumination calculations. Positional and spot lights are only point light sources. 0.0 means disabling range considering at all without any distance limits.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()=default
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
bool IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
bool IsInstance (const char *const theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
bool IsKind (const opencascade::handle< Standard_Type > &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
bool IsKind (const char *const theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism.
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
 
int GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object. Uses relaxed memory ordering since incrementing only requires atomicity, not synchronization with other memory operations.
 
int DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value. Uses release ordering for the decrement to ensure all writes to the object are visible before the count reaches zero. An acquire fence is added only when the count reaches zero, ensuring proper synchronization before deletion. This is more efficient than using acq_rel for every decrement.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

low-level access methods

TCollection_AsciiString myId
 resource id
 
TCollection_AsciiString myName
 user given name
 
gp_Pnt myPosition
 light position
 
Quantity_ColorRGBA myColor
 light color
 
NCollection_Vec4< floatmyDirection
 direction of directional/spot light
 
NCollection_Vec4< floatmyParams
 packed light parameters
 
float mySmoothness
 radius for point light or cone angle for directional light
 
float myIntensity
 intensity multiplier for light
 
const Graphic3d_TypeOfLightSource myType
 Graphic3d_TypeOfLightSource enumeration.
 
size_t myRevision
 modification counter
 
bool myIsHeadlight
 flag to mark head light
 
bool myIsEnabled
 enabled state
 
bool myToCastShadows
 casting shadows is requested
 
const TCollection_AsciiStringGetId () const
 
const NCollection_Vec4< float > & PackedParams () const
 Packed light parameters.
 
const NCollection_Vec4< float > & PackedColor () const
 Returns the color of the light source with dummy Alpha component, which should be ignored.
 
const NCollection_Vec4< float > & PackedDirectionRange () const
 Returns direction of directional/spot light and range for positional/spot light in alpha channel.
 
NCollection_Vec3< floatPackedDirection () const
 Returns direction of directional/spot light.
 
size_t Revision () const
 
void DumpJson (Standard_OStream &theOStream, int theDepth=-1) const
 Dumps the content of me into the stream.
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object.
 
- Static Public Member Functions inherited from Standard_Transient
static constexpr const charget_type_name ()
 Returns a type descriptor about this object.
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class.
 

Detailed Description

Generic light source definition. This class defines arbitrary light source - see Graphic3d_TypeOfLightSource enumeration. Some parameters are applicable only to particular light type; calling methods unrelated to current type will throw an exception.

Constructor & Destructor Documentation

◆ Graphic3d_CLight()

Graphic3d_CLight::Graphic3d_CLight ( Graphic3d_TypeOfLightSource theType)

Empty constructor, which should be followed by light source properties configuration.

Member Function Documentation

◆ Angle()

float Graphic3d_CLight::Angle ( ) const
inline

Returns an angle in radians of the cone created by the spot; 30 degrees by default.

◆ Attenuation()

void Graphic3d_CLight::Attenuation ( double & theConstAttenuation,
double & theLinearAttenuation ) const
inline

Returns the attenuation factors.

◆ Color()

const Quantity_Color & Graphic3d_CLight::Color ( ) const
inline

Returns the color of the light source; WHITE by default.

◆ Concentration()

float Graphic3d_CLight::Concentration ( ) const
inline

Returns intensity distribution of the spot light, within [0.0, 1.0] range; 1.0 by default. This coefficient should be converted into spotlight exponent within [0.0, 128.0] range:

float aSpotExponent = Concentration() * 128.0;
occ::handle< Units_Dimensions > pow(const occ::handle< Units_Dimensions > &, const double)
float Concentration() const
Returns intensity distribution of the spot light, within [0.0, 1.0] range; 1.0 by default....
Definition Graphic3d_CLight.hxx:181
STL input iterator that wraps an OCCT More()/Next() iterator.
Definition NCollection_ForwardRange.hxx:142

The concentration factor determines the dispersion of the light on the surface, the default value (1.0) corresponds to a minimum of dispersion.

◆ ConstAttenuation()

float Graphic3d_CLight::ConstAttenuation ( ) const
inline

Returns constant attenuation factor of positional/spot light source; 1.0f by default. Distance attenuation factors of reducing positional/spot light intensity depending on the distance from its position:

float anAttenuation = 1.0 / (ConstAttenuation() + LinearAttenuation() * theDistance +
QuadraticAttenuation() * theDistance * theDistance);
float ConstAttenuation() const
Returns constant attenuation factor of positional/spot light source; 1.0f by default....
Definition Graphic3d_CLight.hxx:111
float LinearAttenuation() const
Returns linear attenuation factor of positional/spot light source; 0.0 by default....
Definition Graphic3d_CLight.hxx:120

◆ CopyFrom()

void Graphic3d_CLight::CopyFrom ( const occ::handle< Graphic3d_CLight > & theLight)

Copy parameters from another light source excluding source type.

◆ Direction() [1/2]

gp_Dir Graphic3d_CLight::Direction ( ) const
inline

Returns direction of directional/spot light.

◆ Direction() [2/2]

void Graphic3d_CLight::Direction ( double & theVx,
double & theVy,
double & theVz ) const
inline

Returns the theVx, theVy, theVz direction of the light source.

◆ DisplayPosition()

const gp_Pnt & Graphic3d_CLight::DisplayPosition ( ) const
inline

Returns location of positional/spot/directional light, which is the same as returned by Position().

◆ DumpJson()

void Graphic3d_CLight::DumpJson ( Standard_OStream & theOStream,
int theDepth = -1 ) const

Dumps the content of me into the stream.

◆ GetId()

const TCollection_AsciiString & Graphic3d_CLight::GetId ( ) const
inline
Returns
light resource identifier string

◆ HasRange()

bool Graphic3d_CLight::HasRange ( ) const
inline

Returns TRUE if maximum distance of point light source is defined.

◆ Headlight()

bool Graphic3d_CLight::Headlight ( ) const
inline

Alias for IsHeadlight().

◆ Intensity()

float Graphic3d_CLight::Intensity ( ) const
inline

Returns the intensity of light source; 1.0 by default.

◆ IsEnabled()

bool Graphic3d_CLight::IsEnabled ( ) const
inline

Check that the light source is turned on; TRUE by default. This flag affects all occurrences of light sources, where it was registered and activated; so that it is possible defining an active light in View which is actually in disabled state.

◆ IsHeadlight()

bool Graphic3d_CLight::IsHeadlight ( ) const
inline

Returns true if the light is a headlight; FALSE by default. Headlight flag means that light position/direction are defined not in a World coordinate system, but relative to the camera orientation.

◆ LinearAttenuation()

float Graphic3d_CLight::LinearAttenuation ( ) const
inline

Returns linear attenuation factor of positional/spot light source; 0.0 by default. Distance attenuation factors of reducing positional/spot light intensity depending on the distance from its position:

float anAttenuation = 1.0 / (ConstAttenuation() + LinearAttenuation() * theDistance +
QuadraticAttenuation() * theDistance * theDistance);

◆ Name()

const TCollection_AsciiString & Graphic3d_CLight::Name ( ) const
inline

Returns light source name; empty string by default.

◆ PackedColor()

const NCollection_Vec4< float > & Graphic3d_CLight::PackedColor ( ) const
inline

Returns the color of the light source with dummy Alpha component, which should be ignored.

◆ PackedDirection()

NCollection_Vec3< float > Graphic3d_CLight::PackedDirection ( ) const
inline

Returns direction of directional/spot light.

◆ PackedDirectionRange()

const NCollection_Vec4< float > & Graphic3d_CLight::PackedDirectionRange ( ) const
inline

Returns direction of directional/spot light and range for positional/spot light in alpha channel.

◆ PackedParams()

const NCollection_Vec4< float > & Graphic3d_CLight::PackedParams ( ) const
inline

Packed light parameters.

◆ Position() [1/2]

const gp_Pnt & Graphic3d_CLight::Position ( ) const
inline

Returns location of positional/spot light; (0, 0, 0) by default.

◆ Position() [2/2]

void Graphic3d_CLight::Position ( double & theX,
double & theY,
double & theZ ) const
inline

Returns location of positional/spot light.

◆ Range()

float Graphic3d_CLight::Range ( ) const
inline

Returns maximum distance on which point light source affects to objects and is considered during illumination calculations. 0.0 means disabling range considering at all without any distance limits. Has sense only for point light sources (positional and spot).

◆ Revision()

size_t Graphic3d_CLight::Revision ( ) const
inline
Returns
modification counter

◆ SetAngle()

void Graphic3d_CLight::SetAngle ( float theAngle)

Angle in radians of the cone created by the spot, should be within range (0.0, M_PI).

◆ SetAttenuation()

void Graphic3d_CLight::SetAttenuation ( float theConstAttenuation,
float theLinearAttenuation )

Defines the coefficients of attenuation; values should be >= 0.0 and their summ should not be equal to 0.

◆ SetCastShadows()

void Graphic3d_CLight::SetCastShadows ( bool theToCast)

Enable/disable shadow casting.

◆ SetColor()

void Graphic3d_CLight::SetColor ( const Quantity_Color & theColor)

Defines the color of a light source by giving the basic color.

◆ SetConcentration()

void Graphic3d_CLight::SetConcentration ( float theConcentration)

Defines the coefficient of concentration; value should be within range [0.0, 1.0].

◆ SetDirection() [1/2]

void Graphic3d_CLight::SetDirection ( const gp_Dir & theDir)

Sets direction of directional/spot light.

◆ SetDirection() [2/2]

void Graphic3d_CLight::SetDirection ( double theVx,
double theVy,
double theVz )
inline

Sets direction of directional/spot light.

◆ SetDisplayPosition()

void Graphic3d_CLight::SetDisplayPosition ( const gp_Pnt & thePosition)

Setup location of positional/spot/directional light, which is the same as SetPosition() but allows directional light source (technically having no position, but this point can be used for displaying light source presentation).

◆ SetEnabled()

void Graphic3d_CLight::SetEnabled ( bool theIsOn)

Change enabled state of the light state. This call does not remove or deactivate light source in Views/Viewers; instead it turns it OFF so that it just have no effect.

◆ SetHeadlight()

void Graphic3d_CLight::SetHeadlight ( bool theValue)

Setup headlight flag.

◆ SetIntensity()

void Graphic3d_CLight::SetIntensity ( float theValue)

Modifies the intensity of light source, which should be > 0.0.

◆ SetName()

void Graphic3d_CLight::SetName ( const TCollection_AsciiString & theName)
inline

Sets light source name.

◆ SetPosition() [1/2]

void Graphic3d_CLight::SetPosition ( const gp_Pnt & thePosition)

Setup location of positional/spot light.

◆ SetPosition() [2/2]

void Graphic3d_CLight::SetPosition ( double theX,
double theY,
double theZ )
inline

Setup location of positional/spot light.

◆ SetRange()

void Graphic3d_CLight::SetRange ( float theValue)

Modifies maximum distance on which point light source affects to objects and is considered during illumination calculations. Positional and spot lights are only point light sources. 0.0 means disabling range considering at all without any distance limits.

◆ SetSmoothAngle()

void Graphic3d_CLight::SetSmoothAngle ( float theValue)

Modifies the smoothing angle (in radians) of directional light source; should be within range [0.0, M_PI/2].

◆ SetSmoothRadius()

void Graphic3d_CLight::SetSmoothRadius ( float theValue)

Modifies the smoothing radius of positional/spot light; should be >= 0.0.

◆ Smoothness()

float Graphic3d_CLight::Smoothness ( ) const
inline

Returns the smoothness of light source (either smoothing angle for directional light or smoothing radius in case of positional light); 0.0 by default.

◆ ToCastShadows()

bool Graphic3d_CLight::ToCastShadows ( ) const
inline

Return TRUE if shadow casting is enabled; FALSE by default. Has no effect in Ray-Tracing rendering mode.

◆ Type()

Graphic3d_TypeOfLightSource Graphic3d_CLight::Type ( ) const
inline

Returns the Type of the Light, cannot be changed after object construction.

Field Documentation

◆ myColor

Quantity_ColorRGBA Graphic3d_CLight::myColor
protected

light color

◆ myDirection

NCollection_Vec4<float> Graphic3d_CLight::myDirection
protected

direction of directional/spot light

◆ myId

TCollection_AsciiString Graphic3d_CLight::myId
protected

resource id

◆ myIntensity

float Graphic3d_CLight::myIntensity
protected

intensity multiplier for light

◆ myIsEnabled

bool Graphic3d_CLight::myIsEnabled
protected

enabled state

◆ myIsHeadlight

bool Graphic3d_CLight::myIsHeadlight
protected

flag to mark head light

◆ myName

TCollection_AsciiString Graphic3d_CLight::myName
protected

user given name

◆ myParams

NCollection_Vec4<float> Graphic3d_CLight::myParams
protected

packed light parameters

◆ myPosition

gp_Pnt Graphic3d_CLight::myPosition
protected

light position

◆ myRevision

size_t Graphic3d_CLight::myRevision
protected

modification counter

◆ mySmoothness

float Graphic3d_CLight::mySmoothness
protected

radius for point light or cone angle for directional light

◆ myToCastShadows

bool Graphic3d_CLight::myToCastShadows
protected

casting shadows is requested

◆ myType

const Graphic3d_TypeOfLightSource Graphic3d_CLight::myType
protected

Graphic3d_TypeOfLightSource enumeration.


The documentation for this class was generated from the following file: