scg3
0.6
|
A light to be applied to all nodes of its sub-tree (composite node). More...
#include "Light.h"
Public Member Functions | |
Light () | |
virtual | ~Light () |
Light * | setPosition (const glm::vec4 &position) |
Light * | setAmbient (const glm::vec4 &color) |
Light * | setDiffuse (const glm::vec4 &color) |
Light * | setSpecular (const glm::vec4 &color) |
Light * | setDiffuseAndSpecular (const glm::vec4 &color) |
Light * | setSpot (const glm::vec3 &direction, float cutoffDeg, float exponent) |
void | setModelTransform (const glm::mat4 modelTransform) |
void | init () |
virtual void | accept (Traverser *traverser) |
virtual void | acceptPost (Traverser *traverser) |
virtual void | render (RenderState *renderState) |
virtual void | renderPost (RenderState *renderState) |
Public Member Functions inherited from scg::Composite | |
Composite () | |
virtual | ~Composite ()=0 |
virtual void | destroy () |
Composite * | addChild (NodeSP child) |
Composite * | removeChild (Node *node, bool &result) |
Composite * | removeChild (Node *node) |
virtual void | traverse (Traverser *traverser) |
Public Member Functions inherited from scg::Node | |
Node () | |
virtual | ~Node ()=0 |
virtual void | clear () |
int | getNCores () const |
const std::string & | getMetaInfo (const std::string &key) const |
void | setMetaInfo (const std::string &key, const std::string &value) |
bool | isVisible () const |
void | setVisible (bool isVisible=true) |
Static Public Member Functions | |
static LightSP | create () |
Static Public Attributes | |
static const size_t | FLOAT_SIZE = 4 |
static const size_t | VEC4_SIZE = 16 |
static const size_t | POSITION_OFFSET = 0 |
static const size_t | AMBIENT_OFFSET = 16 |
static const size_t | DIFFUSE_OFFSET = 32 |
static const size_t | SPECULAR_OFFSET = 48 |
static const size_t | HALF_VECTOR_OFFSET = 64 |
static const size_t | SPOT_DIRECTION_OFFSET = 80 |
static const size_t | SPOT_COS_CUTOFF_OFFSET = 96 |
static const size_t | SPOT_EXPONENT_OFFSET = 100 |
static const size_t | BUFFER_SIZE = 112 |
Protected Attributes | |
GLuint | ubo_ |
glm::vec4 | position_ |
glm::vec4 | ambient_ |
glm::vec4 | diffuse_ |
glm::vec4 | specular_ |
glm::vec4 | spotDirection_ |
float | spotCosCutoff_ |
float | spotExponent_ |
glm::mat4 | modelTransform_ |
Protected Attributes inherited from scg::Composite | |
NodeSP | leftChild_ |
Protected Attributes inherited from scg::Node | |
NodeSP | rightSibling_ |
Composite * | parent_ |
std::vector< CoreSP > | cores_ |
bool | isVisible_ |
std::unordered_map< std::string, std::string > | metaInfo_ |
Additional Inherited Members | |
Protected Member Functions inherited from scg::Node | |
void | addSibling_ (NodeSP sibling) |
void | removeSibling_ (Node *node, bool &result) |
void | processCores_ (RenderState *renderState) |
void | postProcessCores_ (RenderState *renderState) |
A light to be applied to all nodes of its sub-tree (composite node).
The light is applied to all nodes of its sub-tree, its location within the scene graph is thus logical, not physical. The light position is given by the member variable position_, which is multiplied by the current view transformation (but not by the model transformation). A light position according to a location within the scene graph can be defined by means of a LightPosition node.
Default parameters:
position_ = (0,0,0,1) (point light)
ambient_ = (0,0,0,1)
diffuse_ = (0,0,0,1)
specular = (0,0,0,1)
spotCosCutoff = 0 (no spotlight)
spotExponent = 0
scg::Light::Light | ( | ) |
Constructor.
|
virtual |
Destructor.
|
virtual |
Accept traverser.
Reimplemented from scg::Node.
|
virtual |
Accept traverser after traversing sub-tree.
Reimplemented from scg::Composite.
|
static |
Create shared pointer.
void scg::Light::init | ( | ) |
Initialize light, i.e., create UBO.
|
virtual |
Render light, i.e., add light to render state and bind UBO.
Reimplemented from scg::Node.
|
virtual |
Render light after traversing sub-tree, i.e., remove light from render state.
Reimplemented from scg::Composite.
Light* scg::Light::setAmbient | ( | const glm::vec4 & | color | ) |
Set ambient RGBA color.
Light* scg::Light::setDiffuse | ( | const glm::vec4 & | color | ) |
Set diffuse RGBA color.
Light* scg::Light::setDiffuseAndSpecular | ( | const glm::vec4 & | color | ) |
Set diffuse and specular RGBA colors.
void scg::Light::setModelTransform | ( | const glm::mat4 | modelTransform | ) |
Set model transformation from scene graph location, to be called by PreTraverser.
Light* scg::Light::setPosition | ( | const glm::vec4 & | position | ) |
Set light position.
position | light position, with w = 0 for directional light and w = 1 for point light |
Light* scg::Light::setSpecular | ( | const glm::vec4 & | color | ) |
Set specular RGBA color.
Light* scg::Light::setSpot | ( | const glm::vec3 & | direction, |
float | cutoffDeg, | ||
float | exponent | ||
) |
Set spot parameters. Note: For the spot to be enabled the light has to be a point light (position_.w = 1.0).
direction | spot direction vector (need not be normalized) |
cutoffDeg | cutoff angle, half cone opening angle (0 to 90 degrees) |
exponent | attenuation exponent |