Class SoftwareLightPoint

  • Direct Known Subclasses:
    SoftwareLightSpot

    public class SoftwareLightPoint
    extends SoftwareLight
    The class for point lights in a general lighting system to calculate diffuse and specular colors at a point in space.

    See ShearWarpRendering.pdf for a detailed description of the lighting model.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) javax.vecmath.Color3f ambientColor
      DOCUMENT ME!
      (package private) float cos_alpha
      DOCUMENT ME!
      (package private) float cos_theta
      DOCUMENT ME!
      (package private) javax.vecmath.Color3f diffuseColor
      DOCUMENT ME!
      (package private) javax.vecmath.Vector3f L
      DOCUMENT ME!
      protected boolean m_bAttenuate
      DOCUMENT ME!
      protected float m_fA0
      Attenuation coefficients (inverse quadratic attenuation).
      protected float m_fA1
      Attenuation coefficients (inverse quadratic attenuation).
      protected float m_fA2
      Attenuation coefficients (inverse quadratic attenuation).
      protected javax.vecmath.Vector3f m_kDirection
      To avoid memory allocations.
      (package private) javax.vecmath.Vector3f N
      DOCUMENT ME!
      protected javax.vecmath.Point3f position
      the light's position.
      (package private) javax.vecmath.Vector3f R
      DOCUMENT ME!
      (package private) javax.vecmath.Color3f result
      DOCUMENT ME!
      (package private) javax.vecmath.Color3f specularColor
      DOCUMENT ME!
      (package private) javax.vecmath.Vector3f V
      DOCUMENT ME!
      (package private) javax.vecmath.Color3f vertexDiffuse
      DOCUMENT ME!
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.vecmath.Color3f colorOf​(SoftwareMaterial kMaterial, SoftwareVertexProperty kVertexProperty, javax.vecmath.Point3f kEye)
      Compute the contribution of color from this light on the specified material with specified vertex properties.
      protected void computeAttenuation​(float fDistance)
      Compute the attenuation factor as an inverse quadratic polynomial.
      SoftwareLight copy()
      Create a deep copy of this Light instance.
      float getAttenuation0()
      Get the constant term of the attenuation polynomial.
      float getAttenuation1()
      Get the linear term of the attenuation polynomial.
      float getAttenuation2()
      Get the quadratic term of the attenuation polynomial.
      javax.vecmath.Point3f getPosition()
      Get the light source position.
      void setAttenuation​(float fA0, float fA1, float fA2)
      Set the coefficients for inverse quadratic attenuation, attenuation = 1/(a0+a1*d+a2*d^2) where d is the distance from the light's position to the vertex.
      void setPosition​(float fX, float fY, float fZ)
      Set the light source position.
      void setPosition​(javax.vecmath.Point3f p)
      Set the light source position.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_bAttenuate

        protected boolean m_bAttenuate
        DOCUMENT ME!
      • m_fA0

        protected float m_fA0
        Attenuation coefficients (inverse quadratic attenuation). The Boolean flag is 'false' whenever (a0,a1,a2) = (1,0,0), in which case the inverse quadratic attenuation is the identity mapping and no execution time should be spent evaluating the attenuation factor.
      • m_fA1

        protected float m_fA1
        Attenuation coefficients (inverse quadratic attenuation). The Boolean flag is 'false' whenever (a0,a1,a2) = (1,0,0), in which case the inverse quadratic attenuation is the identity mapping and no execution time should be spent evaluating the attenuation factor.
      • m_fA2

        protected float m_fA2
        Attenuation coefficients (inverse quadratic attenuation). The Boolean flag is 'false' whenever (a0,a1,a2) = (1,0,0), in which case the inverse quadratic attenuation is the identity mapping and no execution time should be spent evaluating the attenuation factor.
      • m_kDirection

        protected final javax.vecmath.Vector3f m_kDirection
        To avoid memory allocations. The vector is used to store the difference between a vertex to be lit and the light's position.
      • position

        protected final javax.vecmath.Point3f position
        the light's position.
      • ambientColor

        javax.vecmath.Color3f ambientColor
        DOCUMENT ME!
      • cos_theta

        float cos_theta
        DOCUMENT ME!
      • cos_alpha

        float cos_alpha
        DOCUMENT ME!
      • diffuseColor

        javax.vecmath.Color3f diffuseColor
        DOCUMENT ME!
      • L

        javax.vecmath.Vector3f L
        DOCUMENT ME!
      • N

        javax.vecmath.Vector3f N
        DOCUMENT ME!
      • R

        javax.vecmath.Vector3f R
        DOCUMENT ME!
      • result

        javax.vecmath.Color3f result
        DOCUMENT ME!
      • specularColor

        javax.vecmath.Color3f specularColor
        DOCUMENT ME!
      • V

        javax.vecmath.Vector3f V
        DOCUMENT ME!
      • vertexDiffuse

        javax.vecmath.Color3f vertexDiffuse
        DOCUMENT ME!
    • Constructor Detail

      • SoftwareLightPoint

        public SoftwareLightPoint()
        Construct a point light. The default colors are all black, the intensity is zero, and the light is off. The attenuation parameters are initialized to 1 (no attenuation). The light is positioned by default at the origin.
      • SoftwareLightPoint

        public SoftwareLightPoint​(SoftwareLightPoint kThat)
        Copy (deep) constructor.
        Parameters:
        kThat - Light What to make "this" light like.
    • Method Detail

      • colorOf

        public javax.vecmath.Color3f colorOf​(SoftwareMaterial kMaterial,
                                             SoftwareVertexProperty kVertexProperty,
                                             javax.vecmath.Point3f kEye)
        Compute the contribution of color from this light on the specified material with specified vertex properties.
        Specified by:
        colorOf in class SoftwareLight
        Parameters:
        kMaterial - SoftwareMaterial Default properties for the material including emissive, ambient, diffuse, and specular colors along with the specular shininess which can be used to disable specular highlighting.
        kVertexProperty - SoftwareVertexProperty Properties of the vertex which include its position and normal vector along with optional material property overrides for the diffuse and specular colors.
        kEye - Point3f The location of the observer in the coordinate system defined for the light.
        Returns:
        Color3f Reference to the computed color contribution by this light with this vertex and its material properties. The instance returned is owned by this light.
      • copy

        public SoftwareLight copy()
        Create a deep copy of this Light instance.
        Specified by:
        copy in class SoftwareLight
        Returns:
        Light Deep copy of this Light instance.
      • getAttenuation0

        public float getAttenuation0()
        Get the constant term of the attenuation polynomial.
        Returns:
        coefficient a0
      • getAttenuation1

        public float getAttenuation1()
        Get the linear term of the attenuation polynomial.
        Returns:
        coefficient a1
      • getAttenuation2

        public float getAttenuation2()
        Get the quadratic term of the attenuation polynomial.
        Returns:
        coefficient a2
      • getPosition

        public javax.vecmath.Point3f getPosition()
        Get the light source position.
        Returns:
        position light source position
      • setAttenuation

        public void setAttenuation​(float fA0,
                                   float fA1,
                                   float fA2)
        Set the coefficients for inverse quadratic attenuation, attenuation = 1/(a0+a1*d+a2*d^2) where d is the distance from the light's position to the vertex. The coefficients must satisfy a0 >= 0, a1 >= 0, and a2 >= 0, but not all can be zero. No attenuation occurs when a0 = 1, a1 = 0, and a2 = 0.
        Parameters:
        fA0 - coefficient a0
        fA1 - coefficient a1
        fA2 - coefficient a2
      • setPosition

        public void setPosition​(javax.vecmath.Point3f p)
        Set the light source position.
        Parameters:
        p - source position
      • setPosition

        public void setPosition​(float fX,
                                float fY,
                                float fZ)
        Set the light source position.
        Parameters:
        fX - float X coordinate of light source position.
        fY - float Y coordinate of light source position.
        fZ - float Z coordinate of light source position.
      • computeAttenuation

        protected void computeAttenuation​(float fDistance)
        Compute the attenuation factor as an inverse quadratic polynomial.
        Parameters:
        fDistance - the distance from the light's position to the vertex to be lit