|
Aviatrix3D 2.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.aviatrix3d.SceneGraphObject org.j3d.aviatrix3d.NodeComponent org.j3d.aviatrix3d.Material
public class Material
Describes the material properties of an object.
Materials may be either single or double sided for an object. By default,
this class sets up for single-sided rendering. All material values are sent
to OpenGL as GL_FRONT_AND_BACK for the target unless otherwise specified.
Whatever these settings, the values will not be used unless the two-sided
lighting value is also enabled on the PolygonAttributes
that
accompanies this material. Without that turned on, the back-face material
values defined here will not be used by OpenGL.
Because the material node is used almost everywhere in scene graphs, and
two-sided material handling uses twice the amount of memory, we've made some
special rules about using it in order to reduce memory footprint. As the
use of separate front and back face colours are relatively rare in use, we
don't allocate the internal memory for their storage unless the flag is
turned on. This then forces another interaction rule. The memory structures
won't be in place unless the flag is turned on, so if you attempted to read
or write to them when the flag is turned off, NullPointerExceptions will be
generated all over the place. To prevent this, we perform a check before
every back-face access to make sure that the flag is currently set, and if
not, will issue our own exception IllegalStateException
.
The default values for this class mirror the OpenGL defaults:
BlendAttributes
object for this. If you also happen to provide a
BlendAttributes
instance to the containing appearance, that will
override what happens internally to this class.
Internationalisation Resource Names
Field Summary | |
---|---|
static int |
AMBIENT_AND_DIFFUSE_TARGET
Set the color material target as the ambient and diffuse light component. |
static int |
AMBIENT_TARGET
Set the color material target as the ambient light component |
static int |
DIFFUSE_TARGET
Set the color material target as the diffuse light component |
static int |
EMISSIVE_TARGET
Set the color material target as the emissive light component |
static int |
SPECULAR_TARGET
Set the color material target as the specular light component |
Fields inherited from class org.j3d.aviatrix3d.NodeComponent |
---|
lastParent, liveCount, parentList |
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler |
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 for the front or combined faces. |
void |
getBackAmbientColor(float[] col)
Get the current value of the ambient color for the back face. |
int |
getBackColorMaterialTarget()
Get the amount of colorTarget for the back face. |
void |
getBackDiffuseColor(float[] col)
Get the current value of the diffuse color for the back face. |
void |
getBackEmissiveColor(float[] col)
Get the current value of the emissive color for the back face. |
float |
getBackShininess()
Get the current shininess value for the back face. |
void |
getBackSpecularColor(float[] col)
Get the current value of the specular color for the back face. |
float |
getBackTransparency()
Get the amount of transparency for the back face. |
int |
getColorMaterialTarget()
Get the current target fr color materials for the front or combined faces. |
void |
getDiffuseColor(float[] col)
Get the current value of the diffuse color of the front and combined faces. |
void |
getEmissiveColor(float[] col)
Get the current value of the emissive color for the front or combined faces. |
float |
getShininess()
Get the current shininess value for the front or combined faces. |
void |
getSpecularColor(float[] col)
Get the current value of the specular color for the front or combined faces. |
float |
getTransparency()
Get the amount of transparency for the front or combined faces. |
boolean |
hasTransparency()
Ask the texture if it has any transparency values. |
boolean |
isBlendingAvailable()
Check to see if the code has detected the lack of the imaging subset. |
boolean |
isColorMaterialEnabled()
Get the current flag defining whether color material lighting is currently enabled or not for this object. |
boolean |
isLightingEnabled()
Get the current flag defining whether lighting is currently enabled or not for this object. |
boolean |
isSeparateBackfaceEnabled()
Get the current state of whether separate back-face colour values are in use. |
boolean |
isSeparateTransparencyEnabled()
Get the current flag defining whether separate transparency and color material lighting is currently enabled or not for this object. |
void |
postRender(javax.media.opengl.GL gl)
Restore all openGL state to the given drawable |
void |
render(javax.media.opengl.GL gl)
Issue ogl commands needed for this component |
void |
setAmbientColor(float[] col)
Set the ambient color to the new value for the front-face and combined values. |
void |
setBackAmbientColor(float[] col)
Set the ambient color to the new value for the back face value. |
void |
setBackColorMaterialTarget(int target)
Set the amount of colorTarget to be used for this material for the back face value. |
void |
setBackDiffuseColor(float[] col)
Set the diffuse color to the new value for the back face value. |
void |
setBackEmissiveColor(float[] col)
Set the emissive color to the new value for the back face value. |
void |
setBackShininess(float s)
Set the shininess factor for the back face value. |
void |
setBackSpecularColor(float[] col)
Set the specular color to the new value for the back face value. |
void |
setBackTransparency(float transparency)
Set the amount of transparency to be used for this material for the back face value. |
void |
setColorMaterialEnabled(boolean state)
Set the flag that enables or disables color material lighting effects on any geometry using this material. |
void |
setColorMaterialTarget(int target)
Set the amount of colorTarget to be used for this material for the front or combined faces. |
void |
setDiffuseColor(float[] col)
Set the diffuse color to the new value for the front and combined faces. |
void |
setEmissiveColor(float[] col)
Set the emissive color to the new value for the front-face and combined values. |
void |
setLightingEnabled(boolean state)
Set the flag that enables or disables lighting on any geometry using this material. |
void |
setSeparateBackfaceEnabled(boolean state)
Set the flag that enables or disables separate material lighting values on any geometry using this material. |
void |
setSeparateTransparencyEnabled(boolean state)
Set the flag that enables or disables separate transparency handling from the color material values. |
void |
setShininess(float s)
Set the shininess factor for the front or combined faces. |
void |
setSpecularColor(float[] col)
Set the specular color to the new value for the front-face and combined values. |
void |
setTransparency(float transparency)
Set the amount of transparency to be used for this material for the front or combined faces. |
Methods inherited from class org.j3d.aviatrix3d.NodeComponent |
---|
addParent, getParents, numParents, removeParent |
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject |
---|
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setLive, setUpdateHandler, setUserData |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int AMBIENT_TARGET
public static final int DIFFUSE_TARGET
public static final int SPECULAR_TARGET
public static final int EMISSIVE_TARGET
public static final int AMBIENT_AND_DIFFUSE_TARGET
Constructor Detail |
---|
public Material()
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
public Material(float[] ambientColor, float[] emissiveColor, float[] diffuseColor, float[] specularColor, float shininess, float transparency)
ambientColor
- emissiveColor
- diffuseColor
- specularColor
- shininess
- The shininess factor valuetransparency
- A transparency value between 0 and 1Method Detail |
---|
public boolean hasTransparency()
hasTransparency
in interface TransparentRenderable
public void render(javax.media.opengl.GL gl)
render
in interface ObjectRenderable
gl
- The gl context to draw withpublic void postRender(javax.media.opengl.GL gl)
postRender
in interface ObjectRenderable
gl
- The gl context to draw withpublic int compareTo(java.lang.Object o) throws java.lang.ClassCastException
compareTo
in interface java.lang.Comparable
o
- The object to be compared
java.lang.ClassCastException
- The specified object's type prevents it from
being compared to this Objectpublic boolean equals(java.lang.Object o)
equals
in interface Renderable
equals
in class java.lang.Object
o
- The object to be compared
public void setShininess(float s) throws InvalidWriteTimingException, java.lang.IllegalArgumentException
s
- The shininess factor value
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback method
java.lang.IllegalArgumentException
- The shininess value is outside the
range of [0,1]public void setBackShininess(float s) throws InvalidWriteTimingException, java.lang.IllegalStateException
s
- The shininess factor value
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback method
java.lang.IllegalStateException
- Attempting to write to the value when the
separate backface flag is not turned on.public float getShininess()
public float getBackShininess() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- Attempting to read the value when the
separate backface flag is not turned on.public void setDiffuseColor(float[] col) throws InvalidWriteTimingException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback methodpublic void setBackDiffuseColor(float[] col) throws InvalidWriteTimingException, java.lang.IllegalStateException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback method
java.lang.IllegalStateException
- Attempting to write to the value when the
separate backface flag is not turned on.public void getDiffuseColor(float[] col)
col
- The array to copy the values intopublic void getBackDiffuseColor(float[] col) throws java.lang.IllegalStateException
col
- The array to copy the values into
java.lang.IllegalStateException
- Attempting to read the value when the
separate backface flag is not turned on.public void setSpecularColor(float[] col) throws InvalidWriteTimingException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback methodpublic void setBackSpecularColor(float[] col) throws InvalidWriteTimingException, java.lang.IllegalStateException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback method
java.lang.IllegalStateException
- Attempting to write to the value when the
separate backface flag is not turned on.public void getSpecularColor(float[] col)
col
- The array to copy the values intopublic void getBackSpecularColor(float[] col) throws java.lang.IllegalStateException
col
- The array to copy the values into
java.lang.IllegalStateException
- Attempting to read the value when the
separate backface flag is not turned on.public void setEmissiveColor(float[] col) throws InvalidWriteTimingException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback methodpublic void setBackEmissiveColor(float[] col) throws InvalidWriteTimingException, java.lang.IllegalStateException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback method
java.lang.IllegalStateException
- Attempting to write to the value when the
separate backface flag is not turned on.public void getEmissiveColor(float[] col)
col
- The array to copy the values intopublic void getBackEmissiveColor(float[] col) throws java.lang.IllegalStateException
col
- The array to copy the values into
java.lang.IllegalStateException
- Attempting to read the value when the
separate backface flag is not turned on.public void setAmbientColor(float[] col) throws InvalidWriteTimingException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic void setBackAmbientColor(float[] col) throws InvalidWriteTimingException, java.lang.IllegalStateException
col
- The new colour to use
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback method
java.lang.IllegalStateException
- Attempting to write to the value when the
separate backface flag is not turned on.public void getAmbientColor(float[] col)
col
- The array to copy the values into.public void getBackAmbientColor(float[] col) throws java.lang.IllegalStateException
col
- The array to copy the values into.
java.lang.IllegalStateException
- Attempting to read the value when the
separate backface flag is not turned on.public void setTransparency(float transparency) throws InvalidWriteTimingException
transparency
- A value between 0 and 1
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback methodpublic void setBackTransparency(float transparency) throws InvalidWriteTimingException, java.lang.IllegalStateException
transparency
- A value between 0 and 1
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener data change callback method
java.lang.IllegalStateException
- Attempting to write to the value when the
separate backface flag is not turned on.public float getTransparency()
public float getBackTransparency() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- Attempting to read the value when the
separate backface flag is not turned on.public void setLightingEnabled(boolean state) throws InvalidWriteTimingException
state
- true if lighting should be used
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic boolean isLightingEnabled()
public void setSeparateTransparencyEnabled(boolean state) throws InvalidWriteTimingException
state
- true if separating transparency from color material
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic boolean isSeparateTransparencyEnabled()
public void setColorMaterialEnabled(boolean state) throws InvalidWriteTimingException
state
- true if color material should be used
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic boolean isColorMaterialEnabled()
public void setColorMaterialTarget(int target) throws InvalidWriteTimingException, java.lang.IllegalArgumentException
target
- One of the _TARGET
constant values
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback method
java.lang.IllegalArgumentException
- The target was not one of the
_TARGET
valuespublic void setBackColorMaterialTarget(int target) throws InvalidWriteTimingException, java.lang.IllegalStateException, java.lang.IllegalArgumentException
target
- One of the _TARGET
constant values
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback method
java.lang.IllegalStateException
- Attempting to write to the value when the
separate backface flag is not turned on.
java.lang.IllegalArgumentException
- The target was not one of the
_TARGET
valuespublic int getColorMaterialTarget()
_TARGET
values for the front facepublic int getBackColorMaterialTarget() throws java.lang.IllegalStateException
_TARGET
values for the back face
java.lang.IllegalStateException
- Attempting to read the value when the
separate backface flag is not turned on.public void setSeparateBackfaceEnabled(boolean state) throws InvalidWriteTimingException
PolygonAttributes
class.
If this is enabling the separate back face values, all the existing front faces are copied into the back face value.
state
- true if two sided colours should be used
InvalidWriteTimingException
- An attempt was made to write outside
of the NodeUpdateListener callback methodpublic boolean isSeparateBackfaceEnabled()
public int compareTo(Material mat)
mat
- The material to be compared
public boolean equals(Material mat)
mat
- The material to be compared
public boolean isBlendingAvailable()
|
Aviatrix3D 2.1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |