[This is preliminary documentation and is subject to change.]

Provides a representation of the open (unobstructed) space above the solid surfaces of a voxel field.

Namespace: org.critterai.nmgen
Assembly: cai-nmgen (in cai-nmgen.dll) Version: 0.4.0.0 (0.4.0.0)

Syntax

         
 C#  Visual Basic  Visual C++ 
public sealed class CompactHeightfield : IManagedObject
Public NotInheritable Class CompactHeightfield _
	Implements IManagedObject
public ref class CompactHeightfield sealed : IManagedObject

Members

         
 All Members  Properties   Methods  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
ApplyMedianFilter(BuildContext)
Applies a median filter to the walkable areas. (Removes noise.)
BorderSize
The AABB border size used during the build of the field.
BoundsMax
The maximum bounds of the heightfield in world space.
BoundsMin
The minimum bounds of the heightfield in world space.
Build(BuildContext, Heightfield, Int32, Int32)
Creates a compact open heightfield from a solid heightfield.
BuildDistanceField(BuildContext)
Builds the distance field for the heightfield.
BuildRegions(BuildContext, Int32, Int32, Int32)
Builds region data for the heightfield using watershed partitioning.
BuildRegionsMonotone(BuildContext, Int32, Int32, Int32)
Builds region data for the heightfield using simple monotone partitioning.
Depth
The depth of the heighfield. (Along the z-axis in cell units.)
ErodeWalkableArea(BuildContext, Int32)
Erodes the walkable area within the heightfield by the specified radius.
Finalize()()()()
Destructor.
(Overrides Object..::..Finalize()()()().)
GetAreaData(array<Byte>[]()[][])
Loads the heightfield's area data into the provided buffer.
GetCellData(array<CompactCell>[]()[][])
Loads the heighfield's CompactCell data into the provided buffer.
GetDistanceData(array<UInt16>[]()[][])
Loads the heightfield's distance field data into the provided buffer.
GetSpanData(array<CompactSpan>[]()[][])
Loads the heightfield's CompactSpan data into the provided buffer.
HasDistanceData
True if distance data is available.
IsDisposed
True if the object has been disposed and should no longer be used.
MarkBoxArea(BuildContext, Vector3, Vector3, Byte)
Applies the area to all spans within the specified bounding box. (AABB)
MarkConvexPolyArea(BuildContext, array<Vector3>[]()[][], Single, Single, Byte)
Applies the area to the all spans within the specified convex polygon.
MarkCylinderArea(BuildContext, Vector3, Single, Single, Byte)
Applied the area to all spans within the specified cylinder.
MaxDistance
The maximum distance value for any span within the field.
MaxRegion
The maximum region id for any span within the field.
RequestDisposal()()()()
Frees all unmanaged resources controlled by the object and marks it as disposed.
ResourceType
The type of unmanaged resources within the object.
SpanCount
The number of spans in the field.
WalkableHeight
The walkable height used during the build of the field.
WalkableStep
The walkable step used during the build of the field.
Width
The width of the heightfield. (Along the x-axis in cell units.)
XZCellSize
The width/depth size of each cell. (On the xz-plane.)
YCellSize
The height increments for span data. (On the y-axis.)

Remarks

For this type of heightfield, the spans represent the floor and ceiling of the open spaces.

Data is stored in a compact, efficient manner.

The following process can be used to iterate spans:

CopyC#
int w = chf.Width;
int d = chf.Depth;

CompactCell[] cells = new CompactCell[w * d];
chf.GetCellData(cells);

CompactSpan[] spans = new CompactSpan[chf.SpanCount];
chf.GetSpanData(spans);

for (int z = 0; z < d; ++z)
{
    for (int x = 0; x < w; ++x)
    {
        CompactCell c = cells[x + z * w];
        for (int i = (int)c.Index, ni = (int)(c.Index + c.Count)
            ; i < ni
            ; ++i)
        {
            CompactSpan s = spans[i];

            // Do something...

            // If you have extracted area and distance data, you
            // can access it with the same index.
            // E.g. areas[i] or distance[i].

            // To access neighbor information...

            for (int dir = 0; dir < 4; ++dir)
            {
                if (s.GetConnection(dir) != CompactSpan.NotConnected)
                {
                    int nx = x + CompactSpan.GetDirOffsetX(dir);
                    int nz = z + CompactSpan.GetDirOffsetZ(dir);
                    int ni = (int)cells[ax + az * w].Index 
                        + s.GetConnection(dir);

                    // ni represents the index of the neighbor.
                    // So spans[ni], areas[ni], directions[ni]
                    // gets the neighbor.
                }
            }
        }
    }
}

Spans contain neighbor connection data that can be used to locate axis-neighbors. Axis neighbors are spans that are offset from the current cell column as follows:

Direction 0 = (-1, 0)
Direction 1 = (0, 1)
Direction 2 = (1, 0)
Direction 3 = (0, -1)

These standard offset can be obtained from the GetDirOffsetX(Int32) and GetDirOffsetZ(Int32) methods.

See the earlier example code for information on how to use connection information.

Behavior is undefined if used after disposal.

Inheritance Hierarchy

System..::..Object
  org.critterai.nmgen..::..CompactHeightfield

See Also