Class PhongMaterial



  • public class PhongMaterial
    extends Material
    The PhongMaterial class provides definitions of properties that represent a Phong shaded material. It describes the interaction of light with the surface of the Mesh it is applied to. The PhongMaterial reflects light in terms of a diffuse and specular component together with an ambient and a self illumination term. The color of a point on a geometric surface is mathematical function of these four components.

    The color is computed by the following equation:

    
     for each ambient light source i {
         ambient += lightColor[i]
     }
    
     for each point light source i {
         diffuse += (L[i] . N) * lightColor[i]
         specular += ((R[i] . V) ^ (specularPower * intensity(specularMap))) * lightColor[i]
     }
    
     color = (ambient + diffuse) * diffuseColor * diffuseMap
                 + specular * specularColor * specularMap
                 + selfIlluminationMap
     
    where lightColor[i] is the color of light source i,
    L[i] is the vector from the surface to light source i,
    N is the normal vector (taking into the account the bumpMap if present),
    R[i] is the normalized reflection vector for L[i] about the surface normal,
    and V is the normalized view vector.
    Since:
    JavaFX 8.0
    See Also:
    AmbientLight, PointLight
    • Constructor Detail

      • PhongMaterial

        public PhongMaterial​()
        Creates a new instance of PhongMaterial class with a default Color.WHITE diffuseColor property.
      • PhongMaterial

        public PhongMaterial​(Color diffuseColor)
        Creates a new instance of PhongMaterial class using the specified color for its diffuseColor property.
        Parameters:
        diffuseColor - the color of the diffuseColor property
      • PhongMaterial

        public PhongMaterial​(Color diffuseColor,
                             Image diffuseMap,
                             Image specularMap,
                             Image bumpMap,
                             Image selfIlluminationMap)
        Creates a new instance of PhongMaterial class using the specified colors and images for its diffuseColor properties.
        Parameters:
        diffuseColor - the color of the diffuseColor property
        diffuseMap - the image of the diffuseMap property
        specularMap - the image of the specularMap property
        bumpMap - the image of the bumpMap property
        selfIlluminationMap - the image of the selfIlluminationMap property
    • Method Detail

      • setDiffuseColor

        public final void setDiffuseColor​(Color value)
        Sets the value of the property diffuseColor.
        Property description:
        The diffuse color of this PhongMaterial.
        Default value:
        Color.WHITE
      • getDiffuseColor

        public final Color getDiffuseColor​()
        Gets the value of the property diffuseColor.
        Property description:
        The diffuse color of this PhongMaterial.
        Default value:
        Color.WHITE
      • setSpecularColor

        public final void setSpecularColor​(Color value)
        Sets the value of the property specularColor.
        Property description:
        The specular color of this PhongMaterial.
        Default value:
        null
      • getSpecularColor

        public final Color getSpecularColor​()
        Gets the value of the property specularColor.
        Property description:
        The specular color of this PhongMaterial.
        Default value:
        null
      • setSpecularPower

        public final void setSpecularPower​(double value)
        Sets the value of the property specularPower.
        Property description:
        The specular power of this PhongMaterial.
        Default value:
        32.0
      • getSpecularPower

        public final double getSpecularPower​()
        Gets the value of the property specularPower.
        Property description:
        The specular power of this PhongMaterial.
        Default value:
        32.0
      • setDiffuseMap

        public final void setDiffuseMap​(Image value)
        Sets the value of the property diffuseMap.
        Property description:
        The diffuse map of this PhongMaterial.
        Default value:
        null
      • getDiffuseMap

        public final Image getDiffuseMap​()
        Gets the value of the property diffuseMap.
        Property description:
        The diffuse map of this PhongMaterial.
        Default value:
        null
      • setSpecularMap

        public final void setSpecularMap​(Image value)
        Sets the value of the property specularMap.
        Property description:
        The specular map of this PhongMaterial.
        Default value:
        null
      • getSpecularMap

        public final Image getSpecularMap​()
        Gets the value of the property specularMap.
        Property description:
        The specular map of this PhongMaterial.
        Default value:
        null
      • setBumpMap

        public final void setBumpMap​(Image value)
        Sets the value of the property bumpMap.
        Property description:
        The bump map of this PhongMaterial, which is a normal map stored as a RGB Image.
        Default value:
        null
      • getBumpMap

        public final Image getBumpMap​()
        Gets the value of the property bumpMap.
        Property description:
        The bump map of this PhongMaterial, which is a normal map stored as a RGB Image.
        Default value:
        null
      • setSelfIlluminationMap

        public final void setSelfIlluminationMap​(Image value)
        Sets the value of the property selfIlluminationMap.
        Property description:
        The self illumination map of this PhongMaterial.
        Default value:
        null
      • getSelfIlluminationMap

        public final Image getSelfIlluminationMap​()
        Gets the value of the property selfIlluminationMap.
        Property description:
        The self illumination map of this PhongMaterial.
        Default value:
        null
      • toString

        public String toString​()
        Description copied from class: Object
        Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

        The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

         getClass().getName() + '@' + Integer.toHexString(hashCode())
         
        Overrides:
        toString in class Object
        Returns:
        a string representation of the object.