Creating a Grid / 2D Mesh.
in
Programming Questions
•
3 years ago
Hi all,
what I first believed to be a more or less easy task turned out to tie knots in my brain.
Basically, I want to create an orthogonal grid, where it's possible to manipulate the position of every single vertice in a 2D space. So when one vertice is moved, all the lines connecting that vertice to it's neighbours move accordingly.
I believe such a thing is called a mesh?
I know that there is a mesh–library out there somewhere, but I'd like to try and build the mesh from ground up.
I know how to generate the original positions of the vertices on a grid.
But I have no clue as how to best tell every vertice who his neighbours are and to remain connected to them all the time. Because not all vertices have the same amount of connections:
- in the corners they have two
- on the edges they have three
- everywhere else they have four
And how do I prevent two vertices to connect themselves twice? (Once in ever direction)
Finally, the whole construct should not be to intense to compute, since I'd want it to be dynamic.
Is such a task feasible for a beginner/intermediate user?
Or are we talking about a rather complex problem here?
If anyone has some pointers as to how I should approach this task I'd be really thankful.
Thanks!
cheers,
Greg