Panda3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Light Class Referenceabstract

The abstract interface to all kinds of lights. More...

#include "light.h"

Inheritance diagram for Light:
LightLensNode LightNode DirectionalLight PointLight RectangleLight Spotlight AmbientLight SphereLight

Public Member Functions

 Light (const Light &copy)
 
virtual PandaNodeas_node ()=0
 
virtual void attrib_ref ()
 This is called when the light is added to a LightAttrib. More...
 
virtual void attrib_unref ()
 This is called when the light is removed from a LightAttrib. More...
 
virtual void bind (GraphicsStateGuardianBase *gsg, const NodePath &light, int light_id)=0
 
virtual const LVecBase3 & get_attenuation () const
 Returns the terms of the attenuation equation for the light. More...
 
virtual int get_class_priority () const =0
 
const LColor & get_color () const
 
PN_stdfloat get_color_temperature () const
 
virtual PN_stdfloat get_exponent () const
 For spotlights, returns the exponent that controls the amount of light falloff from the center of the spotlight. More...
 
int get_priority () const
 
virtual const LColor & get_specular_color () const
 Returns the color of specular highlights generated by the light. More...
 
virtual TypeHandle get_type () const
 
virtual bool get_vector_to_light (LVector3 &result, const LPoint3 &from_object_point, const LMatrix4 &to_object_space)
 Computes the vector from a particular vertex to this light. More...
 
GeomNodeget_viz ()
 Returns a GeomNode that may be rendered to visualize the Light. More...
 
bool has_color_temperature () const
 Returns true if the color was specified as a temperature in kelvins, and get_color_temperature is defined. More...
 
virtual bool is_ambient_light () const
 Returns true if this is an AmbientLight, false if it is some other kind of light. More...
 
virtual void output (std::ostream &out) const =0
 
void set_color (const LColor &color)
 
void set_color_temperature (PN_stdfloat temperature)
 
void set_priority (int priority)
 
virtual void write (std::ostream &out, int indent_level) const =0
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static UpdateSeq get_sort_seq ()
 Returns a global sequence number that is incremented any time any Light in the world changes sort or priority. More...
 
static void init_type ()
 

Public Attributes

 get_color
 Returns the basic color of the light. More...
 
 get_color_temperature
 Returns the basic color temperature of the light, assuming has_color_temperature() returns true. More...
 
 get_priority
 Returns the priority associated with this light. More...
 
 set_color
 Sets the basic color of the light. More...
 
 set_color_temperature
 Sets the color temperature of the light in kelvins. More...
 
 set_priority
 Changes the relative importance of this light relative to the other lights that are applied simultaneously. More...
 

Detailed Description

The abstract interface to all kinds of lights.

The actual light objects also inherit from PandaNode, and can therefore be added to the scene graph at some arbitrary point to define the coordinate system of effect.

Definition at line 38 of file light.h.

Member Function Documentation

◆ attrib_ref()

void Light::attrib_ref ( )
virtual

This is called when the light is added to a LightAttrib.

Reimplemented in LightLensNode.

Definition at line 166 of file light.cxx.

◆ attrib_unref()

void Light::attrib_unref ( )
virtual

This is called when the light is removed from a LightAttrib.

Reimplemented in LightLensNode.

Definition at line 173 of file light.cxx.

Referenced by LightAttrib::~LightAttrib().

◆ get_attenuation()

const LVecBase3 & Light::get_attenuation ( ) const
virtual

Returns the terms of the attenuation equation for the light.

These are, in order, the constant, linear, and quadratic terms based on the distance from the point to the vertex.

Reimplemented in Spotlight, and PointLight.

Definition at line 157 of file light.cxx.

◆ get_exponent()

PN_stdfloat Light::get_exponent ( ) const
virtual

For spotlights, returns the exponent that controls the amount of light falloff from the center of the spotlight.

For other kinds of lights, returns 0.

Reimplemented in Spotlight.

Definition at line 137 of file light.cxx.

◆ get_sort_seq()

UpdateSeq Light::get_sort_seq ( )
inlinestatic

Returns a global sequence number that is incremented any time any Light in the world changes sort or priority.

This is used by LightAttrib to determine when it is necessary to re-sort its internal array of stages.

Definition at line 134 of file light.I.

◆ get_specular_color()

const LColor & Light::get_specular_color ( ) const
virtual

Returns the color of specular highlights generated by the light.

This value is meaningless for ambient lights.

Reimplemented in Spotlight, DirectionalLight, PointLight, and RectangleLight.

Definition at line 146 of file light.cxx.

◆ get_vector_to_light()

bool Light::get_vector_to_light ( LVector3 &  result,
const LPoint3 &  from_object_point,
const LMatrix4 &  to_object_space 
)
virtual

Computes the vector from a particular vertex to this light.

The exact vector depends on the type of light (e.g. point lights return a different result than directional lights).

The input parameters are the vertex position in question, expressed in object space, and the matrix which converts from light space to object space. The result is expressed in object space.

The return value is true if the result is successful, or false if it cannot be computed (e.g. for an ambient light).

Reimplemented in Spotlight, DirectionalLight, and PointLight.

Definition at line 189 of file light.cxx.

◆ get_viz()

GeomNode * Light::get_viz ( )

Returns a GeomNode that may be rendered to visualize the Light.

This is used during the cull traversal to render the Lights that have been made visible.

Definition at line 199 of file light.cxx.

◆ has_color_temperature()

bool Light::has_color_temperature ( ) const
inline

Returns true if the color was specified as a temperature in kelvins, and get_color_temperature is defined.

Since
1.10.0

Definition at line 85 of file light.I.

◆ is_ambient_light()

bool Light::is_ambient_light ( ) const
virtual

Returns true if this is an AmbientLight, false if it is some other kind of light.

Reimplemented in AmbientLight.

Definition at line 63 of file light.cxx.

Member Data Documentation

◆ get_color

const LColor & Light::get_color
inline

Returns the basic color of the light.

Definition at line 49 of file light.h.

Referenced by RectangleLight::get_specular_color().

◆ get_color_temperature

PN_stdfloat Light::get_color_temperature
inline

Returns the basic color temperature of the light, assuming has_color_temperature() returns true.

Since
1.10.0

Definition at line 55 of file light.h.

◆ get_priority

int Light::get_priority
inline

Returns the priority associated with this light.

See set_priority().

Definition at line 64 of file light.h.

◆ set_color

void Light::set_color
inline

Sets the basic color of the light.

Definition at line 49 of file light.h.

◆ set_color_temperature

void Light::set_color_temperature

Sets the color temperature of the light in kelvins.

This will recalculate the light's color.

The default value is 6500 K, corresponding to a perfectly white light assuming a D65 white point.

Since
1.10.0

Definition at line 55 of file light.h.

◆ set_priority

void Light::set_priority
inline

Changes the relative importance of this light relative to the other lights that are applied simultaneously.

The priority number is used to decide which of the requested lights are to be selected for rendering when more lights are requested than the hardware will support. The highest-priority n lights are selected for rendering.

This is similar to TextureStage::set_priority().

Definition at line 64 of file light.h.


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