org.xith3d.terrain.legacy
Class TerrainDataBank

java.lang.Object
  extended by org.xith3d.terrain.legacy.TerrainDataBank
All Implemented Interfaces:
Scribable

public class TerrainDataBank
extends java.lang.Object
implements Scribable

Terrain data bank holds terrain information for a given portion of the world. Banks can be read and written with great speed from disk because they are organized in large arrays.

Multiple banks can be used for the same portion of the world, stored at different densities. Then the terrain system can use the lower density bank for areas far away, saving on memory.


Field Summary
protected  int freeList
           
protected  int[] handles
           
static int MUL_CHILD
           
static int MUL_DIRTY
           
static int MUL_ENABLED
           
static int MUL_ERROR
           
static int MUL_MINMAX
           
static int MUL_NEXT
           
static int MUL_STATIC
           
static int MUL_SUB_ENABLED
           
static int MUL_VERTEX
           
protected  TerrainDataBank newBank
           
 
Constructor Summary
TerrainDataBank()
           
TerrainDataBank(int bankId, int max)
           
 
Method Summary
 int allocateNode()
          Takes a node off the free list and returns the index
static TerrainDataBank compress(TerrainDataBank db)
          Compresses the data bank by moving the non-deleted nodes down near the front and then building a new version which is shorter.
 void delete(int node)
           
static TerrainDataBank expand(TerrainDataBank db)
           
 int getChild(int node, int index)
           
 int getChildBank(int node, int index)
           
 boolean getDirty(int node)
           
 byte getEnabledFlags(int node)
           
 short getError(int node, int index)
           
 short getMaxY(int node)
           
 short getMinY(int node)
           
 int getNext(int node)
           
 boolean getStatic(int node)
           
 byte getSubEnabledCount(int node, int index)
           
 float getY(int node, int index)
           
 void initialize(int max)
           
 boolean isCompressed()
           
 void load(ScribeInputStream in)
           
 void save(ScribeOutputStream out)
           
 void setChild(int node, int index, int val)
           
 void setChildBank(int node, int index, int val)
           
 void setDirty(int node, boolean val)
           
 void setEnabledFlags(int node, byte val)
           
 void setError(int node, int index, short val)
           
 void setMaxY(int node, short val)
           
 void setMinY(int node, short val)
           
 void setNext(int node, int val)
           
 void setStatic(int node, boolean val)
           
 void setSubEnabledCount(int node, int index, byte val)
           
 void setY(int node, int index, float val)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MUL_VERTEX

public static final int MUL_VERTEX
See Also:
Constant Field Values

MUL_ERROR

public static final int MUL_ERROR
See Also:
Constant Field Values

MUL_SUB_ENABLED

public static final int MUL_SUB_ENABLED
See Also:
Constant Field Values

MUL_CHILD

public static final int MUL_CHILD
See Also:
Constant Field Values

MUL_STATIC

public static final int MUL_STATIC
See Also:
Constant Field Values

MUL_DIRTY

public static final int MUL_DIRTY
See Also:
Constant Field Values

MUL_NEXT

public static final int MUL_NEXT
See Also:
Constant Field Values

MUL_ENABLED

public static final int MUL_ENABLED
See Also:
Constant Field Values

MUL_MINMAX

public static final int MUL_MINMAX
See Also:
Constant Field Values

handles

protected int[] handles

newBank

protected TerrainDataBank newBank

freeList

protected int freeList
Constructor Detail

TerrainDataBank

public TerrainDataBank()

TerrainDataBank

public TerrainDataBank(int bankId,
                       int max)
Method Detail

isCompressed

public boolean isCompressed()

expand

public static TerrainDataBank expand(TerrainDataBank db)

delete

public void delete(int node)

compress

public static TerrainDataBank compress(TerrainDataBank db)
Compresses the data bank by moving the non-deleted nodes down near the front and then building a new version which is shorter. This should be done after a static cull to save disk space and memory. This wont be super fast.

Parameters:
db -
Returns:
the new TerrainDataBank

allocateNode

public int allocateNode()
Takes a node off the free list and returns the index

Returns:
the new handle

getY

public float getY(int node,
                  int index)

setY

public void setY(int node,
                 int index,
                 float val)

getError

public short getError(int node,
                      int index)

setError

public void setError(int node,
                     int index,
                     short val)

getChild

public int getChild(int node,
                    int index)

getChildBank

public int getChildBank(int node,
                        int index)

setChild

public void setChild(int node,
                     int index,
                     int val)

setChildBank

public void setChildBank(int node,
                         int index,
                         int val)

getSubEnabledCount

public byte getSubEnabledCount(int node,
                               int index)

setSubEnabledCount

public void setSubEnabledCount(int node,
                               int index,
                               byte val)

getMinY

public short getMinY(int node)

setMinY

public void setMinY(int node,
                    short val)

getEnabledFlags

public byte getEnabledFlags(int node)

setEnabledFlags

public void setEnabledFlags(int node,
                            byte val)

getMaxY

public short getMaxY(int node)

setMaxY

public void setMaxY(int node,
                    short val)

getStatic

public boolean getStatic(int node)

setStatic

public void setStatic(int node,
                      boolean val)

getDirty

public boolean getDirty(int node)

setDirty

public void setDirty(int node,
                     boolean val)

setNext

public void setNext(int node,
                    int val)

getNext

public int getNext(int node)

initialize

public void initialize(int max)

load

public void load(ScribeInputStream in)
          throws InvalidFormat,
                 java.io.IOException
Specified by:
load in interface Scribable
Throws:
InvalidFormat
java.io.IOException

save

public void save(ScribeOutputStream out)
          throws UnscribableNodeEncountered,
                 java.io.IOException
Specified by:
save in interface Scribable
Throws:
UnscribableNodeEncountered
java.io.IOException