public class PositionalLight extends Light
In addition to position, PositionalLight
s have
attenuation attributes which specify the rate at which their intensity
falls off as a function of distance. Three attenuation attributes are
defined: constant, linear, and quadratic attenuation.
The way in which these attenuation attributes are used is up to the client,
although the most common approach is to attenuate the light's ambient, diffuse,
and specular intensities according to the formula
attVal = intensity * (constantAtt + (1/linearAtt) + (1/(quadraticAtt^2))
Constructor and Description |
---|
PositionalLight()
Constructs a
PositionalLight with default position = [0,0,1],
default attenuation values constAtt=1.0, linearAtt=0.0, and quadraticAtt=0.0,
and with other attribute values as defined by the no-argument constructor
of superclass Light . |
Modifier and Type | Method and Description |
---|---|
float |
getConstantAtt()
Returns the value of the constant attenuation attribute of this
PositionalLight . |
float |
getLinearAtt()
Returns the value of the linear attenuation attribute of this
PositionalLight . |
Point3D |
getPosition()
Returns a
Point3D giving the position attribute of this PositionalLight . |
float |
getQuadraticAtt()
Returns the value of the quadratic attenuation attribute of this
PositionalLight . |
void |
setConstantAtt(float catt)
Sets the constant attenuation attribute of this
PositionalLight
to the specified value. |
void |
setLinearAtt(float latt)
Sets the linear attenuation attribute of this
PositionalLight
to the specified value. |
void |
setPosition(Point3D pos)
Sets the position of the
PositionalLight to the values specified
by the provided Point3D . |
void |
setQuadraticAtt(float qatt)
Sets the quadratice attenuation attribute of this
PositionalLight
to the specified value. |
java.lang.String |
toString()
Returns a String representation of this
PositionalLight containing
the light's position, attenuation factors, and the values contained
in the String returned by the superclass method Light.toString() . |
getAmbient, getDiffuse, getName, getSpecular, setAmbient, setDiffuse, setName, setSpecular
public PositionalLight()
PositionalLight
with default position = [0,0,1],
default attenuation values constAtt=1.0, linearAtt=0.0, and quadraticAtt=0.0,
and with other attribute values as defined by the no-argument constructor
of superclass Light
.public Point3D getPosition()
Point3D
giving the position attribute of this PositionalLight
.
The returned object is a clone of the light's position; subsequent changes
to the returned object have no effect on the position of the light.public void setPosition(Point3D pos)
public float getConstantAtt()
PositionalLight
.public void setConstantAtt(float catt)
PositionalLight
to the specified value.public float getLinearAtt()
PositionalLight
.public void setLinearAtt(float latt)
PositionalLight
to the specified value.public float getQuadraticAtt()
PositionalLight
.public void setQuadraticAtt(float qatt)
PositionalLight
to the specified value.public java.lang.String toString()
PositionalLight
containing
the light's position, attenuation factors, and the values contained
in the String returned by the superclass method Light.toString()
.