Walking the edges of a spherical mesh

Mark Norman's icon

I am trying to figure out a way to "walk the edges" of a spherical mesh. For example, suppose I set the color of one vertex on the mesh to bright red. I want to then (1) choose at random one of the connected vertices, (2) set the connecting edge to red, and (3) set the connected vertex to a darker shade of red. As I continue on, vertices and edges left behind will fade over time. The end result will be a flash of red that randomly moves along a path through the sphere until it fades away.

I've examined the jitter objects, such as mesh, but can't find a way to choose a starting vertex and then work my way along connecting edges. If I were to code this, I'd use a graph data structure, define the vertices and edges, then go to town.

Any suggestions? Pure jitter, javascript, lua, a Java external? I'm not looking for anyone to spell out a solution for me, just a pointer in the right direction. Thanks.

Pedro Santos's icon

The cell order of the vertex matrix going to jit.gl.mesh corresponds to the order of the vertices. This tutorial by Andrew Benson is very helpful to understand jit.gl.mesh.

Mark Norman's icon

Knowing cell order doesn't solve my problem because the order of vertices does not indicate which vertices are connected. We can see this in the tutorial that you reference. In the diagram of OpenGL drawing primitives, the GL_TRIANGLE_STRIP primitive connects v1 and v3 even though these vertices are not adjacent in the input matrix.

In fact, the diagram in that tutorial may help me clarify what I am after. Using GL_TRIANGLE_STRIP as a reference, we see that v3 is connected to v1, v2, v4, and v5. If my algorithm starts at v3, I want to be able to randomly choose v1, v2, v4, or v5. The cell order of vertices doesn't help me make that choice.

No matter which primitive is used, and no matter how I order the vertices, I run into this problem.

Pedro Santos's icon

Knowing cell order doesn't solve my problem because the order of vertices does not indicate which vertices are connected.

Yes, it does, in combination with the drawing method.
GL_TRIANGLE_STRIP: after the first triangle, the following triangle is built by defining a new point and reusing the 2 previous ones. It's a method of eliminating some redundacy. If you want complete control of the vertex positions and order, just use the GL_TRIANGLES drawing method, but, in that case to do the same example that's in GL_TRIANGLE_STRIP, you could have a matrix with the following information:
v0 v1 v2 v1 v2 v3 v2 v3 v4 v3 v4 v5
(v0 v1 v2) (v1 v2 v3) (v2 v3 v4) (v3 v4 v5)
triangle1 triangle2 triangle3 triangle4
The matrix would be a "jit.matrix 3 float32 12 1"

balam's icon

perhaps this
https://www.youtube.com/watch?v=5mLAxACSPLU&t=0s&list=PLRc5WfOZXC4mLRs9dBueSTkhsFKJ7szGq&index=2

Mark Norman's icon

That's an insightful video. It gave me some new ideas!

I think I see a way to navigate through the matrix of vertices to get what I want.

I appreciate the help Pedro and Balam.