Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.vrspace.vrmlclient
Class Terrain  view Terrain download Terrain.java

java.lang.Object
  extended byorg.vrspace.vrmlclient.Terrain
Direct Known Subclasses:
ImageTerrain

public class Terrain
extends java.lang.Object


Field Summary
 java.lang.String appearance
           
(package private)  int dim
           
(package private)  java.awt.Frame frame
           
(package private)  double[][] h
           
(package private)  double h1
           
(package private)  double h2
           
(package private)  double h3
           
(package private)  double h4
           
 double height
          used for height calculation and vrml generation
 RGB land
          land color: between seaLevel and topLevel
(package private)  int lod
          level of detail and number of iterations, grid size is 2^lod
(package private)  double max
          min and max height
(package private)  double min
          min and max height
private  boolean reset
           
(package private)  java.util.Random rng
           
(package private)  double roughness
           
(package private)  double scale
           
 RGB sea
          sea color: all below seaLevel
 double seaLevel
          below this use sea color, default 0
(package private)  long seed
           
 double size
          grid size, used in vrml generation
 RGB top
          top color: above landLevel
 double topLevel
          above this use top color, default .7
(package private)  java.util.Stack undo
           
(package private)  double x
           
(package private)  double z
           
 
Constructor Summary
protected Terrain()
           
  Terrain(double x, double z, int lod, double size, double h1, double h2, double h3, double h4, double roughness, long seed)
          Creates new random fractal terrain, at position (x,z), with heights at corners h1...h4.
Generates new fractal terrain with specified level of detail unless lod is 1.
 
Method Summary
 double cellSize()
          Returns size of one grid element
private  void diamond(int x, int y, int side, double scale)
           
 double getAltitude(double x, double z)
          relative (0..1) altitude at absolute point (x,z)
 double getAltitude(int i, int j)
          Relative altitude (0...1) at index (i,j)
 float[][] getColor()
          Retreives terrain color as float[][]
 RGB getColor(double a)
          Color at relative (0...1) height
 RGB getColor(int i, int j)
          Color at index (i,j)
 double getDistance(double x, double y, double z)
          Distance (altitude) between this point and the terrain
 float[] getHeight()
          Returns height matrix as float[]
 double getHeight(double x, double z)
          Absolute altitude (-size...size) at absolute point (x,z)
 double getHeight(int i, int j)
          Absolute altitude (-size...size) at index (i,j)
 java.lang.String gridVrml()
          VRML 2.0 ElevationGrid string
 boolean isOver(double x, double z)
          Is point (x,z) over this terrain?
(package private)  void iteration(int i)
           
 java.lang.String nullGridVrml()
          VRML 2.0 string with 0 heights and colors
private  double rnd()
           
private  void setupHeight()
           
private  void square(int x, int y, int side, double scale)
           
 Terrain subTerrain(double x, double z, double size)
          Creates terrain from this terrain, with center at (x,z) and specified size
IMPORTANT:
new terrain may not have specified size nor coordinates!
 Terrain subTerrain(int x, int z, int lod)
          Creates subset of this terrain at index (x,z) with specified lod.
 java.lang.String toVrml()
          VRML 2.0 Transform string
 int xIndex(double x)
          Index of grid element on this position
 int zIndex(double z)
          Index of grid element on this position
 void zoomIn()
          Zoom in - increases level of detail
 void zoomOut()
          Zoom out - level of detail decreases.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dim

int dim

x

double x

z

double z

h

double[][] h

h1

double h1

h2

double h2

h3

double h3

h4

double h4

roughness

double roughness

lod

int lod
level of detail and number of iterations, grid size is 2^lod


size

public double size
grid size, used in vrml generation


height

public double height
used for height calculation and vrml generation


min

double min
min and max height


max

double max
min and max height


rng

java.util.Random rng

reset

private boolean reset

seed

long seed

scale

double scale

sea

public RGB sea
sea color: all below seaLevel


land

public RGB land
land color: between seaLevel and topLevel


top

public RGB top
top color: above landLevel


seaLevel

public double seaLevel
below this use sea color, default 0


topLevel

public double topLevel
above this use top color, default .7


appearance

public java.lang.String appearance

frame

java.awt.Frame frame

undo

java.util.Stack undo
Constructor Detail

Terrain

protected Terrain()

Terrain

public Terrain(double x,
               double z,
               int lod,
               double size,
               double h1,
               double h2,
               double h3,
               double h4,
               double roughness,
               long seed)
Creates new random fractal terrain, at position (x,z), with heights at corners h1...h4.
Generates new fractal terrain with specified level of detail unless lod is 1.

Method Detail

setupHeight

private void setupHeight()

iteration

void iteration(int i)

diamond

private void diamond(int x,
                     int y,
                     int side,
                     double scale)

square

private void square(int x,
                    int y,
                    int side,
                    double scale)

rnd

private double rnd()

getAltitude

public double getAltitude(double x,
                          double z)
relative (0..1) altitude at absolute point (x,z)


getAltitude

public double getAltitude(int i,
                          int j)
Relative altitude (0...1) at index (i,j)


cellSize

public double cellSize()
Returns size of one grid element


getColor

public RGB getColor(int i,
                    int j)
Color at index (i,j)


getColor

public RGB getColor(double a)
Color at relative (0...1) height


toVrml

public java.lang.String toVrml()
VRML 2.0 Transform string


nullGridVrml

public java.lang.String nullGridVrml()
VRML 2.0 string with 0 heights and colors


gridVrml

public java.lang.String gridVrml()
VRML 2.0 ElevationGrid string


zoomOut

public void zoomOut()
Zoom out - level of detail decreases.


zoomIn

public void zoomIn()
Zoom in - increases level of detail


xIndex

public int xIndex(double x)
Index of grid element on this position


zIndex

public int zIndex(double z)
Index of grid element on this position


subTerrain

public Terrain subTerrain(double x,
                          double z,
                          double size)
Creates terrain from this terrain, with center at (x,z) and specified size
IMPORTANT:
new terrain may not have specified size nor coordinates!


subTerrain

public Terrain subTerrain(int x,
                          int z,
                          int lod)
Creates subset of this terrain at index (x,z) with specified lod.


getHeight

public float[] getHeight()
Returns height matrix as float[]


isOver

public boolean isOver(double x,
                      double z)
Is point (x,z) over this terrain?


getDistance

public double getDistance(double x,
                          double y,
                          double z)
Distance (altitude) between this point and the terrain


getHeight

public double getHeight(double x,
                        double z)
Absolute altitude (-size...size) at absolute point (x,z)


getHeight

public double getHeight(int i,
                        int j)
Absolute altitude (-size...size) at index (i,j)


getColor

public float[][] getColor()
Retreives terrain color as float[][]