j3d.org Aviatrix3D

org.j3d.aviatrix3d
Class TextureUnit

java.lang.Object
  extended byorg.j3d.aviatrix3d.SceneGraphObject
      extended byorg.j3d.aviatrix3d.NodeComponent
          extended byorg.j3d.aviatrix3d.TextureUnit

public class TextureUnit
extends NodeComponent

Describes a texture stage and its associated texture and attributes.

Version:
$Revision: 1.15 $
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
TextureUnit()
          Constructs a Texture Unit with default values.
TextureUnit(Texture t, TextureAttributes attrs, TexCoordGeneration tcg)
          Construct a Texture Unit with the specified texture, attributes and coordinate generation.
 
Method Summary
protected  void checkForCyclicChild(SceneGraphObject parent)
          Check to see if this node is the same reference as the passed node that is a parent of this node.
 TexCoordGeneration getTexCoordGeneration()
          Get the currently set texture.
 Texture getTexture()
          Get the currently set texture.
 TextureAttributes getTextureAttributes()
          Get the currently set texture attributes.
 void getTextureTransform(javax.vecmath.Matrix4f mat)
          Get the current local texture transformation maxtix.
 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.
protected  void setLive(boolean state)
          Notification that this object is live now.
 void setTexCoordGeneration(TexCoordGeneration tcg)
          Set the texture coordinate generation for this stage.
 void setTexture(Texture tex)
          Set the texture for this stage.
 void setTextureAttributes(TextureAttributes attrs)
          Set the texture attributes for this stage.
 void setTextureTransform(javax.vecmath.Matrix4f mat)
          Set the current texture transform matrix.
protected  void setUpdateHandler(NodeUpdateHandler handler)
          Set the scenegraph update handler for this node.
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, hasChanged, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicParent, dataChanged, getUserData, isLive, setUserData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextureUnit

public TextureUnit()
Constructs a Texture Unit with default values.


TextureUnit

public TextureUnit(Texture t,
                   TextureAttributes attrs,
                   TexCoordGeneration tcg)
Construct a Texture Unit with the specified texture, attributes and coordinate generation.

Parameters:
t - The texture instance to use
attrs - Attributes used to control the visual appearance
tcg - Automated texture coordinate generation, if needed
Method Detail

checkForCyclicChild

protected void checkForCyclicChild(SceneGraphObject parent)
                            throws CyclicSceneGraphStructureException
Check to see if this node is the same reference as the passed node that is a parent of this node. This is the downwards check to ensure that there is no cyclic scene graph structures at the point where someone adds a node to the scenegraph. When the reference and this are the same, an exception is generated. Since each class may have different lists of child node setups, this should be overriden by any class that can take children, and have the call passed along to the children.

Overrides:
checkForCyclicChild in class SceneGraphObject
Parameters:
parent - The reference to check against this class
Throws:
CyclicSceneGraphStructureException - Equal parent and child

setUpdateHandler

protected void setUpdateHandler(NodeUpdateHandler handler)
Set the scenegraph update handler for this node. It will notify all its children of the value. A null value will clear the current handler.

Overrides:
setUpdateHandler in class SceneGraphObject
Parameters:
handler - The instance to use as a handler

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

setLive

protected void setLive(boolean state)
Notification that this object is live now. Overridden to make sure that the live state of the nodes represents the same state as the parent scene graph.

Overrides:
setLive in class SceneGraphObject
Parameters:
state - true if this should be marked as live now

setTexture

public void setTexture(Texture tex)
                throws InvalidWriteTimingException
Set the texture for this stage. Passing a value of null will disable this stage from being passed to the rendering APIs.

Parameters:
tex - The texture to be used or null
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getTexture

public Texture getTexture()
Get the currently set texture. If none is set, return null.

Returns:
The current texture instance or null

setTextureAttributes

public void setTextureAttributes(TextureAttributes attrs)
                          throws InvalidWriteTimingException
Set the texture attributes for this stage.

Parameters:
attrs - The texture attributes. Null clears.
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getTextureAttributes

public TextureAttributes getTextureAttributes()
Get the currently set texture attributes. If none is set, return null.

Returns:
The current texture attributes instance or null

setTexCoordGeneration

public void setTexCoordGeneration(TexCoordGeneration tcg)
                           throws InvalidWriteTimingException
Set the texture coordinate generation for this stage.

Parameters:
tcg - The texture coordinate generation. Null clears.
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener callback method

getTexCoordGeneration

public TexCoordGeneration getTexCoordGeneration()
Get the currently set texture. If none is set, return null.

Returns:
The current texture instance or null

setTextureTransform

public void setTextureTransform(javax.vecmath.Matrix4f mat)
                         throws InvalidWriteTimingException
Set the current texture transform matrix. A value of null will reset the matrix back to the default identity matrix.

Parameters:
mat - The matrix to modify textures by, or null
Throws:
InvalidWriteTimingException

getTextureTransform

public void getTextureTransform(javax.vecmath.Matrix4f mat)
Get the current local texture transformation maxtix. If no matrix is currently set, it will set the value to an identity matrix.

Parameters:
mat - The matrix to copy the current values into

j3d.org Aviatrix3D

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