yage.scene.light
Authors:
Eric Poggel
License:
LGPL v3
- class
LightNode
: yage.scene.movable.MovableNode;
- LightNodes are Nodes that emit light.
Opengl hardware lights are used by default, but shaders can be used to go
beyond their capabilities.
All color values are floating point in the range from 0 to 1 and in the order
of red, green, blue and alpha. For example,
(1, .5, 0, 0) is orange, since it is 100% red and 50% green.
Spotlights default to shining in the -z direction (the same as the default looking direction of the camera).
They can be rotated by rotating the Node itself.
- enum
Type
;
- Values that can be assigned to type.
-
DIRECTIONAL
- A light that shines in one direction through the entire scene
-
POINT
- A light that shines outward in all directions
-
SPOT
- A light that emits light outward from a point in a single direction
- Type
type
;
- The
type
of light (directional, point, or spot)
- Color
ambient
;
- Ambient color of the light. Defaults to black
- Color
diffuse
;
- Diffuse color of the light. Defaults to 100% white.
- Color
specular
;
- Specular color of the light, defaults to 100% white.
- float
spotAngle
;
- Spotlight angle of the light, in radians.
If the light type is a spotlight, this is the angle of the light cone.
- float
spotExponent
;
- Spotlight exponent of the light.
If the light type is a spotlight, this is how focussed the light is.
Larger values produce brighter concentrations of light in the center of the circle
A value of 0 provides an even distribution of light across the entire spot circle.
- LightNode
clone
(bool children = false);
- Make a duplicate of this node, unattached to any parent Node.
Params:
bool children |
recursively
clone
children (and descendants) and add them as children to the new Node. |
Returns:
The cloned Node.
- float
getLightRadius
();
void
setLightRadius
(float radius);
- Get / set the radius of the light. Default value is 256.
Quadratic attenuation is used, so the brightness of an object is Radius^2/distance^2,
Using this formula, a brightness of 1.0 or higher is 100% bright.
- float
getQuadraticAttenuation
();
- Get the quadratic attenuation calculated from the light's radius.
- Color
getBrightness
(Vec3f point, float margin = 0F);
- Return the RGB brightness this light contributes to a given point in 3D space, relative to this light's scene.
OpenGl's fixed-function, traditional lighting calculations are used.
The diffuse and ambient values of the light are taken into effect,
while the specular is not, since it depends on the viewing angle of the camera.
Also note that this does not take into account shadows or anything of that nature.
Params:
Vec3f point |
3D coordinates of the point to be evaluated. |
float margin |
For spotlights, setting a margin cause this function to return brightest point inside
of that radius, instead of the default of a single point.
This is used internally for nodes that have a spotlight shine on one corner of them
but not at all at their center. |
|