org.xith3d.terrain
Class TextureSurface

java.lang.Object
  extended by org.xith3d.terrain.TextureSurface
All Implemented Interfaces:
GridResource, GridSurface

public class TextureSurface
extends java.lang.Object
implements GridSurface

This is a basic example GridSurface implementation to show, how to improve terrain rendering by utilizing a detail texture.


Constructor Summary
TextureSurface(GridResourceSpec<GridSurface> spec)
          Constructs a TextureSurface from the given specifications.
TextureSurface(java.net.URL mainTexture)
          Constructs a TextureSurface with a single texture.
TextureSurface(java.net.URL mainTexture, Material material)
          Constructs a TextureSurface with a single texture.
TextureSurface(java.net.URL mainTexture, java.net.URL detailTexture, float detailRepeat, org.jagatoo.opengl.enums.TextureMode blendMode)
          Constructs a TextureSurface with detail texture support.
TextureSurface(java.net.URL mainTexture, java.net.URL detailTexture, float detailRepeat, org.jagatoo.opengl.enums.TextureMode blendMode, Material material)
          Constructs a TextureSurface with detail texture support.
 
Method Summary
 Appearance getAppearance()
          Returns an Appearance instance for a prepared rectangular region of the grid.
 int getTextureUnits()
          Will be called to return the amount of texture units needed.
 org.openmali.vecmath2.TexCoord2f map(float s, float t, int unit)
          Maps the passed grid coordinates to texture coordinates.
 void release()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextureSurface

public TextureSurface(java.net.URL mainTexture)
Constructs a TextureSurface with a single texture.

Parameters:
mainTexture - the name/path of the main color texture for the grid

TextureSurface

public TextureSurface(java.net.URL mainTexture,
                      Material material)
Constructs a TextureSurface with a single texture.

Parameters:
mainTexture - the name/path of the main color texture for the grid.
material - the material properties of this surface

TextureSurface

public TextureSurface(GridResourceSpec<GridSurface> spec)
Constructs a TextureSurface from the given specifications.

Parameters:
spec - the specifications to use

TextureSurface

public TextureSurface(java.net.URL mainTexture,
                      java.net.URL detailTexture,
                      float detailRepeat,
                      org.jagatoo.opengl.enums.TextureMode blendMode)
Constructs a TextureSurface with detail texture support.

Parameters:
mainTexture - the name/path of the main color texture for the grid.
detailTexture - the name/path of the repeating detail texture.
detailRepeat - the amount of repetitions (per side) of the detail texture
blendMode - the blend mode of the detail texture (see TextureAttributes)

TextureSurface

public TextureSurface(java.net.URL mainTexture,
                      java.net.URL detailTexture,
                      float detailRepeat,
                      org.jagatoo.opengl.enums.TextureMode blendMode,
                      Material material)
Constructs a TextureSurface with detail texture support.

Parameters:
mainTexture - the name/path of the main color texture for the grid.
detailTexture - the name/path of the repeating detail texture.
detailRepeat - the amount of repetitions (per side) of the detail texture
blendMode - the blend mode of the detail texture (see TextureAttributes)
material - the material properties of this surface
Method Detail

release

public void release()

Specified by:
release in interface GridResource
Specified by:
release in interface GridSurface

getAppearance

public Appearance getAppearance()
Returns an Appearance instance for a prepared rectangular region of the grid. We only set up one appearance for our grid.

Specified by:
getAppearance in interface GridSurface

getTextureUnits

public int getTextureUnits()
Will be called to return the amount of texture units needed.

Specified by:
getTextureUnits in interface GridSurface
Returns:
the number of texture units

map

public org.openmali.vecmath2.TexCoord2f map(float s,
                                            float t,
                                            int unit)
Maps the passed grid coordinates to texture coordinates.

Specified by:
map in interface GridSurface
Parameters:
s - the "longitude" coordinate of the grid
t - the "latitude" coordinate of the grid
unit - the texture unit for which the coordinates have to be calculated.
Returns:
a texture coordinate