org.globalse.arena.sword.algorithm
Class Generator

java.lang.Object
  |
  +--org.globalse.arena.sword.algorithm.Generator
Direct Known Subclasses:
Generator1

public abstract class Generator
extends java.lang.Object

Abstract base class for fractal generators. It provides some common functionality (getRandomValue, crop). Fractal generators must implement the generate() and the getMinMax() method.


Method Summary
protected  double[][] crop(double[][] map)
          Removes the last line and the last row of map.
abstract  double[][] generate(int x, int y, int logOfSize, long seed, double roughness)
          Generates one tile of size (2^logSize)x(2^logSize).
abstract  double[] getMinMax()
          Returns the range in which "most" height values and vegetation values are.
protected  double getRandomValue(double x, double y, double s, double m, long seed)
          Returns a gaussian "random" value with standard deviation s and mean value mean value m.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

generate

public abstract double[][] generate(int x,
                                    int y,
                                    int logOfSize,
                                    long seed,
                                    double roughness)
Generates one tile of size (2^logSize)x(2^logSize).
Parameters:
x - the x-coordinate of the tile
y - the y-coordinate of the tile
logSize - the resulting size is 2^logSize + 1.
roughness - a value in [0,1] that determines how rough the landscape will be
Returns:
A 2-dimensional array

getMinMax

public abstract double[] getMinMax()
Returns the range in which "most" height values and vegetation values are.
Returns:
an array minMax where minMax[0] is the minimum value and minMax[1] is the maximum value

getRandomValue

protected double getRandomValue(double x,
                                double y,
                                double s,
                                double m,
                                long seed)
Returns a gaussian "random" value with standard deviation s and mean value mean value m. The value is not really random. It depends deterministically on x, y and seed.
Parameters:
x - the x coordinate
y - the y coordinate
s - the standard deviation
m - the mean value
Returns:
a gaussian random value with standard deviation s and mean value m

crop

protected double[][] crop(double[][] map)
Removes the last line and the last row of map.
Preconditions:
map.length = map[i].length f.a. 0 <= i < map.length



This page is hosted by the Chair for Applied Software Engineering of the Technische Universität München.
Imprint (Impressum)