Dear friends, I am following the recast code, here I am stuck in.

107 views
Skip to first unread message

Jack

unread,
May 12, 2013, 9:26:31 PM5/12/13
to recastna...@googlegroups.com
I understand the obj files are to be read by identifiers followed by values. Then I am up to the subdivide function,

static void subdivide(BoundsItem* items, int nitems, int imin, int imax, int trisPerChunk,
                      int& curNode, rcChunkyTriMeshNode* nodes, const int maxNodes,
                      int& curTri, int* outTris, const int* inTris)
{
    int inum = imax - imin;
    int icur = curNode;
   
    if (curNode > maxNodes)
        return;

    rcChunkyTriMeshNode& node = nodes[curNode++];
   
    if (inum <= trisPerChunk)
    {
        // Leaf
        calcExtends(items, nitems, imin, imax, node.bmin, node.bmax);
       
        // Copy triangles.
        node.i = curTri;
        node.n = inum;
       
        for (int i = imin; i < imax; ++i)
        {
            const int* src = &inTris[items[i].i*3];
            int* dst = &outTris[curTri*3];
            curTri++;
            dst[0] = src[0];
            dst[1] = src[1];
            dst[2] = src[2];
        }
    }
    else
    {
        // Split
        calcExtends(items, nitems, imin, imax, node.bmin, node.bmax);
       
        int    axis = longestAxis(node.bmax[0] - node.bmin[0],
                               node.bmax[1] - node.bmin[1]);
       
        if (axis == 0)
        {
            // Sort along x-axis
            qsort(items+imin, inum, sizeof(BoundsItem), compareItemX);
        }
        else if (axis == 1)
        {
            // Sort along y-axis
            qsort(items+imin, inum, sizeof(BoundsItem), compareItemY);
        }
       
        int isplit = imin+inum/2;
       
        // Left
        subdivide(items, nitems, imin, isplit, trisPerChunk, curNode, nodes, maxNodes, curTri, outTris, inTris);
        // Right
        subdivide(items, nitems, isplit, imax, trisPerChunk, curNode, nodes, maxNodes, curTri, outTris, inTris);
       
        int iescape = curNode - icur;
        // Negative index means escape.
        node.i = -iescape;
    }
}

What does it do? Any reference materials I can take a look at?
Thanks
Jack

Mikko Mononen

unread,
May 12, 2013, 9:39:35 PM5/12/13
to recastna...@googlegroups.com
The ChunkyTrimesh is a simple acceleration structure which I use for the demos to make the tile generation faster. It is a simple AABB tree.

For your own implementation you don't need any of that. The important bit of feeding in triangles to Recast is the rcRasterizeTriangle* functions. They feed in the input triangles. You can call one of the indexed triangles methods or even the one that rasterizes just one triangle.


--mikko



Jack

--
 
---
You received this message because you are subscribed to the Google Groups "recastnavigation" group.
To unsubscribe from this group and stop receiving emails from it, send an email to recastnavigati...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jack

unread,
May 12, 2013, 10:40:13 PM5/12/13
to recastna...@googlegroups.com
Now I am up to "spans", what do spans do?
Jack
 

Jack

unread,
May 12, 2013, 11:01:30 PM5/12/13
to recastna...@googlegroups.com
BTW, the contour will be a poly if the trial fit doesn't "fit" in a "square".
Like to say if the obstacle is cutting a corner of a square, there must be a contour to set up, then it is of type "poly"
This is my assumption. Correct me if I am any wrong
Thanks
Jack

 

Mikko Mononen

unread,
May 12, 2013, 11:30:10 PM5/12/13
to recastna...@googlegroups.com
Keep on following the example code... as you can see from the example code, there is a visualization of each step in the demo too, that should help you understand how things work.

--mikko


On Sun, May 12, 2013 at 7:40 PM, Jack <lucky7...@yahoo.com.hk> wrote:
Now I am up to "spans", what do spans do?

Jack
 

--

Ben Hymers

unread,
May 14, 2013, 9:58:19 AM5/14/13
to recastna...@googlegroups.com
Here's a handy resource that explains the process in a slightly more human-friendly way than code:

Reply all
Reply to author
Forward
0 new messages