org.critterai.nmgen
Class SolidHeightfieldBuilder

java.lang.Object
  extended by org.critterai.nmgen.SolidHeightfieldBuilder

public final class SolidHeightfieldBuilder
extends Object

A class used to build solid heightfields from source geometry using a given configuration. The solid heightfield represents the space obstructed by the source geometry.

Each triangle in the source geometry is voxelized using conservative voxelization and added to the field. Conservative voxelization is an algorithm that ensures that polygon surfaces are completely encompassed by the the generated voxels.

At the end of the process, spans with the SpanFlags.WALKABLE flag have survived the following tests:

See Also:
The Voxelization Process, Introduction to Heightfields, Conservative Voxelization (PDF)

Constructor Summary
SolidHeightfieldBuilder(float cellSize, float cellHeight, int minTraversableHeight, int maxTraversableStep, float maxTraversableSlope, boolean clipLedges)
          Constructor
 
Method Summary
 SolidHeightfield build(float[] vertices, int[] indices)
          Generates a solid heightfield from the provided source geometry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SolidHeightfieldBuilder

public SolidHeightfieldBuilder(float cellSize,
                               float cellHeight,
                               int minTraversableHeight,
                               int maxTraversableStep,
                               float maxTraversableSlope,
                               boolean clipLedges)
Constructor

Parameters:
cellSize - The size of the cells. (The grid that forms the base of the field.)

This value represents the x and z-axis sampling resolution to use when generating voxels.

cellHeight - The height increment of the field.

This value represents the y-axis sampling resolution to use when generating voxels.

minTraversableHeight - Represents the minimum floor to ceiling height that will still allow a floor area to be considered traversable.

Permits detection of overhangs in the geometry which make the geometry below become unwalkable.

Constraints: > 0

maxTraversableStep - Represents the maximum ledge height that is considered to still be traversable.

Prevents minor deviations in height from improperly showing as obstructions. Permits detection of stair-like structures, curbs, etc.

Constraints: >= 0

maxTraversableSlope - The maximum slope that is considered traversable. (Degrees)

Spans that are at or above this slope have the SpanFlags.WALKABLE flag removed.

Constraints: 0 <= value <= 85

clipLedges - Indicates whether ledges should be marked as unwalkable. I.e. The SpanFlags.WALKABLE flag will be removed.

A ledge is a normally traversable span that has one or more accessible neighbors with a an un-steppable drop from span top to span top.

E.g. If an agent using the navmesh were to travel down from the ledge span to its neighbor span, it would result in the maximum traversable step distance being violated. The agent cannot legally "step down" from a ledge to its neighbor.

Method Detail

build

public SolidHeightfield build(float[] vertices,
                              int[] indices)
Generates a solid heightfield from the provided source geometry. The solid heightfield will represent the space obstructed by the source geometry.

The SpanFlags.WALKABLE will be applied to spans whose top surface is considered traversable. See the class description for details.

Parameters:
vertices - Source geometry vertices in the form (x, y, z).
indices - Source geometry indices in the form (VertA, VertB, VertC). Wrapped: Clockwise.
Returns:
The generated solid heightfield, or null if the generation fails.


Project Home and Source Code

Copyright 2010 Stephen Pratt. All rights reserved. Use is subject to license terms.