Jump to content
  • Advertisement

Points constraint approach

Recommended Posts

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!

Share this post

Link to post
Share on other sites
Posted (edited)

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.


Edited by Randy Gaul

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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!