I'm trying to build a navigation mesh with Havok AI, the NavMesh vertex data is modeled with 3D Max.

Definitions taken from Havok to construct a NavMesh:

struct Edge{

    int m_a; // The starting vertex


    int m_b; // The end vertex

        /// The edge key of the other half of this edge (HKAI_INVALID_PACKED_KEY implies that there is no other half and that this is a boundary edge)
    int m_oppositeEdge;

        /// The face key of other half of this edge (HKAI_INVALID_PACKED_KEY implies that there is no other half and that this is a boundary edge)
    int m_oppositeFace;
}

struct Face
{
    int m_startEdgeIndex; // The start edge index for this face

    EdgeIndex m_startUserEdgeIndex; // The start index of user edges for this face

    // The number of standard geometric edges

    hkInt16 m_numEdges;

    // The number of user edges

    hkInt16 m_numUserEdges;
}

a simple Vertex is hkVector4 (4 floats)

well the class hkaiNavMesh has these members

class hkaiNavMesh 
{
...
            /// Nav mesh faces see hkaiNavMesh::Face
        hkArray<struct Face>        m_faces;

            /// Nav mesh edges see hkaiNavMesh::Edge
        hkArray<struct Edge>        m_edges;

            /// Verts
        hkArray<hkVector4>          m_vertices;
...
};

So, as can understand how to build navmesh in havok (I import vertices from 3D Max then I add them to vertex list) I should create the Edges first, but I got confused in Face creation because a Face is created with 3 or more Edge indices (a Edge contains two Vertices )

I know how to create conventionally mesh which is basically the vertices and Faces (which are a list of integers also called indices) like a normal mesh, and this is I have (vertices and indices in fact because 3 indices are one face)

This is how I create edges:

// hkaiNavMesh::AddEdgeContext is an struct wich has the edge to add
    hkArray<hkaiNavMesh::AddEdgeContext> edges;
    edges.clear();

    // gets the total Indices 
    for(int i = 0; i < allIndex.GetSize(); i+=3)
    {

        // to construct an edge I take a face which are three indices and construct 3 edges 
        // let say whe have 3 indices A, B, C to create an edge i take A and B for one, A and C for another
        // B and C for the third edge

        hkaiNavMesh::AddEdgeContext context;

        // A and B (allIndex[i]) - allIndex[i+1]
        context.m_edge.m_a = allIndex[i];
        context.m_edge.m_b = allIndex[i+1];

        // checks if already exist and edge refering the same vertex indices
        if(!ExistEdge(context.m_edge, edges))
        {
            edges.pushBack(context);
        }

        // A and C (allIndex[i]) - allIndex[i+2]
        context.m_edge.m_a = allIndex[i];
        context.m_edge.m_b = allIndex[i+2];

        if(!ExistEdge(context.m_edge, edges))
        {
            edges.pushBack(context);
        }
        // B and C (allIndex[i+1]) - allIndex[i+2]
        context.m_edge.m_a = allIndex[i+1];
        context.m_edge.m_b = allIndex[i+2];

        if(!ExistEdge(context.m_edge, edges))
        {
            edges.pushBack(context);
        }
    }

but at the time to create the Faces using the edges indices I can't, because as I said a face are 3 indices, if an Edge has 2 vertex indices if I use 2 Edge indices to make a face it results in an exception:

([0x1B5ED013] Assert: mesh.getEdge(p).m_b == edge1.m_aStack) on validateFace.

What do you think I have to do, read or understand?

To refer Havok classes (hkaiNavMesh.h) source code is at: https://github.com/Bewolf2/projectanarchy/tree/master/Source/Ai/Pathfinding/NavMesh

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.