Tugcga / Path-Finder

Python and AssemblyScript implementations of path finding and collision avoidance algorithms in navigation meshes
28 stars 6 forks source link

example code to generate navmesh for indoor scene #10

Open zkf1997 opened 1 year ago

zkf1997 commented 1 year ago

Thanks for this great repo! I am using the python version to generate navmesh for indoor scenes and got into some problems. I am testing with one simplest scene with a single sofa on the floor plane and I find the generated navmesh just ignore the sofa and think all the plane is walkable. I attached the obj model, may you help to show how to generate nav mesh for such scenes? I am also a bit confused how the parameters for baker.bake could be properly set for such indoor scenes. scene.zip

Tugcga commented 1 year ago

It looks like the baking algorithm is sensitive tot he scene scale. It will be better to use the scene, where agent is nearly 2 unit height and 0.2 - 0.8 units radius. In this case the result will be more predictable. If you already have an exported scene to *.obj, then before setting vertices to the baker engine, scale it up, then bake navmesh, obtain the result and finally scale it down. The next picture is an example: img_01 In this example I use this simple technique. Of course, you should select proper agent radius for correct result. In your example the size of the scene is very small, so, the radius of the agent = 0.6 looks unnatural.

Most important parameters for baking are the following. Cell Size and Cell Height used in the voxelization step of the baking. It voxelize all geometry and use these voxels to build the navigation mesh. So, less size of voxels leads to more detailed navigation mesh. But very small size produce a huge number of voxels. Agent Height used only for areas of the geometry which overhang over the ground. Agent Radius is a radius of the agent. Agent Max Climb defines the height over ground which is available for the agent. Stairs is an example which use this parameter. If this parameter is small, then each step in the stair will be separate are. With large value all these areas connected into one sloped plane.

zkf1997 commented 1 year ago

Thanks for your kind help. I tried to use a smaller voxel size and height and found it worked. The web demo is also very helpful!