de.rico.engine.effect.texproj
Class TextureProjector

java.lang.Object
  extended by de.rico.engine.effect.texproj.TextureProjector

public class TextureProjector
extends java.lang.Object

This class represents a texture projector. It can be used to project textures into the world. White parts of the texture will be transparent.

Author:
Frank Bruns

Constructor Summary
TextureProjector(java.lang.String name, java.lang.String texPath, int textureUnit)
          Creates a new texture projector.
TextureProjector(java.lang.String name, java.lang.String texPath, int textureUnit, Point3D position)
          Creates a new texture projector.
TextureProjector(java.lang.String name, java.lang.String texPath, int textureUnit, Point3D position, float rotX, float rotY)
          Creates a new texture projector.
 
Method Summary
 void bind(javax.media.opengl.GL gl)
          Binds the projected texture to the successing meshes.
 int getAssignedTexUnit()
          Returns the texture unit this projection is assigned to.
 java.lang.String getName()
          Returns the name of the texture projector.
 Point3D getPosition()
          Returns the projector position
 float getProjectionBalance()
          Returns the value that is influencing the texture projection balance.
 float getRotX()
          Return the rotation around the x axis.
 float getRotY()
          Return the rotation around the y axis.
 void release(javax.media.opengl.GL gl)
          Releases (stops) the texture projection.
 void setAssignedTextureUnit(int texUnit)
          Set the texture unit to be used for texture projection.
 void setPosition(float x, float y, float z)
          Sets the projector's position
 void setPosition(Point3D position)
          Sets the projector's position
 void setProjectionBalance(float value)
          This method sets the balance of front and back projection of the texture.
 void setRotX(float rotX)
          Set the x axis rotation of the texture projector.
 void setRotY(float rotY)
          Set the y axis rotation of the texture projector.
 void setShowProjectorPosition(boolean show)
          Determines whether the projector's position will be symbolized by a little solid cube.
 void setX(float x)
          Sets the x-coordinate of the projector
 void setY(float y)
          Sets the y-coordinate of the projector
 void setZ(float z)
          Sets the z-coordinate of the projector
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextureProjector

public TextureProjector(java.lang.String name,
                        java.lang.String texPath,
                        int textureUnit)
Creates a new texture projector. The projector's position is (0,0,0), just like its rotation.

Parameters:
name - name of the texture projector (can be used a script id)
texPath - path to texture file
textureUnit - texture unit to use for texture projection (0 - 31)

TextureProjector

public TextureProjector(java.lang.String name,
                        java.lang.String texPath,
                        int textureUnit,
                        Point3D position)
Creates a new texture projector. The projector's rotation is (0,0,0).

Parameters:
name - name of the texture projector (can be used a script id)
texPath - path to texture file
textureUnit - texture unit to use for texture projection
position - position of the light

TextureProjector

public TextureProjector(java.lang.String name,
                        java.lang.String texPath,
                        int textureUnit,
                        Point3D position,
                        float rotX,
                        float rotY)
Creates a new texture projector. The projector's position and rotation are set by the specified parameters

Parameters:
name - name of the texture projector (can be used a script id)
texPath - path to texture file
textureUnit - texture unit to use for texture projection
position - position of the light
rotX - rotation along the x axis
rotY - rotation along the y axis
Method Detail

getName

public java.lang.String getName()
Returns the name of the texture projector. This can be used to refer to the projector in scripts, for example.

Returns:
name of the texture projector

setShowProjectorPosition

public void setShowProjectorPosition(boolean show)
Determines whether the projector's position will be symbolized by a little solid cube.

Parameters:
show - Symbolize projector position? --> true = yes, false = no

setAssignedTextureUnit

public void setAssignedTextureUnit(int texUnit)
Set the texture unit to be used for texture projection.
Note: You can't use GL_TEXTURE0 (tex unit 0), because it is reserved for normal object texturing. Furthermore be carenful not assign a texture to a texture unit that doesn't exist.

Parameters:
texUnit - texture unit to use for projection (e.g. 1 or 2)

getAssignedTexUnit

public int getAssignedTexUnit()
Returns the texture unit this projection is assigned to.

Returns:
Assigned texture unit for projection

bind

public void bind(javax.media.opengl.GL gl)
Binds the projected texture to the successing meshes.

Parameters:
gl -

release

public void release(javax.media.opengl.GL gl)
Releases (stops) the texture projection.

Parameters:
gl -

getPosition

public Point3D getPosition()
Returns the projector position

Returns:
position of the projector

setPosition

public void setPosition(Point3D position)
Sets the projector's position

Parameters:
position - position of the projector

setPosition

public void setPosition(float x,
                        float y,
                        float z)
Sets the projector's position

Parameters:
x - x-coordinate
y - y-coordinate
z - z-coordinate

setX

public void setX(float x)
Sets the x-coordinate of the projector

Parameters:
x - x-coordinate value

setY

public void setY(float y)
Sets the y-coordinate of the projector

Parameters:
y - y-coordinate value

setZ

public void setZ(float z)
Sets the z-coordinate of the projector

Parameters:
z - z-coordinate value

setRotX

public void setRotX(float rotX)
Set the x axis rotation of the texture projector.

Parameters:
rotX - degree of x axis roation

setRotY

public void setRotY(float rotY)
Set the y axis rotation of the texture projector.

Parameters:
rotY - degree of y axis roation

getRotX

public float getRotX()
Return the rotation around the x axis.

Returns:
rotation around the x axis

getRotY

public float getRotY()
Return the rotation around the y axis.

Returns:
rotation around the y axis

setProjectionBalance

public void setProjectionBalance(float value)
This method sets the balance of front and back projection of the texture. A negative value shifts the balance to the front projection, resulting in an enlarged texture projection to the front and a shrinked texture projection to the back. A positive value just works vice versa. If you're not sure, what values to use, start with a small value >= 1 or <= -1.

Parameters:
value - value that affects the texture projection balance

getProjectionBalance

public float getProjectionBalance()
Returns the value that is influencing the texture projection balance.

Returns:
texture projection balance influence value