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

Represents the mesh data for a PolyMesh object.

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++ 
[SerializableAttribute]
public sealed class PolyMeshData
<SerializableAttribute> _
Public NotInheritable Class PolyMeshData
[SerializableAttribute]
public ref class PolyMeshData sealed

Members

            
 All Members  Constructors   Fields   Methods  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
PolyMeshData(Int32, Int32, Int32)
Constructor.
areas
The area assigned to each polygon. [Length: >= polyCount]
borderSize
The AABB border size used to build the mesh. [Limit: >= 0] [Units: XZCellSize]
boundsMax
The maximum bounds of the mesh's AABB.
boundsMin
The minimum bounds of the mesh's AABB.
CanFit(Int32, Int32, Int32)
Checks the size of the buffers to see if they are large enough to hold the specified data.
flags
The flags assigned to each polygon. [Length: >= polyCount]
maxVertsPerPoly
The maximum vertices per polygon. [Limits: 3 <= value <= MaxAllowedVertsPerPoly]
polyCount
The number of polygons.
polys
Polygon and neighbor data. [Length: >= polyCount * 2 * maxVertsPerPoly]
regions
The region id assigned to each polygon. [Length: >= polyCount]
Resize(Int32, Int32, Int32)
Clears all object data and resizes the buffers.
vertCount
The number of vertices.
verts
Mesh vertices. [(x, y, z) * vertCount]
walkableHeight
The walkable height used to build the mesh. [Units: World]
walkableRadius
The walkable radius used to build the mesh. [Limit: >= 0] [Units: World]
walkableStep
The maximum walkable step used to build the mesh. [Limit: >= 0] [Units: World]
xzCellSize
The xz-plane cell size. [Limit: >= MinCellSize]
yCellSize
The y-axis cell height. [Limit: >= MinCellSize]

Remarks

Warning: The serializable attributewill be removed in v0.5. Use GetSerializedData(Boolean) instead of serializing this object.

Represents a mesh of potentially overlapping convex polygons of between three and maxVertsPerPoly vertices. The mesh exists within the context of an axis-aligned bounding box (AABB) with vertices laid out in an evenly spaced grid based on xz-plane and y-axis cells.

This class is not compatible with Unity serialization.

Examples

Iterating the Polygons

CopyC#
int[] pTargetVert = new int[2];

// Loop through the polygons.
for (int iPoly = 0; iPoly <polyCount; iPoly++)
{
    int pPoly = iPoly * maxVertsPerPoly * 2;

    // Loop through the edges.
    for (int iPolyVert = 0; iPolyVert <maxVertsPerPoly; iPolyVert++)
    {
        int iv = polys[pPoly + iPolyVert];

        if (iv == NullIndex)
            // Soft end of the polygon.
            break;

        if (polys[pPoly + maxVertsPerPoly + iPolyVert]
                == NullIndex)
        {
            // The edge is a solid border.
        }
        else
        }
            // The edge connects to another polygon.
        }

        // Pointer to first edge vertex.
        pTargetVert[0] = iv * 3;

        if (iPolyVert + 1 >= maxVertsPerPoly)
            // Reached hard end of polygon.  Loop back.
            iv = polys[pPoly + 0];
        else
        {
            iv = polys[pPoly + iPolyVert + 1];
            if (iv == NullIndex)
                // Reached soft send of polygon.  Loop back.
                iv = polys[pPoly + 0];
        }
        // Pointer to second edge vertex.
        pTargetVert[1] = iv * 3;

        for (int i = 0; i <2; i++)
        {
            int p = pTargetVert[i];
            int x = verts[p + 0];
            int y = verts[p + 1];
            int z = verts[p + 2];
            float worldX = boundsMin[0] + x * xzCellSize;
            float worldY = boundsMin[1] + y * yCellSize;
            float worldZ = boundsMin[2] + z * xzCellSize;
            // Do something with the vertices.
        }
    }
}

Inheritance Hierarchy

System..::..Object
  org.critterai.nmgen..::..PolyMeshData

See Also