Class PointLight

java.lang.Object
com.ijurnove.cpu3d.Light
com.ijurnove.cpu3d.PointLight
All Implemented Interfaces:
Rotatable, Scalable, Translatable

public class PointLight extends Light implements Translatable, Rotatable, Scalable
PointLight extends the abstract class Light. A PointLight illuminates the area around it. Shadow calculations are significantly more expensive than DirectionalLights, as shadows must be calculated in all six directions.

PointLight have a decayPow field that specifies how fast the light should decay as it gets farther away from the source. For each illuminated point, the diffuse and specular light values are divided by the distance from the light source raised to the power of decayPow. The default value is 3. PointLights can be translated, rotated, and scaled.

  • Constructor Details

    • PointLight

      public PointLight(Point3d pos, PhongComponents components)
      Constructs a PointLight with a specified position and PhongComponents.
      Parameters:
      pos - the specified position
      components - the specified PhongComponents
  • Method Details

    • getPos

      public Point3d getPos()
      Returns the position as a Point3d.
      Returns:
      the position of this PointLight
    • init

      protected void init()
    • setDecay

      public void setDecay(double decay)
      Sets the decay exponent.
      Parameters:
      decay - the decay exponent
    • getDecay

      public double getDecay()
      Returns the decay exponent.
      Returns:
      the decay exponent
    • updateShadowMap

      protected void updateShadowMap()
    • shadowValue

      protected double shadowValue(Point3d point)
    • lightVec

      protected Vector3d lightVec(Point3d point)
    • distance

      protected double distance(Vector3d lightVec)
    • translate

      public void translate(double x, double y, double z)
      Description copied from interface: Translatable
      Shifts this object's X, Y, and Z position by the given values.
      Specified by:
      translate in interface Translatable
      Parameters:
      x - how far the object should be translated along the X axis
      y - how far the object should be translated along the Y axis
      z - how far the object should be translated along the Z axis
    • rotate

      public void rotate(int axis, double theta, Point3d point)
      Description copied from interface: Rotatable
      Rotates this object about a given point on a specified axis. 0 corresponds to the X axis, 1 corresponds to the Y axis, and 2 corresponds to the Z axis.
      Specified by:
      rotate in interface Rotatable
      Parameters:
      axis - the axis to rotate around
      theta - the radians to rotate by
      point - the center point to rotate around
    • scale

      public void scale(double size, Point3d point)
      Description copied from interface: Scalable
      Scales this object by a given amount from a point.
      Specified by:
      scale in interface Scalable
      Parameters:
      size - the scale multiplier
      point - the point that this object should be scaled from