🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Points constraint approach

Started by
2 comments, last by Irlan Robson 5 years, 2 months ago

Hello, I'd like some suggestions and pointers about what approach I could take for this specific matter. I basically have a line made of n points (well, a hair): when I move one or more points, I need the other points to be constrained so that the hair length remains the same. I'm currently using verlet integration which works just fine: the only issue is that requires a 2nd step, so first, the points are moved to "unconstrained" positions; after that, the verlet integrations moves them back to the correct positions so that are constrained (and hair length remains the same).

So I was wondering, there is an approach that would require 1 single step? Perhaps I could achieve the same behavior with Euler or quaternions?

Thanks for any suggestion!

Advertisement

Integration might not be an important topic compared to which kind of solver you use. I like Thomas Jakobsen style for cloth and have implemented this for a game before successfully. I also used it for touch-bend vegetation. Vegetation would be a lot like a hair.

I found success with a kind of shape-matching where the initial input mesh defines the target position for each particle, and each bone maps one-to-one with one particle. This way graphical meshes can be converted to the cloth run-time format without requiring additional authoring from an artist.

The way the shape matching works is I would define a frame of reference for each particle by considering the next particle's position. As the particles move about, I used a function to calculate the shortest arc quaternion between the original target positions and moved positions. There was one part where the quaternion would flip around under large rotations, and I believe I solved it with an if-statement and negated the quaternion at a certain point.

After finding target positions for each particle, which are defined relative to parent particles (to help preserve the original shape), I would attach weak springs from each particle to each target position. The strength of the spring was tapered from root to end, and tuneable by an artist. The only difference between the constraints between particles and the constraints between a particle and a target position, was I assumed target positions were particles with infinite mass.

With this strategy I found bend constraints to be a nuisance, and simply removed them.

http://www.cs.cmu.edu/afs/cs/academic/class/15462-s13/www/lec_slides/Jakobsen.pdf

Here is a summary of three approaches that can be used for hair/rope simulation:

- Mass-spring System: Here particles are connected via linear springs. Equation of motion can be solved using an implicit integrator to support large time steps and avoid instability. This is typically used for cloth simulation in movies and some games (LucasArts, Blender, Pixar).

- Position Based Dynamics: Kind of what you're using and commonly used in games. Fast but as an iterative solver, constraints can break.

- Featherstone: Fast and supports any time step. Large velocities may lead to instability and blow up the simulation. Can be used for simulating inextensible hair.  

Featherstone is a single step approach. It works in reduced coordinates. Constraints are always satisfied. However, large time steps might lead to instabilities, but we can add damping to improve stability.

This topic is closed to new replies.

Advertisement