- Home /
Change a plane's vertices positions in runtime using a 2D array
Currently I'm generating a simple rectangular plane mesh comprised of many triangles making up "tiles" to serve as the floor of my map. I also have a system to read .txt files and organize the data into a 2d array to be used as tile data. An example of the text file:
1 1 1 1
1 0 0 1
1 0 0 1
1 1 1 1
where 1 = wall, and 0 = floor.
With my text file reader, the tile data then becomes organized into a corresponding 2d array, such that, in this example:
array[0,0] = 1
array[0,1] = 1
array[1,1] = 0
...
With this tile data, I want to edit the vertices of the mesh based on how it reads the tile data in the 2d array. My biggest issue right now is figuring out how to find which vertices belong to which tile, and how to access that tile based on the position of its tile data in the 2d array (ie., (0,0) = tile 1, (0,2) = tile 2).
The way my mesh generation works right now is that it first stores the tile data from the text file, then generates a plane of triangles, so I wanted to potentially loop back through the vertices of the mesh, change their height based on the tile data, and then reapply the mesh.
Hopefully at least some of this made sense. Thanks for any insight you might have!