j3d.org Aviatrix3D

org.j3d.aviatrix3d
Class Material

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.NodeComponent
          extended byorg.j3d.aviatrix3d.Material
All Implemented Interfaces:
java.lang.Comparable

public class Material
extends NodeComponent
implements java.lang.Comparable

Describes the material properties of an object.

Version:
$Revision: 1.17 $
Author:
Alan Hudson

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
liveCount
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, updateHandler, WRITE_TIMING_MSG
 
Constructor Summary
Material()
          Constructs a material with default values.
Material(float[] ambientColor, float[] emissiveColor, float[] diffuseColor, float[] specularColor, float shininess, float transparency)
          Create a new material with all the colours specified.
 
Method Summary
 int compareTo(Material mat)
          Compares this object with the specified object for order.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(Material mat)
          Compares this object with the specified object to check for equivalence.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 void getAmbientColor(float[] col)
          Get the current value of the ambient color.
 void getDiffuseColor(float[] col)
          Get the current value of the diffuse color.
 void getEmissiveColor(float[] col)
          Get the current value of the emissive color.
 float getShininess()
          Get the current shininess value.
 void getSpecularColor(float[] col)
          Get the current value of the specular color.
 float getTransparency()
          Get the value for the existing transparency values
 boolean isLightingEnabled()
          Get the current lighting enabled flag.
 void renderState(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Issue ogl commands needed for this component
 void restoreState(net.java.games.jogl.GL gl, net.java.games.jogl.GLU glu)
          Restore all openGL state to the given drawable
 void setAmbientColor(float[] col)
          Set the ambient color to the new value.
 void setDiffuseColor(float[] col)
          Set the diffuse color to the new value.
 void setEmissiveColor(float[] col)
          Set the emissive color to the new value.
 void setLightingEnabled(boolean state)
          Set the flag that enables or disables lighting on any geometry using this material.
 void setShininess(float s)
          Set the shininess factor.
 void setSpecularColor(float[] col)
          Set the specular color to the new value.
 void setTransparency(float transparency)
          Set the amount of transparency to be used for this material.
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, hasChanged, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getUserData, isLive, setLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Material

public Material()
Constructs a material with default values.
 ambient color = (0.2, 0.2, 0.2)
 emisive color = (0.0, 0.0, 0.0)
 diffuse color = (0.8, 0.8, 0.8)
 specular color = (0, 0, 0)
 shininess = 0.2
 transparency = 1
 


Material

public Material(float[] ambientColor,
                float[] emissiveColor,
                float[] diffuseColor,
                float[] specularColor,
                float shininess,
                float transparency)
Create a new material with all the colours specified.

Parameters:
ambientColor -
emissiveColor -
diffuseColor -
specularColor -
shininess - The shininess factor value
transparency - A transparency value between 0 and 1
Method Detail

renderState

public void renderState(net.java.games.jogl.GL gl,
                        net.java.games.jogl.GLU glu)
Issue ogl commands needed for this component

Overrides:
renderState in class NodeComponent
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

restoreState

public void restoreState(net.java.games.jogl.GL gl,
                         net.java.games.jogl.GLU glu)
Restore all openGL state to the given drawable

Overrides:
restoreState in class NodeComponent
Parameters:
gl - The gl context to draw with
glu - The utility context to draw with

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Derived classes should extend this one to add the extra comparisons needed.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The object to be compared
Returns:
-1, 0 or 1 depending on order
Throws:
java.lang.ClassCastException - The specified object's type prevents it from being compared to this Object

equals

public boolean equals(java.lang.Object o)
Compare this object for equality to the given object.

Parameters:
o - The object to be compared
Returns:
True if these represent the same values

setShininess

public void setShininess(float s)
                  throws InvalidWriteTimingException
Set the shininess factor. The shininess should be a vlue between 0 and 1.

Parameters:
s - The shininess factor value
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getShininess

public float getShininess()
Get the current shininess value.

Returns:
a number between 0 and 1

setDiffuseColor

public void setDiffuseColor(float[] col)
                     throws InvalidWriteTimingException
Set the diffuse color to the new value.

Parameters:
col - The new colour to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getDiffuseColor

public void getDiffuseColor(float[] col)
Get the current value of the diffuse color.

Parameters:
col - The array to copy the values into

setSpecularColor

public void setSpecularColor(float[] col)
                      throws InvalidWriteTimingException
Set the specular color to the new value.

Parameters:
col - The new colour to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getSpecularColor

public void getSpecularColor(float[] col)
Get the current value of the specular color.

Parameters:
col - The array to copy the values into

setEmissiveColor

public void setEmissiveColor(float[] col)
                      throws InvalidWriteTimingException
Set the emissive color to the new value.

Parameters:
col - The new colour to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getEmissiveColor

public void getEmissiveColor(float[] col)
Get the current value of the emissive color.

Parameters:
col - The array to copy the values into

setAmbientColor

public void setAmbientColor(float[] col)
                     throws InvalidWriteTimingException
Set the ambient color to the new value.

Parameters:
col - The new colour to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getAmbientColor

public void getAmbientColor(float[] col)
Get the current value of the ambient color.

Parameters:
col - The array to copy the values into

setTransparency

public void setTransparency(float transparency)
                     throws InvalidWriteTimingException
Set the amount of transparency to be used for this material.

Parameters:
transparency - A value between 0 and 1
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getTransparency

public float getTransparency()
Get the value for the existing transparency values

Returns:
The current transparency setting

setLightingEnabled

public void setLightingEnabled(boolean state)
                        throws InvalidWriteTimingException
Set the flag that enables or disables lighting on any geometry using this material.

Parameters:
state - true if lighting should be used
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

isLightingEnabled

public boolean isLightingEnabled()
Get the current lighting enabled flag.


compareTo

public int compareTo(Material mat)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
mat - The material to be compared
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(Material mat)
Compares this object with the specified object to check for equivalence.

Parameters:
mat - The material to be compared
Returns:
true if the objects represent identical values

j3d.org Aviatrix3D

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - j3d.org