Voxel-based terrain area types

247 views
Skip to first unread message

Ed Catchpole

unread,
Jan 14, 2014, 10:14:17 AM1/14/14
to recastna...@googlegroups.com
Hi,

I'm building a recast mesh from terrain that's already voxel-based using rcAddSpan. The next thing I need to do is alter the area type of the mesh based on surface types that change at voxel-granularity (the area types are just two rough types - "terrain" and "road", so it shouldn't get too noisy).

I used to pass RC_WALKABLE_AREA as the 'area' parameter on rcAddSpan; I've now changed this to be RC_NULL_AREA, 1 (terrain) or 2 (road), but I'm not seeing any changes in the mesh generated (should new areas appear as new triangles in the mesh?) or the paths that use it.

Also, is using the area parameter on rcAddSpan at voxelisation stage equivalent to using rcMarkBoxArea when building the compact heightfield?

Cheers!

Mikko Mononen

unread,
Jan 14, 2014, 2:09:19 PM1/14/14
to recastna...@googlegroups.com
Hi,
Setting area type in rcAddSpan() should result different areas appearing in the navmesh. How big is your character in relation to your voxel size? In general you should have at least 4-6 voxels per character diameter, so if you're game is something like MineCraft, you should upscale your voxels as you pass them to Recast (that is, each voxel is i.e. 6x6 Recast spans).

--mikko 


--
 
---
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.

Ed Catchpole

unread,
Jan 14, 2014, 2:34:58 PM1/14/14
to recastna...@googlegroups.com
Hi Mikko, thanks for replying so quickly. Currently my characters are 0.8m diameter and the mesh voxel size is 1m.

Would this be the source of the seemingly absent areas? I'll try increasing the voxel resolution as recommended. I assume the areas should show up as distinct triangles in the navmesh debug render?

Mikko Mononen

unread,
Jan 14, 2014, 2:49:00 PM1/14/14
to recastna...@googlegroups.com
Yeah, they should show up, just like if you mark an area using the volumes. Let me know if it works out.

Btw, are you adding the voxels one at a time, or a vertical run of voxels as one span? Some of the filtering code which tries to fix some corner cases in more natural looking levels. If you are adding one voxel at a time you could also try to set flagMergeThr=0. That prevens some of the merging code to take place. The general idea with the merge flag is that small non-walkable triangles in level geometry (i.e. sides of small rocks or tree roots) does not prevent navigation.

I recommend to add the voxels as long spans in general.


--mikko


On Tue, Jan 14, 2014 at 9:34 PM, Ed Catchpole <ecatch...@googlemail.com> wrote:
Hi Mikko, thanks for replying so quickly. Currently my characters are 0.8m diameter and the mesh voxel size is 1m.

Would this be the source of the seemingly absent areas? I'll try increasing the voxel resolution as recommended. I assume the areas should show up as distinct triangles in the navmesh debug render?

Ed Catchpole

unread,
Jan 14, 2014, 2:58:37 PM1/14/14
to recastna...@googlegroups.com
Ok, excellent - I'm currently adding the longest spans possible, splitting them only when the area type would change or it hits air.

Ed Catchpole

unread,
Jan 15, 2014, 7:33:08 AM1/15/14
to recastna...@googlegroups.com
Increasing the voxel resolution sorted it out - I can clearly see the roads being marked out as different triangles, and route-finding is now being influenced by the lower-cost areas. Thanks!

Mikko Mononen

unread,
Jan 15, 2014, 10:31:22 AM1/15/14
to recastna...@googlegroups.com
Cool!

--mikko


On Wed, Jan 15, 2014 at 1:33 PM, Ed Catchpole <ecatch...@googlemail.com> wrote:
Increasing the voxel resolution sorted it out - I can clearly see the roads being marked out as different triangles, and route-finding is now being influenced by the lower-cost areas. Thanks!

--

Jeremy Swigart

unread,
Mar 14, 2014, 4:39:43 AM3/14/14
to recastna...@googlegroups.com
Related to this functionality, is it possible to create custom areas by rasterizing a full model? For instance, is it possible to use a 'door' area on the geometry that makes up this door in a way that would result in just the ground being marked off. I'm hoping to automate this as much as possible to avoid the need to go and manually draw polygons on the floor within the door footprint. Should just rasterize the walkable triangles of the door with my door area type and leave out the unwalkable triangles?(due to slope, etc) Back when I used Navpower you could add 'obstacles' like a convex shape or bounding box and it would cut out the regions from the floor. It worked with boolean operations though rather than re-rasterization, so I'm not quite sure how to get the same effect with the rasterization. Technically it may not be safe to assume that the door will have walkable geometry at the ground level of the other navigation around it so maybe the way to do it would be to use rcMarkConvexPolyArea with a projected 2d hull of the door vertice?

Thanks.
door.png

Mikko Mononen

unread,
Mar 14, 2014, 5:07:09 AM3/14/14
to recastna...@googlegroups.com
Hi,
You can use convex volumes to mark areas in the compact heigh field. Take a look at the Convex Area Tool in the demo.

Generall marking the area type of compact heighfield before calling the region building operations is something you can tinker with yourself too. For example some people use it to alter the tessellation of the navmesh.


--mikko


For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages