Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class TextureAttributes

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

public class TextureAttributes
extends NodeComponent
implements ObjectRenderable

Describes how a texture gets applied to the underlying geometry.

All of these attributes are part of the texture object so we only issue OGL commands when they change. This will update the Texture Object's values for all future uses.

If point sprites are available, this class can be used to enable or disable their use. Note that to use them completely, you also need to enable the equivalent state with PointAttributes.setPointSpriteEnabled(boolean)

When providing texture unit identfiers for the source for the combiner functions, not all the constants are defined. Since OpenGL uses sequential numbering, if you need anything greater than 8, you can specify the value buy making the call with SOURCE_TEXUTRE_0 + n where n is the texture unit ID that you want to use.

The default values for this class are:

 Texture Mode: GL.GL_REPLACE
 RGB Scale: 1
 Alpha Scale: 1

 RGB CombineMode: COMBINE_MODULATE
 Alpha CombineMode: COMBINE_MODULATE

 RGB Source0: SOURCE_CURRENT_TEXTURE
 RGB Source1: SOURCE_PREVIOUS_UNIT
 RGB Source2: SOURCE_CONSTANT_COLOR

 Alpha Source0: SOURCE_CURRENT_TEXTURE
 Alpha Source1: SOURCE_PREVIOUS_UNIT
 Alpha Source2: SOURCE_CONSTANT_COLOR

 RGB Operand0: SRC_COLOR
 RGB Operand1: SRC_COLOR
 RGB Operand2: SRC_ALPHA

 Alpha Operand0: SRC_ALPHA
 Alpha Operand1: SRC_ALPHA
 Alpha Operand2: SRC_ALPHA
 
Point sprites are disabled by default.

Internationalisation Resource Names

Version:
$Revision: 1.28 $
Author:
Justin Couch, Alan Hudson

Field Summary
static int COMBINE_ADD
          Set combine mode for applying textures to objects to GL_ADD
static int COMBINE_ADD_SIGNED
          Set combine mode for applying textures to objects to GL_ADD_SIGNED
static int COMBINE_DOT3_RGB
          Set combine mode for applying textures to objects to GL_DOT3_RGB
static int COMBINE_DOT3_RGBA
          Set combine mode for applying textures to objects to GL_DOT3_RGBA
static int COMBINE_INTERPOLATE
          Set combine mode for applying textures to objects to GL_INTERPOLATE
static int COMBINE_MODULATE
          Set combine mode for applying textures to objects to GL_MODULATE
static int COMBINE_REPLACE
          Set combine mode for applying textures to objects to GL_REPLACE
static int COMBINE_SUBTRACT
          Set combine mode for applying textures to objects to GL_SUBTRACT
static int MODE_ADD
          Set the mode for applying textures to objects to GL_ADD
static int MODE_BLEND
          Set the mode for applying textures to objects to GL_BLEND
static int MODE_COMBINE
          Set the mode for applying textures to objects to GL_COMBINE
static int MODE_DECAL
          Set the mode for applying textures to objects to GL_DECAL
static int MODE_MODULATE
          Set the mode for applying textures to objects to GL_MODULATE
static int MODE_REPLACE
          Set the mode for applying textures to objects to GL_REPLACE
static int ONE_MINUS_SRC_ALPHA
          Use one minus source alpha for the incoming operation
static int ONE_MINUS_SRC_COLOR
          Use one minus source colour for the incoming operation
static int SOURCE_BASE_COLOR
          The source is the base colour of the object before texturing has been applied.
static int SOURCE_CONSTANT_COLOR
          The source is the provided texture blend colour
static int SOURCE_CURRENT_TEXTURE
          The source is the current texture stage
static int SOURCE_PREVIOUS_UNIT
          The source is the output of the previous texture unit
static int SOURCE_TEXTURE_0
          The source is texture stage 0
static int SOURCE_TEXTURE_1
          The source is texture stage 1
static int SOURCE_TEXTURE_2
          The source is texture stage 2
static int SOURCE_TEXTURE_3
          The source is texture stage 3
static int SOURCE_TEXTURE_4
          The source is texture stage 4
static int SOURCE_TEXTURE_5
          The source is texture stage 5
static int SOURCE_TEXTURE_6
          The source is texture stage 6
static int SOURCE_TEXTURE_7
          The source is texture stage 7
static int SRC_ALPHA
          Use the source alpha for the incoming operation
static int SRC_COLOR
          Use the source colour for the incoming operation
 
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
TextureAttributes()
          Constructs a Texture Unit with default values.
 
Method Summary
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 int compareTo(TextureAttributes ta)
          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(TextureAttributes ta)
          Compares this object with the specified object to check for equivalence.
 void getBlendColor(float[] col)
          Get the current blend colour.
 int getCombineMode(boolean alpha)
          Get the combine mode in use.
 int getCombineOperand(boolean alpha, int opIdx)
          Get the current value of the combine operand in use.
 float getCombineScale(boolean alpha)
          Get the combine scale factor.
 int getCombineSource(boolean alpha, int opIdx)
          Get the current value of the combine source function in use
 int getTextureMode()
          Get the current texture mode in use.
 boolean isPointSpriteAllowed()
          Convenience method to check if this code has detected the prescense of multitexture extensions.
 boolean isPointSpriteCoordEnabled()
          Get the current state of the whether the point sprites coordinates are enabled.
 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 setBlendColor(float r, float g, float b, float a)
          Set the blend colour to use for this texture.
 void setCombineMode(boolean alpha, int mode)
          Set the combine mode for the alpha or RGB side.
 void setCombineOperand(boolean alpha, int opIdx, int function)
          Set the operand to use for alpha or RGB combine mode.
 void setCombineScale(boolean alpha, float scale)
          Set the combine scale factor.
 void setCombineSource(boolean alpha, int opIdx, int source)
          Set the combine source type for alpha or RGB combine mode.
 void setPointSpriteCoordEnabled(boolean state)
          Set the point sprite coordinate enabled flag.
 void setTextureMode(int mode)
          Set the texture mode.
 
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

MODE_REPLACE

public static final int MODE_REPLACE
Set the mode for applying textures to objects to GL_REPLACE

See Also:
Constant Field Values

MODE_MODULATE

public static final int MODE_MODULATE
Set the mode for applying textures to objects to GL_MODULATE

See Also:
Constant Field Values

MODE_BLEND

public static final int MODE_BLEND
Set the mode for applying textures to objects to GL_BLEND

See Also:
Constant Field Values

MODE_DECAL

public static final int MODE_DECAL
Set the mode for applying textures to objects to GL_DECAL

See Also:
Constant Field Values

MODE_ADD

public static final int MODE_ADD
Set the mode for applying textures to objects to GL_ADD

See Also:
Constant Field Values

MODE_COMBINE

public static final int MODE_COMBINE
Set the mode for applying textures to objects to GL_COMBINE

See Also:
Constant Field Values

COMBINE_REPLACE

public static final int COMBINE_REPLACE
Set combine mode for applying textures to objects to GL_REPLACE

See Also:
Constant Field Values

COMBINE_MODULATE

public static final int COMBINE_MODULATE
Set combine mode for applying textures to objects to GL_MODULATE

See Also:
Constant Field Values

COMBINE_ADD

public static final int COMBINE_ADD
Set combine mode for applying textures to objects to GL_ADD

See Also:
Constant Field Values

COMBINE_ADD_SIGNED

public static final int COMBINE_ADD_SIGNED
Set combine mode for applying textures to objects to GL_ADD_SIGNED

See Also:
Constant Field Values

COMBINE_INTERPOLATE

public static final int COMBINE_INTERPOLATE
Set combine mode for applying textures to objects to GL_INTERPOLATE

See Also:
Constant Field Values

COMBINE_SUBTRACT

public static final int COMBINE_SUBTRACT
Set combine mode for applying textures to objects to GL_SUBTRACT

See Also:
Constant Field Values

COMBINE_DOT3_RGB

public static final int COMBINE_DOT3_RGB
Set combine mode for applying textures to objects to GL_DOT3_RGB

See Also:
Constant Field Values

COMBINE_DOT3_RGBA

public static final int COMBINE_DOT3_RGBA
Set combine mode for applying textures to objects to GL_DOT3_RGBA

See Also:
Constant Field Values

SOURCE_CURRENT_TEXTURE

public static final int SOURCE_CURRENT_TEXTURE
The source is the current texture stage

See Also:
Constant Field Values

SOURCE_TEXTURE_0

public static final int SOURCE_TEXTURE_0
The source is texture stage 0

See Also:
Constant Field Values

SOURCE_TEXTURE_1

public static final int SOURCE_TEXTURE_1
The source is texture stage 1

See Also:
Constant Field Values

SOURCE_TEXTURE_2

public static final int SOURCE_TEXTURE_2
The source is texture stage 2

See Also:
Constant Field Values

SOURCE_TEXTURE_3

public static final int SOURCE_TEXTURE_3
The source is texture stage 3

See Also:
Constant Field Values

SOURCE_TEXTURE_4

public static final int SOURCE_TEXTURE_4
The source is texture stage 4

See Also:
Constant Field Values

SOURCE_TEXTURE_5

public static final int SOURCE_TEXTURE_5
The source is texture stage 5

See Also:
Constant Field Values

SOURCE_TEXTURE_6

public static final int SOURCE_TEXTURE_6
The source is texture stage 6

See Also:
Constant Field Values

SOURCE_TEXTURE_7

public static final int SOURCE_TEXTURE_7
The source is texture stage 7

See Also:
Constant Field Values

SOURCE_CONSTANT_COLOR

public static final int SOURCE_CONSTANT_COLOR
The source is the provided texture blend colour

See Also:
Constant Field Values

SOURCE_BASE_COLOR

public static final int SOURCE_BASE_COLOR
The source is the base colour of the object before texturing has been applied.

See Also:
Constant Field Values

SOURCE_PREVIOUS_UNIT

public static final int SOURCE_PREVIOUS_UNIT
The source is the output of the previous texture unit

See Also:
Constant Field Values

SRC_COLOR

public static final int SRC_COLOR
Use the source colour for the incoming operation

See Also:
Constant Field Values

ONE_MINUS_SRC_COLOR

public static final int ONE_MINUS_SRC_COLOR
Use one minus source colour for the incoming operation

See Also:
Constant Field Values

SRC_ALPHA

public static final int SRC_ALPHA
Use the source alpha for the incoming operation

See Also:
Constant Field Values

ONE_MINUS_SRC_ALPHA

public static final int ONE_MINUS_SRC_ALPHA
Use one minus source alpha for the incoming operation

See Also:
Constant Field Values
Constructor Detail

TextureAttributes

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

Method Detail

render

public void render(javax.media.opengl.GL gl)
Issue ogl commands needed for this component

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

postRender

public void postRender(javax.media.opengl.GL gl)
Restore all openGL state to the given drawable.

Specified by:
postRender in interface ObjectRenderable
Parameters:
gl - The gl 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.

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

setTextureMode

public void setTextureMode(int mode)
                    throws InvalidWriteTimingException
Set the texture mode. If set to blend mode, and no colour has been provided yet, it defaults to all white.

Parameters:
mode - The new mode
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getTextureMode

public int getTextureMode()
Get the current texture mode in use.

Returns:
one of the MODE_* values

setBlendColor

public void setBlendColor(float r,
                          float g,
                          float b,
                          float a)
                   throws InvalidWriteTimingException
Set the blend colour to use for this texture. Blend is a 4-component colour value.

Parameters:
r - The red component of the blend colour
g - The green component of the blend colour
b - The blue component of the blend colour
a - The alpha component of the blend colour
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getBlendColor

public void getBlendColor(float[] col)
Get the current blend colour. If it hasn't been set previously, the call is ignored.

Parameters:
col - An array to copy the colour in, in RGBA format

setCombineMode

public void setCombineMode(boolean alpha,
                           int mode)
                    throws InvalidWriteTimingException
Set the combine mode for the alpha or RGB side.

Parameters:
alpha - True if this is setting the combine mode for the alpha channel. False for the RGB channels
mode - one of the valid COMBINE_* mode types
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getCombineMode

public int getCombineMode(boolean alpha)
Get the combine mode in use. If the attributes are set up to not use texture combiners, this will return the last set value.

Parameters:
alpha - true when this should fetch the alpha setting, false for the RGB setting
Returns:
one of the valid COMBINE_* mode types

setCombineScale

public void setCombineScale(boolean alpha,
                            float scale)
                     throws InvalidWriteTimingException
Set the combine scale factor.

Parameters:
alpha - Scale the alpha channel (true) Or the Rgb channel
scale - The amount to scale the channel by
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getCombineScale

public float getCombineScale(boolean alpha)
Get the combine scale factor.

Parameters:
alpha - True if to return the the alpha channel, false for RGB
Returns:
The amount to scale the channel by

setCombineOperand

public void setCombineOperand(boolean alpha,
                              int opIdx,
                              int function)
                       throws InvalidWriteTimingException
Set the operand to use for alpha or RGB combine mode.

Parameters:
alpha - true when this should set the alpha setting, false for the RGB setting
opIdx - A value of 0, 1 or 2 indicating which operand argument this should effect
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getCombineOperand

public int getCombineOperand(boolean alpha,
                             int opIdx)
Get the current value of the combine operand in use.

Parameters:
alpha - true when this should fetch the alpha setting, false for the RGB setting
opIdx - A value of 0, 1 or 2 indicating which operand argument this should fetch
Returns:
one of the valid COMBINE_* mode types

setCombineSource

public void setCombineSource(boolean alpha,
                             int opIdx,
                             int source)
                      throws InvalidWriteTimingException
Set the combine source type for alpha or RGB combine mode.

Parameters:
alpha - true when this should set the alpha setting, false for the RGB setting
opIdx - A value of 0, 1 or 2 indicating which operand argument this should effect
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

getCombineSource

public int getCombineSource(boolean alpha,
                            int opIdx)
Get the current value of the combine source function in use

Parameters:
alpha - true when this should fetch the alpha setting, false for the RGB setting
opIdx - A value of 0, 1 or 2 indicating which operand argument this should fetch
Returns:
one of the valid SRC_* types

setPointSpriteCoordEnabled

public void setPointSpriteCoordEnabled(boolean state)
                                throws InvalidWriteTimingException
Set the point sprite coordinate enabled flag. By default this is disabled. Note that to use them completely, you also need to enable the equivalent state with PointAttributes.setPointSpriteEnabled(boolean)

Parameters:
state - true if this texture unit should enable point sprite coordinates. False to disable
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data changed callback method

isPointSpriteCoordEnabled

public boolean isPointSpriteCoordEnabled()
Get the current state of the whether the point sprites coordinates are enabled.

Returns:
true if the point sprite coordinates are enabled

isPointSpriteAllowed

public boolean isPointSpriteAllowed()
Convenience method to check if this code has detected the prescense of multitexture extensions. If none are found, this will return null. However, one node instance has to have passed through the rendering cycle for this to have detected it. A better option would be to make use of the appropriate callbacks on the GraphicsOutputDevice APIs to detect before you get to this point.

Returns:
true if multitexture is allowed

compareTo

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

equals

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

Parameters:
ta - The attributes 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