Rhino C++ API  7.18
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ON_Light Class Reference

#include <opennurbs_light.h>

Inheritance diagram for ON_Light:
ON_Geometry ON_Object

Public Member Functions

 ON_Light ()
 ON_Light (const ON_Light &)=default
 ~ON_Light ()
ON_Color Ambient () const
ON_3dVector Attenuation () const
double Attenuation (double) const
ON::coordinate_system CoordinateSystem () const
 determined by style More...
void Default ()
 make default light More...
ON_Color Diffuse () const
int Dimension () const override
ON_3dVector Direction () const
void Dump (ON_TextLog &) const override
 for debugging More...
bool Enable (bool=true)
 returns previous state More...
bool GetBBox (double *boxmin, double *boxmax, bool bGrowBox=false) const override
 virtual ON_Geometry GetBBox override
bool GetLightXform (const ON_Viewport &vp, ON::coordinate_system dest_cs, ON_Xform &xform) const
bool GetSpotLightRadii (double *inner_radius, double *outer_radius) const
 The spotlight radii are useful for display UI. More...
double HotSpot () const
double Intensity () const
 0.0 = 0% 1.0 = 100% Only clamped above zero - no maximum. More...
const bool IsDirectionalLight () const
bool IsEnabled () const
const bool IsLinearLight () const
const bool IsPointLight () const
const bool IsRectangularLight () const
const bool IsSpotLight () const
bool IsValid (class ON_TextLog *text_log=nullptr) const override
ON_3dVector Length () const
int LightIndex () const
const ON_wStringLightName () const
ON_3dPoint Location () const
ON_UUID ModelObjectId () const override
 virtual More...
ON::object_type ObjectType () const override
ON_Lightoperator= (const ON_Light &)=default
ON_3dVector PerpindicularDirection () const
double PowerCandela () const
double PowerLumens () const
double PowerWatts () const
bool Read (ON_BinaryArchive &) override
void SetAmbient (ON_Color)
void SetAttenuation (const ON_3dVector &)
void SetAttenuation (double, double, double)
void SetDiffuse (ON_Color)
void SetDirection (const ON_3dVector &)
void SetHotSpot (double)
void SetIntensity (double)
void SetLength (const ON_3dVector &)
void SetLightIndex (int)
void SetLightName (const char *)
void SetLightName (const wchar_t *)
void SetLocation (const ON_3dPoint &)
void SetPowerCandela (double)
void SetPowerLumens (double)
void SetPowerWatts (double)
void SetShadowIntensity (double)
void SetSpecular (ON_Color)
void SetSpotAngleDegrees (double)
void SetSpotAngleRadians (double)
void SetSpotExponent (double)
void SetStyle (ON::light_style)
void SetWidth (const ON_3dVector &)
double ShadowIntensity () const
ON_Color Specular () const
double SpotAngleDegrees () const
double SpotAngleRadians () const
double SpotExponent () const
ON::light_style Style () const
bool Transform (const ON_Xform &) override
ON_3dVector Width () const
bool Write (ON_BinaryArchive &) const override
- Public Member Functions inherited from ON_Geometry
 ON_Geometry ()=default
 ON_Geometry (const ON_Geometry &)=default
 ~ON_Geometry ()=default
ON_BoundingBox BoundingBox () const
virtual class ON_BrepBrepForm (class ON_Brep *brep=nullptr) const
virtual void ClearBoundingBox ()
virtual ON_COMPONENT_INDEX ComponentIndex () const
virtual bool EvaluatePoint (const class ON_ObjRef &objref, ON_3dPoint &P) const
bool GetBoundingBox (ON_3dPoint &bbox_min, ON_3dPoint &bbox_max, bool bGrowBox=false) const
bool GetBoundingBox (ON_BoundingBox &bbox, bool bGrowBox=false) const
virtual bool GetTightBoundingBox (class ON_BoundingBox &tight_bbox, bool bGrowBox=false, const class ON_Xform *xform=nullptr) const
virtual bool HasBrepForm () const
virtual bool IsDeformable () const
virtual bool IsMorphable () const
virtual bool MakeDeformable ()
virtual bool Morph (const class ON_SpaceMorph &morph)
ON_Geometryoperator= (const ON_Geometry &)=default
bool Rotate (double rotation_angle, const ON_3dVector &rotation_axis, const ON_3dPoint &rotation_center)
bool Rotate (double sin_angle, double cos_angle, const ON_3dVector &rotation_axis, const ON_3dPoint &rotation_center)
bool Scale (double scale_factor)
virtual bool SwapCoordinates (int i, int j)
bool Translate (const ON_3dVector &translation_vector)
- Public Member Functions inherited from ON_Object
 ON_Object (const ON_Object &)
virtual ~ON_Object ()
virtual ON_AggregateComponentStatus AggregateComponentStatus () const
bool AttachUserData (class ON_UserData *pUserData)
unsigned int ClearAllComponentStates () const
virtual unsigned int ClearComponentStates (ON_COMPONENT_INDEX component_index, ON_ComponentStatus states_to_clear) const
virtual unsigned int ClearComponentStates (ON_ComponentStatus states_to_clear) const
void CopyUserData (const ON_Object &source_object)
unsigned int CopyUserData (const ON_Object &source_object, ON_UUID source_userdata_item_id, ON_Object::UserDataConflictResolution userdata_conflict_resolution)
virtual ON__UINT32 DataCRC (ON__UINT32 current_remainder) const
virtual bool DeleteComponents (const ON_COMPONENT_INDEX *ci_list, size_t ci_count)
virtual void DestroyRuntimeCache (bool bDelete=true)
bool DetachUserData (class ON_UserData *pUserData)
void EmergencyDestroy ()
class ON_UserDataFirstUserData () const
virtual unsigned int GetComponentsWithSetStates (ON_ComponentStatus states_filter, bool bAllEqualStates, ON_SimpleArray< ON_COMPONENT_INDEX > &components) const
class ON_UserDataGetUserData (const ON_UUID &userdata_uuid) const
bool GetUserString (const wchar_t *key, ON_wString &string_value) const
int GetUserStringKeys (ON_ClassArray< ON_wString > &user_string_keys) const
int GetUserStrings (ON_ClassArray< ON_UserString > &user_strings) const
bool IsCorrupt (bool bRepair, bool bSilentError, class ON_TextLog *text_log) const
bool IsKindOf (const ON_ClassId *pClassId) const
virtual void MarkAggregateComponentStatusAsNotCurrent () const
virtual void MemoryRelocate ()
void MoveUserData (ON_Object &source_object)
unsigned int MoveUserData (ON_Object &source_object, ON_UUID source_userdata_item_id, ON_Object::UserDataConflictResolution userdata_conflict_resolution, bool bDeleteAllSourceItems)
ON_Objectoperator= (const ON_Object &)
void PurgeUserData ()
virtual unsigned int SetComponentStates (ON_COMPONENT_INDEX component_index, ON_ComponentStatus states_to_set) const
virtual unsigned int SetComponentStatus (ON_COMPONENT_INDEX component_index, ON_ComponentStatus status_to_copy) const
bool SetUserString (const wchar_t *key, const wchar_t *string_value)
int SetUserStrings (int count, const ON_UserString *user_strings, bool bReplace)
virtual unsigned int SizeOf () const
bool ThisIsNullptr (bool bSilentError) const
void TransformUserData (const class ON_Xform &xform)
virtual bool UpdateReferencedComponents (const class ON_ComponentManifest &source_manifest, const class ON_ComponentManifest &destination_manifest, const class ON_ManifestMap &manifest_map)
int UserStringCount () const

Public Attributes

ON_Color m_ambient
ON_3dVector m_attenuation
 attenuation settings - ignored for "directional" and "ambient" lights More...
bool m_bOn
 true if light is on More...
ON_Color m_diffuse
ON_3dVector m_direction
 ignored for "point" and "ambient" lights More...
double m_hotspot
 0.0 to 1.0 (See SetHotSpot() for details) More...
double m_intensity
ON_3dVector m_length
ON_UUID m_light_id
int m_light_index
ON_wString m_light_name
ON_3dPoint m_location
 ignored for "directional" and "ambient" lights More...
double m_shadow_intensity
 shawdow casting More...
ON_Color m_specular
double m_spot_angle
 spot settings - ignored for non-spot lights More...
double m_spot_exponent
ON::light_style m_style
 style of light More...
double m_watts
ON_3dVector m_width

Static Public Attributes

static const ON_Light Unset
- Static Public Attributes inherited from ON_Geometry
const static ON_Geometry Unset

Additional Inherited Members

- Public Types inherited from ON_Object
enum  UserDataConflictResolution : unsigned char {
  UserDataConflictResolution::destination_object = 0, UserDataConflictResolution::source_object = 1, UserDataConflictResolution::source_copycount_gt = 2, UserDataConflictResolution::source_copycount_ge = 3,
  UserDataConflictResolution::destination_copycount_gt = 4, UserDataConflictResolution::destination_copycount_ge = 5, UserDataConflictResolution::delete_item = 6

Detailed Description


/ / Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved. / OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert / McNeel & Associates. / / THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. / ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF / MERCHANTABILITY ARE HEREBY DISCLAIMED. /
/ For complete openNURBS copyright information see http://www.opennurbs.org. / //////////////////////////////////////////////////////////////

Constructor & Destructor Documentation

◆ ON_Light() [1/2]

ON_Light::ON_Light ( )

◆ ~ON_Light()

ON_Light::~ON_Light ( )

◆ ON_Light() [2/2]

ON_Light::ON_Light ( const ON_Light )

Member Function Documentation

◆ Ambient()

ON_Color ON_Light::Ambient ( ) const

◆ Attenuation() [1/2]

ON_3dVector ON_Light::Attenuation ( ) const

◆ Attenuation() [2/2]

double ON_Light::Attenuation ( double  ) const

computes 1/(a[0] + d*a[1] + d^2*a[2]) where d = argument returns 0 if a[0] + d*a[1] + d^2*a[2] <= 0

◆ CoordinateSystem()

ON::coordinate_system ON_Light::CoordinateSystem ( ) const

determined by style

◆ Default()

void ON_Light::Default ( )

make default light


◆ Diffuse()

ON_Color ON_Light::Diffuse ( ) const

◆ Dimension()

int ON_Light::Dimension ( ) const

ON_Geometry virtual functions

Reimplemented from ON_Geometry.

◆ Direction()

ON_3dVector ON_Light::Direction ( ) const

◆ Dump()

void ON_Light::Dump ( ON_TextLog ) const

for debugging

Reimplemented from ON_Object.

◆ Enable()

bool ON_Light::Enable ( bool  = true)

returns previous state

turn light on/off

◆ GetBBox()

bool ON_Light::GetBBox ( double *  boxmin,
double *  boxmax,
bool  bGrowBox = false 
) const

virtual ON_Geometry GetBBox override

Reimplemented from ON_Geometry.

◆ GetLightXform()

bool ON_Light::GetLightXform ( const ON_Viewport vp,
ON::coordinate_system  dest_cs,
ON_Xform xform 
) const

Description: A light's location and direction can be defined with respect to world, camera, or view coordinates. GetLightXform gets the transformation from the light's intrinsic coordinate system to the destination coordinate system specified by dest_cs. Parameters: vp - [in] viewport where light is being used dest_cs - [in] destination coordinate system xform - [out] transformation from the light's intrinsic coordinate system to cs. Returns: true if successful.

◆ GetSpotLightRadii()

bool ON_Light::GetSpotLightRadii ( double *  inner_radius,
double *  outer_radius 
) const

The spotlight radii are useful for display UI.

◆ HotSpot()

double ON_Light::HotSpot ( ) const

◆ Intensity()

double ON_Light::Intensity ( ) const

0.0 = 0% 1.0 = 100% Only clamped above zero - no maximum.

◆ IsDirectionalLight()

const bool ON_Light::IsDirectionalLight ( ) const

◆ IsEnabled()

bool ON_Light::IsEnabled ( ) const

◆ IsLinearLight()

const bool ON_Light::IsLinearLight ( ) const

◆ IsPointLight()

const bool ON_Light::IsPointLight ( ) const

◆ IsRectangularLight()

const bool ON_Light::IsRectangularLight ( ) const

◆ IsSpotLight()

const bool ON_Light::IsSpotLight ( ) const

◆ IsValid()

bool ON_Light::IsValid ( class ON_TextLog text_log = nullptr) const

ON_Object virtual functions

Reimplemented from ON_Geometry.

◆ Length()

ON_3dVector ON_Light::Length ( ) const

◆ LightIndex()

int ON_Light::LightIndex ( ) const

◆ LightName()

const ON_wString& ON_Light::LightName ( ) const

◆ Location()

ON_3dPoint ON_Light::Location ( ) const

◆ ModelObjectId()

ON_UUID ON_Light::ModelObjectId ( ) const


Reimplemented from ON_Object.

◆ ObjectType()

ON::object_type ON_Light::ObjectType ( ) const

Description: Useful for switch statements that need to differentiate between basic object types like points, curves, surfaces, and so on.

Returns: ON::object_type enum value.

Remarks: The default implementation of this virtual function returns ON::unknown_object_type

Reimplemented from ON_Object.

◆ operator=()

ON_Light& ON_Light::operator= ( const ON_Light )

◆ PerpindicularDirection()

ON_3dVector ON_Light::PerpindicularDirection ( ) const

◆ PowerCandela()

double ON_Light::PowerCandela ( ) const

◆ PowerLumens()

double ON_Light::PowerLumens ( ) const

◆ PowerWatts()

double ON_Light::PowerWatts ( ) const

◆ Read()

bool ON_Light::Read ( ON_BinaryArchive binary_archive)

Description: Low level archive writing tool used by ON_BinaryArchive::ReadObject(). Parameters: binary_archive - archive to read from Returns: Returns true if the read is successful. Remarks: Use ON_BinaryArchive::ReadObject() to read objects. This Read() function should read the objects definition back into its data members.

The default implementation of this virtual function returns false and does nothing.

Reimplemented from ON_Object.

◆ SetAmbient()

void ON_Light::SetAmbient ( ON_Color  )


◆ SetAttenuation() [1/2]

void ON_Light::SetAttenuation ( const ON_3dVector )

◆ SetAttenuation() [2/2]

void ON_Light::SetAttenuation ( double  ,
double  ,

attenuation settings (ignored for "directional" and "ambient" lights) attenuation = 1/(a[0] + d*a[1] + d^2*a[2]) where d = distance to light

◆ SetDiffuse()

void ON_Light::SetDiffuse ( ON_Color  )

◆ SetDirection()

void ON_Light::SetDirection ( const ON_3dVector )

◆ SetHotSpot()

void ON_Light::SetHotSpot ( double  )

The hot spot setting runs from 0.0 to 1.0 and is used to provides a linear interface for controling the focus or concentration of a spotlight. A hot spot setting of 0.0 corresponds to a spot exponent of 128. A hot spot setting of 1.0 corresponds to a spot exponent of 0.0.

◆ SetIntensity()

void ON_Light::SetIntensity ( double  )

◆ SetLength()

void ON_Light::SetLength ( const ON_3dVector )

linear and rectangular light parameters (ignored for non-linear/rectangular lights)

◆ SetLightIndex()

void ON_Light::SetLightIndex ( int  )

light index

◆ SetLightName() [1/2]

void ON_Light::SetLightName ( const char *  )

light name

◆ SetLightName() [2/2]

void ON_Light::SetLightName ( const wchar_t *  )

◆ SetLocation()

void ON_Light::SetLocation ( const ON_3dPoint )

◆ SetPowerCandela()

void ON_Light::SetPowerCandela ( double  )

◆ SetPowerLumens()

void ON_Light::SetPowerLumens ( double  )

◆ SetPowerWatts()

void ON_Light::SetPowerWatts ( double  )

◆ SetShadowIntensity()

void ON_Light::SetShadowIntensity ( double  )

shadow parameters (ignored for non-spot lights)

shadow intensity 0.0 = does not cast any shadows 1.0 = casts black shadows

◆ SetSpecular()

void ON_Light::SetSpecular ( ON_Color  )

◆ SetSpotAngleDegrees()

void ON_Light::SetSpotAngleDegrees ( double  )

spot light parameters (ignored for non-spot lights)

angle = 0 to 90 degrees exponent = 0 to 128 (0=uniform, 128=high focus)

◆ SetSpotAngleRadians()

void ON_Light::SetSpotAngleRadians ( double  )

◆ SetSpotExponent()

void ON_Light::SetSpotExponent ( double  )

The spot exponent varies from 0.0 to 128.0 and provides an exponential interface for controling the focus or concentration of a spotlight (like the OpenGL GL_SPOT_EXPONENT parameter). The spot exponent and hot spot parameters are linked; changing one will change the other. A hot spot setting of 0.0 corresponds to a spot exponent of 128. A hot spot setting of 1.0 corresponds to a spot exponent of 0.0.

◆ SetStyle()

void ON_Light::SetStyle ( ON::light_style  )

style, location, and direction direction is ignored for "point" and "ambient" lights location is ignored for "directional" and "ambient" lights

◆ SetWidth()

void ON_Light::SetWidth ( const ON_3dVector )

◆ ShadowIntensity()

double ON_Light::ShadowIntensity ( ) const

◆ Specular()

ON_Color ON_Light::Specular ( ) const

◆ SpotAngleDegrees()

double ON_Light::SpotAngleDegrees ( ) const

◆ SpotAngleRadians()

double ON_Light::SpotAngleRadians ( ) const

◆ SpotExponent()

double ON_Light::SpotExponent ( ) const

◆ Style()

ON::light_style ON_Light::Style ( ) const

◆ Transform()

bool ON_Light::Transform ( const ON_Xform xform)

Description: Transforms the object.

Parameters: xform - [in] transformation to apply to object. If xform.IsSimilarity() is zero, then you may want to call MakeSquishy() before calling Transform.

Remarks: When overriding this function, be sure to include a call to ON_Object::TransformUserData() which takes care of transforming any ON_UserData that may be attached to the object.

See Also: ON_Geometry::IsDeformable();

Remarks: Classes derived from ON_Geometry should call ON_Geometry::Transform() to handle user data transformations and then transform their definition.

Reimplemented from ON_Geometry.

◆ Width()

ON_3dVector ON_Light::Width ( ) const

◆ Write()

bool ON_Light::Write ( ON_BinaryArchive ) const

Use ON_BinaryArchive::WriteObject() and ON_BinaryArchive::ReadObject() for top level serialization. These Read()/Write() members should just write/read specific definitions. In particular, they should not write/ read any chunk typecode or length information. The default implementations return false and do nothing.

Reimplemented from ON_Object.

Member Data Documentation

◆ m_ambient

ON_Color ON_Light::m_ambient

◆ m_attenuation

ON_3dVector ON_Light::m_attenuation

attenuation settings - ignored for "directional" and "ambient" lights

each entry >= 0.0 att = 1/(a[0] + d*a[1] + d^2*a[2]) where d = distance to light

◆ m_bOn

bool ON_Light::m_bOn

true if light is on

◆ m_diffuse

ON_Color ON_Light::m_diffuse

◆ m_direction

ON_3dVector ON_Light::m_direction

ignored for "point" and "ambient" lights

◆ m_hotspot

double ON_Light::m_hotspot

0.0 to 1.0 (See SetHotSpot() for details)

◆ m_intensity

double ON_Light::m_intensity

Linear dimming/brightening factor: 0.0 = off, 1.0 = 100%. Values < 0.0 and values > 1.0 are permitted but are not consistently interpreted by various renderers. Renderers should clamp the range to [0.0, 1.0] if their lighting model does not support more exotic interpretations of m_intensity.

◆ m_length

ON_3dVector ON_Light::m_length

only for linear and rectangular lights ends of linear lights are m_location and m_location+m_length

◆ m_light_id

ON_UUID ON_Light::m_light_id

◆ m_light_index

int ON_Light::m_light_index

◆ m_light_name

ON_wString ON_Light::m_light_name

◆ m_location

ON_3dPoint ON_Light::m_location

ignored for "directional" and "ambient" lights

◆ m_shadow_intensity

double ON_Light::m_shadow_intensity

shawdow casting

0.0 = no shadow casting, 1.0 = full shadow casting

◆ m_specular

ON_Color ON_Light::m_specular

◆ m_spot_angle

double ON_Light::m_spot_angle

spot settings - ignored for non-spot lights

0.0 to 90.0

◆ m_spot_exponent

double ON_Light::m_spot_exponent

0.0 to 128.0 0.0 = uniform 128.0 = high focus

◆ m_style

ON::light_style ON_Light::m_style

style of light

◆ m_watts

double ON_Light::m_watts

Used by lighting models that reference lighting fixtures. Values < 0.0 are invalid. If m_watts is 0.0, the value is ignored.

◆ m_width

ON_3dVector ON_Light::m_width

only for rectangular lights corners of rectangular lights are m_location, m_location+m_length, m_location+m_width, m_location+m_width+m_length

◆ Unset

const ON_Light ON_Light::Unset