Voxelize : RecastGenerator mesh areas informations


I am working on a project and we aquired A* pro a few days ago. As we wanted to speed up the process of our level designer, we though of a way to create grid-graphs all over the world using something similar to RecastGenerator.

At first we wanted to use the RecastGraph but this one isn’t good if there are a lot of interactions with objects (they move and it doesn’t update the navmesh).

Our idea is to use the informations of the areas(by areas, I mean all connected vertices of the same color) generated from the RecastGenerator, to create grid-graphs. The ideal would be that each “area” create a grid-graph with the according size and position on the world.

After this process, the RecastGraph will be removed and our level designer will be able to tweak all grid-graphs created, link them etc…

Thank you in advance for your help.

Um… I don’t quite follow… Could you elaborate? Perhaps an example case?

Here is a screenshot showing what I am looking for:

I just need to get the informations (vertices etc…) from these “area” but I have no idea where they are stored.

Hope you will understand better.

What Raph is asking is this: one of the scripts you are using finds the areas to color them with lines and generate nav meshes on them. Obviously, there’s a variable somewhere that stores information about the areas in question. The question is, where exactly that variable is, because we have not been able to locate it.

The reason why we need that information about those areas is that we want to put grid graphs in those areas, but have no idea how to detect them, so we figured that if you already detect them anyway, why not just take that information and use it for our purpose.

Thank you.


Sorry for the late answer.

That information is stored in the ‘area’ variable on each node.

The code below will take the first area it sees, and then construct a bounds object which encapsulates all vertices for nodes with the same area id. I assume it would be something like this you would want to do.
The code has not been tested, I hope I have not made any mistakes in the code.

Also, for this you might want to set A* Inspector -> Settings -> Min Area Size to 0 (zero) since otherwise multiple areas might get the same area id.
//First graph, assuming it is a recast graph RecastGraph graph = AstarPath.active.astardata.graphs[0] as RecastGraph; Node[] nodes = graph.nodes; Bounds b = new Bounds (Vector3.zero, Vector3.zero); int firstArea = -1; //Vertices in the graph Vector3[] verts = graph.vectorVertices; for (int i=0;i<nodes.Length;i++) { MeshNode node = nodes[i] as MeshNode; if (firstArea == -1) { b = new Bounds (verts[node.v1], Vector3.zero); firstArea = node.area; } if (firstArea == node.area) { //The vertices of the node is here b.Encapsulate (verts[node.v1]); b.Encapsulate (verts[node.v2]); b.Encapsulate (verts[node.v3]); } } Debug.Log (b);