It is currently Thu Dec 12, 2019 1:59 pm


All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PolyVox SurfaceExtractor + Recast Navigation
PostPosted: Tue Oct 22, 2013 8:33 am 
User avatar

Joined: Thu Sep 05, 2013 3:38 am
Posts: 51
Location: USA - Arizona
Hello once again ;] I have one more pertinent question about PolyVox I need a little help in understanding, that is use with Recast Navigation, specifically how to extract triangle data from the Surface Extractors as is needed by Recast.

I found a Surface Extractor supplies us with Indices & Vertices but no triangle data, that being said I assume you can construct the triangle data from the Indices and Vertices?

Assuming again my previous statement is correct does anyone know how this can be accomplished? If that's not feasible does anyone know how you would go about getting the triangle data? More precisely the x,y,z position of all three vertices of a triangle are required to be passed to Recast.

I'm thinking the indices are some sort of description of a triangle and point to which vertices needed?

As always the communities help is most greatly appreciated :]
I plan to release a tutorial project on how to get the two working, that is if I can do it myself :P

I have two options, rasterize each triangle into the heightfield
Code:
/// Rasterizes a triangle into the specified heightfield.
///  @ingroup recast
///  @param[in,out]   ctx            The build context to use during the operation.
///  @param[in]      v0            Triangle vertex 0 [(x, y, z)]
///  @param[in]      v1            Triangle vertex 1 [(x, y, z)]
///  @param[in]      v2            Triangle vertex 2 [(x, y, z)]
///  @param[in]      area         The area id of the triangle. [Limit: <= #RC_WALKABLE_AREA]
///  @param[in,out]   solid         An initialized heightfield.
///  @param[in]      flagMergeThr   The distance where the walkable flag is favored over the non-walkable flag.
///                          [Limit: >= 0] [Units: vx]
void rcRasterizeTriangle(rcContext* ctx, const float* v0, const float* v1, const float* v2,
                   const unsigned char area, rcHeightfield& solid,
                   const int flagMergeThr = 1);

Or rasterize a triangle mesh into the heightfield
Code:
/// Rasterizes an indexed triangle mesh into the specified heightfield.
///  @ingroup recast
///  @param[in,out]   ctx            The build context to use during the operation.
///  @param[in]      verts         The vertices. [(x, y, z) * @p nv]
///  @param[in]      nv            The number of vertices.
///  @param[in]      tris         The triangle indices. [(vertA, vertB, vertC) * @p nt]
///  @param[in]      areas         The area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]
///  @param[in]      nt            The number of triangles.
///  @param[in,out]   solid         An initialized heightfield.
///  @param[in]      flagMergeThr   The distance where the walkable flag is favored over the non-walkable flag.
///                          [Limit: >= 0] [Units: vx]
void rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,
                    const int* tris, const unsigned char* areas, const int nt,
                    rcHeightfield& solid, const int flagMergeThr = 1);

/// Rasterizes an indexed triangle mesh into the specified heightfield.
///  @ingroup recast
///  @param[in,out]   ctx         The build context to use during the operation.
///  @param[in]      verts      The vertices. [(x, y, z) * @p nv]
///  @param[in]      nv         The number of vertices.
///  @param[in]      tris      The triangle indices. [(vertA, vertB, vertC) * @p nt]
///  @param[in]      areas      The area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]
///  @param[in]      nt         The number of triangles.
///  @param[in,out]   solid      An initialized heightfield.
///  @param[in]      flagMergeThr   The distance where the walkable flag is favored over the non-walkable flag.
///                       [Limit: >= 0] [Units: vx]
void rcRasterizeTriangles(rcContext* ctx, const float* verts, const int nv,
                    const unsigned short* tris, const unsigned char* areas, const int nt,
                    rcHeightfield& solid, const int flagMergeThr = 1);

/// Rasterizes triangles into the specified heightfield.
///  @ingroup recast
///  @param[in,out]   ctx            The build context to use during the operation.
///  @param[in]      verts         The triangle vertices. [(ax, ay, az, bx, by, bz, cx, by, cx) * @p nt]
///  @param[in]      areas         The area id's of the triangles. [Limit: <= #RC_WALKABLE_AREA] [Size: @p nt]
///  @param[in]      nt            The number of triangles.
///  @param[in,out]   solid         An initialized heightfield.
///  @param[in]      flagMergeThr   The distance where the walkable flag is favored over the non-walkable flag.
///                          [Limit: >= 0] [Units: vx]
void rcRasterizeTriangles(rcContext* ctx, const float* verts, const unsigned char* areas, const int nt,
                    rcHeightfield& solid, const int flagMergeThr = 1);


I'm going to attempt to rasterize the triangle mesh into the heightfield since the surface extractor gives me a triangle mesh to work with, it would seem more efficient to do so as well. I'm working in junction with PolyVox forums & Recast forums.

_________________
Dream Big Or Go Home.
ENet - http://enet.bespin.org
Recast - https://github.com/memononen/recastnavigation
Irrlicht - http://irrlicht.sourceforge.net/forum
PolyVox - http://www.volumesoffun.com/phpBB3/
Help Me Help You.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: PolyVox SurfaceExtractor + Recast Navigation
PostPosted: Wed Oct 23, 2013 9:32 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
kklouzal wrote:
I'm thinking the indices are some sort of description of a triangle and point to which vertices needed?


Yes, this is correct. You can read the indices in groups of three to define the triangle. For example, if the index buffer contains (6,2,1,5,6,2,...) then the first triangle is defined by vertices (6,2,1) and the second triangle is defined by vertices (5,6,2). Note that the two triangles share an edge in the example.

kklouzal wrote:
I'm going to attempt to rasterize the triangle mesh into the heightfield since the surface extractor gives me a triangle mesh to work with


It does appear to match the required definition of a triangle mesh quite well, so this is probably right approach.

Maybe it's a bit wasteful though... my limited knowledge of Recast/Detour is that they actually work by voxelising the mesh? Maybe that's only in some cases, and creating the heightfield is an alternative? Of course, using a heightfield will limit your ability to work with caves and stuff, which is presumably one of the reasons you are using PolyVox. Too bad you can't just give them the voxel data directly.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net