yaarq.sys
Class yrqTerrain

java.lang.Object
  |
  +--yaarq.sys.yrqTerrain
All Implemented Interfaces:
javax.media.j3d.ImageComponent2D.Updater

public class yrqTerrain
extends java.lang.Object
implements javax.media.j3d.ImageComponent2D.Updater

The terrain class encapsules a textured terrain geometry placed in the center of the x-z plane. It provides utility functions and objects for applying lightmaps to the terrain and supports heightmap for fast determination of terrain height at a given location and for intersection calculations. An instance of this class can be set to the engine to enable terrain support. If no class instance is set to the engine, terrain support is disabled and the engine ignores updating of the terrain.

TODO: Implement height map


Constructor Summary
yrqTerrain(yrqEngine a_engine)
          Constructs an instance of the terrain class.
 
Method Summary
 void addShader(java.lang.String a_name, yrqShader a_shader)
          This method adds a shader to the terrain shading system.
 javax.media.j3d.BoundingBox getBounds()
          This function returns the current bounds of the terrain geometry.
 yrqShader getShader(java.lang.String a_name)
          This method retrieves one of the shaders by its name.
 void removeShader(java.lang.String a_name)
          This method removes one of the shaders by its name.
 void removeShader(yrqShader a_shader)
          This method removes one of the shaders by its reference.
 void setGeometry(javax.media.j3d.Geometry a_geometry)
          This method sets the geometry to be used for the terrain.
 void setHeightmap(javax.media.j3d.Texture2D a_texture)
          This method sets the heightmap to use for determination of altitude and colission with the terrain.
 void setTexture(javax.media.j3d.Texture2D a_texture)
          This method sets the texture to use for the terrain.
 void update()
          This function is called by the engine before rendering a frame to update the shademap used for terrain shading.
 void updateData(javax.media.j3d.ImageComponent2D a_component, int a_x, int a_y, int a_width, int a_height)
          This implementation of the ImageUpdater interface renders the shademap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

yrqTerrain

public yrqTerrain(yrqEngine a_engine)
Constructs an instance of the terrain class.

Parameters:
a_engine - The engine instance
Method Detail

addShader

public void addShader(java.lang.String a_name,
                      yrqShader a_shader)
This method adds a shader to the terrain shading system. If no name is passed for the shader, it is added without a key. You can only refer to an unnamed shader via an externally kept object reference.

Shaders are no scenegraph objects, the can be added, removed and changed at any time after terrain instantiation.

Parameters:
a_name - The name of the shader to add
a_shader - The shader to add

getBounds

public javax.media.j3d.BoundingBox getBounds()
This function returns the current bounds of the terrain geometry.


getShader

public yrqShader getShader(java.lang.String a_name)
This method retrieves one of the shaders by its name.

Shaders are no scenegraph objects, the can be added, removed and changed at any time after terrain instantiation.

Parameters:
a_name - The name of the shader to add

removeShader

public void removeShader(java.lang.String a_name)
This method removes one of the shaders by its name.

Shaders are no scenegraph objects, the can be added, removed and changed at any time after terrain instantiation.

Parameters:
a_name - The name of the shader to remove

removeShader

public void removeShader(yrqShader a_shader)
This method removes one of the shaders by its reference.

Shaders are no scenegraph objects, the can be added, removed and changed at any time after terrain instantiation.


setGeometry

public void setGeometry(javax.media.j3d.Geometry a_geometry)
This method sets the geometry to be used for the terrain. Bounds are autmatically updated, and the shader system is refreshed to reflect new shade coordinates.

Parameters:
a_geometry - The geometry for the terrain

setHeightmap

public void setHeightmap(javax.media.j3d.Texture2D a_texture)
This method sets the heightmap to use for determination of altitude and colission with the terrain. Values are automatically interpolated.

Parameters:
a_texture - The texture to use as a heightmap

setTexture

public void setTexture(javax.media.j3d.Texture2D a_texture)
This method sets the texture to use for the terrain.


update

public void update()
This function is called by the engine before rendering a frame to update the shademap used for terrain shading. Rendering is only done if the shademap is dirty.


updateData

public void updateData(javax.media.j3d.ImageComponent2D a_component,
                       int a_x,
                       int a_y,
                       int a_width,
                       int a_height)
This implementation of the ImageUpdater interface renders the shademap

Specified by:
updateData in interface javax.media.j3d.ImageComponent2D.Updater
Parameters:
a_component - The imagecomponent to update
a_x - The area to update
a_y - The area to update
a_width - The area to update
a_height - The area to update