Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class VertexShader

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.NodeComponent
          extended by org.j3d.aviatrix3d.GL14ShaderProgram
              extended by org.j3d.aviatrix3d.VertexShader
All Implemented Interfaces:
java.lang.Comparable, ObjectRenderable, Renderable, ShaderComponentRenderable

public class VertexShader
extends GL14ShaderProgram
implements ShaderComponentRenderable

Node that handles Vertex shader implementation.

The implementation is relatively simple using just a bind program call followed by the parameter setting. If the application needs greater control than this, such as multi-pass rendering, then derive this class and change the render-loop code to do what is required.

Parameters follow the OpenGL model. There are 96 evironment parameters and 96 local parameters. Both can be set through this class, though this may change in a future design revision, to make environment parameters into a global setting.

Though OpenGL can take the attributes as doubles, this is not supported by this API currently.

Version:
$Revision: 1.23 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.GL14ShaderProgram
programChanged, programIdMap, programString
 
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
 
Fields inherited from interface org.j3d.aviatrix3d.rendering.ShaderComponentRenderable
FRAGMENT_SHADER, GEOMETRY_SHADER, PROGRAM_SHADER, VERTEX_SHADER
 
Constructor Summary
VertexShader()
          Constructs a Vertex shader with default values.
VertexShader(int attrListSize, int paramListSize)
          Create a vertext shader instance with a guaranteed maximum parameter list size.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 int compareTo(VertexShader sh)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 boolean equals(VertexShader sh)
          Compares this object with the specified object to check for equivalence.
 int getComponentType()
          Get the type of component this state represents.
 void postRender(javax.media.opengl.GL gl)
           
 void render(javax.media.opengl.GL gl)
          Set up the rendering state now.
 void setEnvironmentParam(int idx, float[] value)
          Set the environment parameter as a float array.
 void setLocalParam(int idx, float[] value)
          Set the local parameter as a float array.
 
Methods inherited from class org.j3d.aviatrix3d.GL14ShaderProgram
getProgramId, getProgramString, isValid, reinitialize, setProgramString
 
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
 
Methods inherited from interface org.j3d.aviatrix3d.rendering.ShaderComponentRenderable
getProgramId, isValid, reinitialize
 

Constructor Detail

VertexShader

public VertexShader()
Constructs a Vertex shader with default values. The internal arrays for vertex attributes will be 16 and environment and local parameters to 96.


VertexShader

public VertexShader(int attrListSize,
                    int paramListSize)
             throws InvalidWriteTimingException
Create a vertext shader instance with a guaranteed maximum parameter list size. If an attempt is made to read/set past this, an exception will generated. This ID is the maximum parameter index that will be used and the maxium number actually used.

Parameters:
paramListSize - The maximum number of environment and local parameters that will be used.
attrListSize - The maximum number of vertex attributes that will be used
Throws:
InvalidWriteTimingException
Method Detail

getComponentType

public int getComponentType()
Get the type of component this state represents.

Specified by:
getComponentType in interface ShaderComponentRenderable
Returns:
One of the _SHADER constants

render

public void render(javax.media.opengl.GL gl)
Set up the rendering state now.

Specified by:
render in interface ObjectRenderable
Parameters:
gl - The gl context to draw with

postRender

public void postRender(javax.media.opengl.GL gl)
Specified by:
postRender in interface ObjectRenderable

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.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The objec 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.

Specified by:
equals in interface Renderable
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

setEnvironmentParam

public void setEnvironmentParam(int idx,
                                float[] value)
                         throws InvalidWriteTimingException
Set the environment parameter as a float array.

Parameters:
idx - The index of the parameter to set
value - A float array 4 in length of the values to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

setLocalParam

public void setLocalParam(int idx,
                          float[] value)
                   throws InvalidWriteTimingException
Set the local parameter as a float array.

Parameters:
idx - The index of the parameter to set
value - A float array 4 in length of the values to use
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

compareTo

public int compareTo(VertexShader sh)
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:
sh - The shader instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

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

Parameters:
sh - The shader instance to be compared
Returns:
true if the objects represent identical values

Aviatrix3D
2.1.0

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