net.jinx.video
Class Material

java.lang.Object
  extended by net.jinx.video.Material
All Implemented Interfaces:
Coloration

public class Material
extends java.lang.Object
implements Coloration

Material objects hold values for the colors of vertices and lights. They're composed of three, four element arrays of floats. In order, these elements are red, green, blue and alpha transparency values. Each material also has a shininess value, but this is only used for vertices, not lights.
The three arrays, in order, are for ambient, diffuse, and specular lighting.

API Stability: Stable.


Constructor Summary
Material()
          Constructs a default white Material.
Material(float[] ambient, float[] diffuse, float[] specular, float shininess)
          Constructs a Material with ambient, diffuse, specular and shininess components.
Material(float[] ambient, float[] diffuse, float[] specular, float[] emission, float shininess)
          Constructs a Material object using the given color values.
 
Method Summary
 java.lang.Object clone()
           
 void draw(Context opt)
          "Draws" the Material, causing any vertices that come after it to be colored with the material.
 void draw(Context opt, int number, float[] vertex)
          Causes the Coloration to be drawn.
 Material duplicate()
           
 boolean equals(java.lang.Object o)
           
 float[] getAmbient()
          Provides the ambient portion of the color.
 float[] getDiffuse()
          Provides the diffuse portion of the color.
 float[] getEmission()
          Provides the emissive portion of the color.
 float getShininess()
          Provides the shininess value of the color.
 float[] getSpecular()
          Provides the specular portion of the color.
static void interpolate(Material a, Material b, Material c, float i)
           
 void load(Hierarchy h)
          Configures this Coloration from the given Hierarchy.
 void setShininess(float shininess)
          Allows setting the shininess of the Material.
 void store(Hierarchy h)
          Stores this Coloration to the given Hierarchy.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Material

public Material()
Constructs a default white Material.


Material

public Material(float[] ambient,
                float[] diffuse,
                float[] specular,
                float shininess)
Constructs a Material with ambient, diffuse, specular and shininess components.

Parameters:
ambient - the ambient part.
diffuse - the diffuse part.
specular - the specular part.
shininess - the shininess part.

Material

public Material(float[] ambient,
                float[] diffuse,
                float[] specular,
                float[] emission,
                float shininess)
Constructs a Material object using the given color values.

Parameters:
ambient - the ambient color array.
diffuse - the diffuse color array.
specular - the specular color array.
shininess - the shininess value.
Method Detail

getAmbient

public float[] getAmbient()
Provides the ambient portion of the color.

Returns:
the ambient color array from the constructor.

getDiffuse

public float[] getDiffuse()
Provides the diffuse portion of the color.

Returns:
the diffuse color array from the constructor.

getSpecular

public float[] getSpecular()
Provides the specular portion of the color.

Returns:
the specular color array from the constructor.

getEmission

public float[] getEmission()
Provides the emissive portion of the color.

Returns:
the emissive color array from the constructor.

getShininess

public float getShininess()
Provides the shininess value of the color.

Returns:
the shininess value.

setShininess

public void setShininess(float shininess)
Allows setting the shininess of the Material.

Parameters:
shininess - the shininess value.

draw

public void draw(Context opt,
                 int number,
                 float[] vertex)
Description copied from interface: Coloration
Causes the Coloration to be drawn. This should simply setup the OpenGL state according to the color that should be used.

Specified by:
draw in interface Coloration
Parameters:
opt - the rendering options that are being used. Implementatons of this interface should pay attention to the color related flags.
number - the current vertex number.
vertex - the current vertex position (x, y, and z coordinates).

draw

public void draw(Context opt)
"Draws" the Material, causing any vertices that come after it to be colored with the material.

Parameters:
opt - the Context object for rendering.

load

public void load(Hierarchy h)
Description copied from interface: Coloration
Configures this Coloration from the given Hierarchy. This is not meant to be called directly, unless you intend to configure a specific Coloration object.
This method is actually designed to be called by the loadColoration(net.jinx.db.Hierarchy) method of ModelUtil, which will construct and return an instance of any Coloration class. This is the reason that all Coloration classes must have a no argument constructor. ModelUtil.loadColoration(net.jinx.db.Hierarchy) needs that to do it's job. By the time this method is called, the type of the coloration has already been determined and constructed and is now ready to be configured.

Specified by:
load in interface Coloration
Parameters:
h - the Hierarchy to configure this Coloration from.

store

public void store(Hierarchy h)
Description copied from interface: Coloration
Stores this Coloration to the given Hierarchy. This is not meant to be called directly, unless you know you're going to be using a specific Coloration implementation.
This method is actually designed to be called by the store(net.jinx.db.Hierarchy, Coloration) method of ModelUtil, which stores the name of the class to use, so that when the loadColoration(net.jinx.db.Hierarchy) method of ModelUtil is used, the class can be instantiated and used.

Specified by:
store in interface Coloration
Parameters:
h - the Hierarchy to store this Coloration to.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

duplicate

public Material duplicate()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

interpolate

public static void interpolate(Material a,
                               Material b,
                               Material c,
                               float i)