I'm wondering if someone has a code example of position based dynamics with i.e. a spring constraint? I found this paper describing the technique which has some pseudo code, but I would love to see some java/c/c++/as/... code
Asked
Active
Viewed 5,923 times
5
-
1"Spring constraint"? In the language of PBD a spring is not a constraint, it's part of f_ext. What have you tried coding so far? – Beta Apr 02 '11 at 04:37
-
@Beta That's not entirely the case. In the PBD model, ad hoc spring-like behavior is achieved by replacing the usual spring force with a spring or stretching "constraint", although that constraint may be only partially/fractionally enforced to approximate stretchy spring-like behaviour. For example, Muller's original paper models cloth using such constraints between vertices of the cloth (Fig 3.) The strength of the spring is handled using an iteration-dependent pseudo-stiffness parameter k that dials back the constraint projection (see the end of Section 3.3). – batty Nov 21 '13 at 20:46
-
You should at least read the paper and try to understand the math and try some code, it is the only way you will learn the most. – BRabbit27 Jun 11 '14 at 09:14
3 Answers
4
The soft body (and cloth/rope) simulation in the open source Bullet physics library is using position based dynamics, as described by Thomas Jakobsen ( http://www.gamasutra.com/resource_guide/20030121/jacobson_01.shtml) and your paper link by Matthias Mueller.
See http://bullet.googlecode.com for the C++ source code.

Erwin Coumans
- 1,766
- 14
- 22
-
Actually, it may happen that Jakobsen's Hitman 1 engine is not the first to use that idea. It may have been actually _used_ by Xavier Provost in 1995, when he developed a cloth simulator. – teodron Mar 28 '13 at 09:45
0
Processing has various physics and particle system libraries, and they use Java.
Edit: I guess I misunderstood the question earlier, but here is someone's attempt to code Muller's approach.

highBandWidth
- 16,751
- 20
- 84
- 131