Encapsulates methods common to all lights.
#include <AlLight.h>
class AlLight : public AlObject , public AlAnimatable
virtual ~AlLight();
virtual statusCode deleteObject();
virtual AlObjectType type() const;
virtual const char* name() const;
virtual statusCode setName( const char* );
statusCode parameter( const AlLightFields, double& ) const;
statusCode setParameter( const AlLightFields, const double );
AlLightNode* lightNode() const;
virtual AlLightNode* lookAtNode() const;
virtual AlLightNode* upNode() const;
boolean hasLinkedObjects() const;
AlObject* firstLinkedObject() const;
AlObject* nextLinkedObject( AlObject * ) const;
statusCode applyIteratorToLinkedObjects( AlIterator *iter, int& rc );
statusCode linkObjectToLight( AlObject * );
statusCode unlinkObjectFromLight( AlObject * );
boolean exclusivity() const;
statusCode setExclusivity( boolean );
statusCode color( double&, double&, double& ) const;
statusCode setColor( double, double, double );
statusCode worldPosition( double&, double&, double& ) const;
This virtual class contains methods which are common to all types of lights. This includes color, linkage to objects and exclusivity.
To create a light, the user must instantiate and call the create method of a specific type of light (eg. a point light or a spot light). When a light is created, three light nodes are created, grouped under a group node, which is inserted into the universe’s DAG. These light nodes represent the position, "look at" and "up" points of the light.
Even though three light nodes are created for all lights, only the spot light class uses the information in the "look at" and "up" nodes. All other classes either don’t have a direction or store direction in a different manner. The direction vector of a spot light is the vector between its position point and its "look at" point. The "up" direction vector of a spot light is the vector between its position point and its "up" point.
There are two ways to delete a light object. When an AlLight object is deleted, its three light nodes are deleted. Alternatively, when a light node is deleted, its associated light (and other light nodes) are deleted. The group node that originally grouped the position, "look at" and "up" nodes is not deleted.
The light classes are derived as follows, where a class inherits the functionality defined in the class above it. The user can only instantiate ambient, point, direction, spot, linear and area lights.
For directional lights, the light positions are (in Z-up coordinate system) position at (0,0,0), view at (0,0,-1), and up at (0,1,-1). For linear lights, the axis by default starts at the position point and extends (2,0,0). For area lights, the short axis starts at the position point and extends (0,1,0); the long axis starts at the position point and extends (2,0,0).
All lights have an "exclusive" flag. If this flag is TRUE, then the light will only illuminate objects to which it is linked. If the flag is FALSE, the light will illuminate objects that have no light links. The default for new lights is FALSE.
statusCode AlLight::setParameter( const AlLightFields field,const double value)
statusCode AlLight::color( double &r, double &g, double &b) const
Returns the color of the light in r,g & b, (for red, green and blue). Valid values for r,g & b are between 0.0 and 255.0.
AlObject* AlLight::nextLinkedObject( AlObject* toThis ) const
Returns a pointer to the object following the given object that is linked to this light. NULL is returned if there is no following object. NULL is returned if the given AlObject wasn’t found in the light list. Only objects with 3D geometry can be linked to a light. Cameras, lights, curves and CVs cannot be linked to a light. Surfaces and faces can be linked to a light.
statusCode AlLight::applyIteratorToLinkedObjects( AlIterator *iter, int& rc )
statusCode AlLight::linkObjectToLight( AlObject *obj )
Links the given object to the light. If the light’s exclusive flag is on, then the light will only illuminate objects to which it is linked. Only objects with 3D geometry can be linked to a light. Cameras, lights, curves and CVs cannot be linked to a light. Surfaces, faces, and shells can be linked to a light.
statusCode AlLight::worldPosition( double &x, double &y, double &z ) const
Returns the point in world space where this light is positioned. This is the same as the position of the position light node.