public class SpotLight extends PositionalLight
PositionalLight
which is a spot light; that is,
a light which has a direction together with values
cutoffAngle and falloffExponent defining a cone which restricts
the light (much like a lamp shade) as it shines in the specified direction.
SpotLight
s also of course have all the attributes inherited from
parent classes, including position, attenuation factors, and
ambient, diffuse, and specular intensities
The cutoffangle of a SpotLight
specifies the "half-angle"
of the cone restricting the light, in degrees; the allowable range of the
cone half-angle is [0..90] (a value of 90 represents a SpotLight
with a 180 degree field, such as a wall-mounted fish-eye bulb.
The falloff exponent of a SpotLight
is intended to represent the rate of
fall-off of light intensity as the direction to an illuminated object deviates from the
SpotLight
's direction.
The actual meaning and usage of both the cutoffAngle and the falloff exponent are up to the client code.
Constructor and Description |
---|
SpotLight()
Constructs a
SpotLight with default direction [0,0,-1],
cutoffAngle = 45 degrees, default exponent = 2.0,
and with other attribute values as defined by the no-argument constructor
of superclass PositionalLight . |
Modifier and Type | Method and Description |
---|---|
float |
getCutoffAngle()
Returns the value of the cutoff angle attribute of this
SpotLight . |
Vector3D |
getDirection()
Returns a
Vector3D giving the direction attribute of this
SpotLight . |
float |
getFalloffExponent()
Returns the value of the falloff exponent attribute of this
SpotLight . |
void |
setCutoffAngle(float degrees)
Sets the cutoff angle attribute of this
SpotLight
to the specified value. |
void |
setDirection(Vector3D dir)
Sets the direction of the cone constraining the
SpotLight to the values specified
by the provided Vector3D . |
void |
setFalloffExponent(float exp)
Sets the falloff exponent attribute of this
SpotLight
to the specified value. |
java.lang.String |
toString()
Returns a String representation of this
SpotLight containing
the light's direction, cutoff angle, and falloff exponent
values and the values contained
in the String returned by the superclass method PositionalLight.toString() . |
getConstantAtt, getLinearAtt, getPosition, getQuadraticAtt, setConstantAtt, setLinearAtt, setPosition, setQuadraticAtt
getAmbient, getDiffuse, getName, getSpecular, setAmbient, setDiffuse, setName, setSpecular
public SpotLight()
SpotLight
with default direction [0,0,-1],
cutoffAngle = 45 degrees, default exponent = 2.0,
and with other attribute values as defined by the no-argument constructor
of superclass PositionalLight
.public Vector3D getDirection()
Vector3D
giving the direction attribute of this
SpotLight
. Note that direction refers to the center-line
of the cone constraining the spot light (similar to a lamp shade); not to
be confused with the "direction" value associated with DistantLight
s.
The returned object is a clone of the light's direction; subsequent changes
to the returned object have no effect on the direction of the light.public void setDirection(Vector3D dir)
SpotLight
to the values specified
by the provided Vector3D
.
The provided object is cloned before setting the light's values;
subsequent changes to the specified object have no effect on the light.public float getCutoffAngle()
SpotLight
. Cutoff angle is the half-angle of the
cone restricting the SpotLight
.public void setCutoffAngle(float degrees)
SpotLight
to the specified value. The cutoff angle for SpotLight
s is
normally a value given in degrees.public float getFalloffExponent()
SpotLight
. The falloff exponent is normally used as the
exponent in a function controlling the rate of reduction of light
intensity as position moves away from the primary direction of the
SpotLight
.public void setFalloffExponent(float exp)
SpotLight
to the specified value.public java.lang.String toString()
SpotLight
containing
the light's direction, cutoff angle, and falloff exponent
values and the values contained
in the String returned by the superclass method PositionalLight.toString()
.toString
in class PositionalLight