Class FloodFill
raft.kilavuz.grid
java.lang.Object
  raft.kilavuz.grid.FloodFill

public class FloodFill
extends Object

creates a Grid by floodfilling from a given set of starting locations. FloodFill creates a kind of 2d grid in 3d space which can take us up or down slopes, across bridges and over and under overpasses. FloodFill also takes care of jumping over obstacles and gaps.

FloodFill class itself only organizes the floodfill process. actual reachability checks is delegated to StepChecker. FloodFill decides which direction to check and also makes sure if returned values are in proper range.

jump reachability is only checked for cells which cannot be reached with simple step. jumpDistance is the upper limit of how far a unit can jump in cardinal directions. for diagonal jumps round(sqrt(2) * jumpDistance)) is used as horizontal and vertical upper limit

pseudo code for FloodFill is something like:

    add initial points to list
    while list not empty
       while list not empty
          remove first point in list
          floodfill to direct neighbours
       for each point which isnt checked for jump before
                      and is not traversable for some certain direction
              check for jump reachability and add found points to list
 

floodfilling may be a quite time and memory consuming process especially for large maps

See Also:
Grid, StepChecker

Field Summary
static boolean
static boolean
static int
radius
debug variable to restrict flood fill to a region.
Constructor Summary
FloodFill(List<Vector3> initialPoints, StepChecker stepChecker, float cellWidth, float cellHeight, float cellMatchRatio, float stepRatio, float jumpRatio, float fallRatio, int jumpDistance, boolean diagonalJump)
creates a new FloodFill starting from a few points
FloodFill(Vector3 initialPoint, StepChecker stepChecker, float cellWidth, float cellHeight, float cellMatchRatio, float stepRatio, float jumpRatio, float fallRatio, int jumpDistance, boolean diagonalJump)
creates a new FloodFill starting at one point
Method Summary
getGrid()
returns the created grid
Field Detail
DIAGONAL_JUMP_ALLOWED
public static final boolean DIAGONAL_JUMP_ALLOWED

DIAGONAL_JUMP_NOT_ALLOWED
public static final boolean DIAGONAL_JUMP_NOT_ALLOWED

radius
public static int radius
debug variable to restrict flood fill to a region. set to a positive value to use. if set only a square region with each side 2*radius+1 will be scanned
Constructor Detail
FloodFill
public FloodFill(Vector3 initialPoint,
                 StepChecker stepChecker,
                 float cellWidth,
                 float cellHeight,
                 float cellMatchRatio,
                 float stepRatio,
                 float jumpRatio,
                 float fallRatio,
                 int jumpDistance,
                 boolean diagonalJump)
creates a new FloodFill starting at one point
Parameters:
stepChecker - the StepChecker to spot reachabilities between cells
cellWidth - cell width
cellHeight - cell height
cellMatchRatio - the ration to cell height to consider two cells the same. 0.1 <= cellMatchRatio 0.5 is a good value
stepRatio - how much a unit can step up, ratio to cell height. 0 < stepRatio <= 0.5
jumpRatio - how much a unit can jump up, ratio to cell height. setting <= stepRatio disables up jumping
fallRatio - how much a unit can fall down, ratio to cell height. >= stepRatio
jumpDistance - how many cells a unit can jump away. values less than 2 disables jumping away
diagonalJump - if diagonalJump is allowed.

FloodFill
public FloodFill(List<Vector3> initialPoints,
                 StepChecker stepChecker,
                 float cellWidth,
                 float cellHeight,
                 float cellMatchRatio,
                 float stepRatio,
                 float jumpRatio,
                 float fallRatio,
                 int jumpDistance,
                 boolean diagonalJump)
creates a new FloodFill starting from a few points
Parameters:
initialPoints - starting points in world space. note all points' x, z values are rounded accordog to first point and cellWidth
stepChecker - the StepChecker to spot reachabilities between cells
cellWidth - cell width
cellHeight - cell height
cellMatchRatio - the ration to cell height to consider two cells the same. 0.1 <= cellMatchRatio 0.5 is a good value
stepRatio - how much a unit can step up, ratio to cell height. 0 < stepRatio
jumpRatio - how much a unit can jump up, ratio to cell height. setting <= stepRatio disables up jumping
fallRatio - how much a unit can fall down, ratio to cell height. >= stepRatio
jumpDistance - how many cells a unit can jump away. values less than 2 disables jumping away
diagonalJump - if diagonalJump is allowed.
Method Detail
getGrid
public Grid getGrid()
returns the created grid
Java API documentation generated with DocFlex/Doclet v1.5.2
DocFlex/Doclet is both a multi-format Javadoc doclet and a free edition of DocFlex/Javadoc. If you need to customize your Javadoc without writing a full-blown doclet from scratch, DocFlex/Javadoc may be the only tool able to help you! Find out more at www.docflex.com