jme.texture
Class ProceduralTexture

java.lang.Object
  extended byjme.texture.ProceduralTexture

public class ProceduralTexture
extends java.lang.Object

ProceduralTexture generates an ImageIcon using an AbstractHeightMap and one or more ImageIcons as input textures. The final texture is built based on a pixel's current height and the values associated with each input image. When adding an input texture, a low, optimal and high value is given to denote how much of the RGB value to use for a given output pixel. For example, if a texture is added with (0, 10, 20), and a pixel is denoted as having a height of 5 50% of the texture will be used for the output texture. When combining multiple input textures with overlapping values, you can create a smooth blending for the output texture. Currently, the output texture will have the same dimensions as the input heightmap.

Version:
0.1.0
Author:
Mark Powell

Constructor Summary
ProceduralTexture(AbstractHeightMap heightMap)
          Constructor instantiates a new ProceduralTexture object initializing the list for textures and the height map.
 
Method Summary
 void addTexture(javax.swing.ImageIcon image, int low, int optimal, int high)
          addTexture adds an additional texture to the list of input textures.
 void createTexture(int textureSize)
          createTexture takes the current height map and the current loaded textures and produces an ImageIcon which can be retrieved with a call to getImageIcon.
 javax.swing.ImageIcon getImageIcon()
          getImageIcon retrieves the procedural texture that has been created.
 boolean saveTexture(java.lang.String filename)
           
 void setHeightMap(AbstractHeightMap hm)
          setHeightMap sets the input heightmap to use for the texture generation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProceduralTexture

public ProceduralTexture(AbstractHeightMap heightMap)
Constructor instantiates a new ProceduralTexture object initializing the list for textures and the height map.

Parameters:
heightMap - the height map to use for the texture generation.
Method Detail

createTexture

public void createTexture(int textureSize)
createTexture takes the current height map and the current loaded textures and produces an ImageIcon which can be retrieved with a call to getImageIcon.


saveTexture

public boolean saveTexture(java.lang.String filename)

addTexture

public void addTexture(javax.swing.ImageIcon image,
                       int low,
                       int optimal,
                       int high)
addTexture adds an additional texture to the list of input textures. Each texture has a low, optimal and high value associated with it. This determines how much of the texture color to use for a particular pixel. Where optimal is 100% of the color, less than low is 0% and higher than high is 0%. For example if the values are (0, 10, 20), and the height is 5, then 50% of the color will be used.

Parameters:
image - the input texture.
low - the low color value for this texture.
optimal - the optimal color value for this texture.
high - the high color value for this texture.

setHeightMap

public void setHeightMap(AbstractHeightMap hm)
setHeightMap sets the input heightmap to use for the texture generation.

Parameters:
hm - the new heightmap.
Throws:
MonkeyRuntimeException - if hm is null.

getImageIcon

public javax.swing.ImageIcon getImageIcon()
getImageIcon retrieves the procedural texture that has been created. Note that this will return null until createTexture has been called.

Returns:
the ImageIcon of the output texture.