Jump to content
  • Advertisement
Sign in to follow this  
sobeit

algorithm for generating line adherent to the surface of a mesh

This topic is 2115 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. 

 

Share this post


Link to post
Share on other sites
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.

Edited by Erik Rufelt

Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Edited by eppo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!