yaarq.sys
Class yrqShader

java.lang.Object
  |
  +--yaarq.sys.yrqShader

public class yrqShader
extends java.lang.Object

The shader class encapsules light and shadow to be applied to a terrain. A texture provides the ligh or shadow to be applied, with all shaders added over each other defining the terrain lightmap. Shader textures are greyscale, and the shademap is applied using the ADDSIGNED texturing rule. This means that a shademap value of 128 denotes no shading, a value of 0 denotes absolute shade and a value of 255 denotes absolute brightness.

TODO: Nothing


Constructor Summary
yrqShader(yrqEngine a_engine, javax.media.j3d.Texture2D a_texture, javax.vecmath.Point3d a_position, float a_alpha)
          ...
 
Method Summary
 float getAlpha()
          This function retrieves the alpha value of the shader.
 boolean getDirty()
          This function returns a boolean value denoting if the shader instance has been modified.
 javax.vecmath.Point3d getPosition()
          This method retrieves the position of the shader.
 javax.media.j3d.Texture2D getTexture()
          This function retrieves the texture of the shader.
 void setAlpha(float a_alpha)
          This method sets the alpha value of the shader.
 void setDirty(boolean a_dirty)
          This method sets the dirty state of the shader.
 void setPosition(javax.vecmath.Point3d a_position)
          This method sets the position of the shader.
 void setTexture(javax.media.j3d.Texture2D a_texture)
          This method sets a new texture to the shader.
 void update(java.awt.Graphics2D a_gfx, int a_width, int a_height)
          This method is called by the terrain instance the shader has been attached to whenever necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

yrqShader

public yrqShader(yrqEngine a_engine,
                 javax.media.j3d.Texture2D a_texture,
                 javax.vecmath.Point3d a_position,
                 float a_alpha)
...

Parameters:
a_engine - The engine instance
a_texture - The texture to use for the shader
a_position - The initial position of the shader
a_alpha - The initial alpha of the shader
Method Detail

getAlpha

public float getAlpha()
This function retrieves the alpha value of the shader. This value is applied to the shader whenever it is put to the shademap of its terrain instance using the AlphaComposite.SRC_OVER rule. The value range is 0-1


getDirty

public boolean getDirty()
This function returns a boolean value denoting if the shader instance has been modified. It is used by the terrain instance to which the shader is attached to decide if the shademap has to be repainted.


getPosition

public javax.vecmath.Point3d getPosition()
This method retrieves the position of the shader. The y component of the position is ignored, a 3d instance is used for convenience, to ease the creation of projection shadows along the y-axis.


getTexture

public javax.media.j3d.Texture2D getTexture()
This function retrieves the texture of the shader. Textures used for shaders shoud be greyscale textures with the background being 128 in value (producing no effect), shadows being 0 in value (darkest shadow) and lights being 255 in value (producing maximum brightness).


setAlpha

public void setAlpha(float a_alpha)
This method sets the alpha value of the shader. This value is applied to the shader whenever it is put to the shademap of its terrain instance using the AlphaComposite.SRC_OVER rule. The value range is 0-1

Parameters:
a_alpha - The alpha value to set for the shader

setDirty

public void setDirty(boolean a_dirty)
This method sets the dirty state of the shader. It is used by the terrain instance the shader is attached to to reset the shaders dirty state after a successful update of the shademap.


setPosition

public void setPosition(javax.vecmath.Point3d a_position)
This method sets the position of the shader. This is done by reference. The y component of the position is ignored, a 3d instance is used for convenience, to ease the creation of projection shadows along the y-axis.

Parameters:
a_position - The position to which to translate the shader

setTexture

public void setTexture(javax.media.j3d.Texture2D a_texture)
This method sets a new texture to the shader. Textures used for shaders shoud be greyscale textures with the background being 128 in value (producing no effect), shadows being 0 in value (darkest shadow) and lights being 255 in value (producing maximum brightness).

Parameters:
a_texture - The new texture to use for this shader

update

public void update(java.awt.Graphics2D a_gfx,
                   int a_width,
                   int a_height)
This method is called by the terrain instance the shader has been attached to whenever necessary. It redraws the shademap area this shader is responsible for.

Parameters:
a_gfx - The graphics object to which to render the shader
a_height - The pixel height of the shademap