Volumes Of Funhttp://www.volumesoffun.com/phpBB3/ PolyVox SurfaceExtractor + Recast Navigationhttp://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=545 Page 1 of 1

 Author: kklouzal [ Tue Oct 22, 2013 8:33 am ] Post subject: PolyVox SurfaceExtractor + Recast Navigation 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 I have two options, rasterize each triangle into the heightfieldCode:/// 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 heightfieldCode:/// 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.

 Author: David Williams [ Wed Oct 23, 2013 9:32 am ] Post subject: Re: PolyVox SurfaceExtractor + Recast Navigation 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 withIt 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.

 Page 1 of 1 All times are UTC Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Grouphttp://www.phpbb.com/