algorithm for generating line adherent to the surface of a mesh

Started by
3 comments, last by eppo 10 years, 6 months ago

Hi, I'm trying to create a dynamic vine growing effect for my game. I wonder if there is any efficient algorithm that can procedurally generate line(vine) that is clingy to the given mesh without penetration.

Advertisement

If you have a mesh in a format that contains adjacency information then it should be relatively straight forward, at least for a simple line. If you start at one triangle on the mesh and a direction for the line, then project the direction on the triangle's plane and calculate the intersection of the line with the triangle's edge. Then use the adjacency information about the next triangle that is connected to the same edge to continue on the next triangle and do the same there, creating one segment on the line on each triangle encountered. Obviously it gets more and more expensive with a more complex vine-mesh.


If you have a mesh in a format that contains adjacency information

any idea about mesh without adjacency information? Because I'm using Unity3d, I think it can't parse this kind of mesh format.

You probably have to build the information during loading.. preprocess the model and go through every triangle and check against every other triangle in the mesh to find one that shares two vertices, and that's an edge between them.

I would probably try to do it by doing collision detection against the mesh instead.. like shoot rays at it and determine where the vine should go.. but of course that doesn't really solve the penetration issue, though with many rays it's probably not noticeable unless you need it to be exact.

Unity should have some API that lets you access a mesh's underlying structure.

Start out by picking a point on a triangle and a random point on one of the triangle's three edges. You then move/grow towards that point. One you reach it, you jump to that edge's connecting triangle, again pick a random point on one of the triangle's other two edges and continue growing.

This topic is closed to new replies.

Advertisement