- Home /
How can I extract a mesh from the nav mesh?
I am trying to get a mesh from the nav mesh. The way that I have found is by:
NavMeshTriangulation navMeshTriangluation = NavMesh.CalculateTriangulation();
int[] triangles = navMeshTriangluation.indices;
Vector3[] vertices = navMeshTriangluation.vertices;
Then I use AutoWeld from this Unity answers page to remove the duplicates. But when I add a material of a grid square, it appears that uvs are so tight together, the object just shows the color of the grid lines.
I have also played around with High-Level NavMesh Building Components too and was unsuccessful.
I would just like a simple mesh extracted from the nav mesh and to be able to apply an material to it. Any ideas?
Answer by Buckslice · Dec 21, 2017 at 12:04 AM
I am guessing the navmesh doesn't generate or set up uvs correctly since they don't matter for navigation at all. Lucky for you I think Triplanar mapping would work great for your situation. Basically it just projects a texture onto your mesh from each cardinal direction without the need for uvs.
@Buckslice I know little about shaders, when I use this it works except, when I use a transparent image, it shows black where it should be transparent. I tried changing render type to transparent and that didn't help. Do you know what else to modify?
Haven't tested this but I think you can just add 'Blend SrcAlpha One$$anonymous$$inusSrcAlpha' below the 'Zwrite On' line. Also make sure your texture is imported with alpha is transparency option.
@Buckslice that was only part of it. I had to make x, y, and z a float4. I created a color variable for the tint with the value of 1,1,1,1 and in the surf function I added o.Alpha=z.a