Position based dynamics (Physics)

BlitzMax Forums/BlitzMax Programming/Position based dynamics (Physics)

Warpy(Posted 2007) [#1]
I found a nice paper a few days ago called Position Based Dynamics, by a chap called muller and some other dudes. It explains rather clearly how to implement a dynamics system that can handle pretty much whatever sort of rules you want to put in it.

This is great, because physics is something that everyone seems to have trouble with beyond simply moving particles about, without resorting to those wrappers for things like newton or ODE. I certainly do, so this is going to stick around for a good while in my how-to-do-stuff folder.

So, I had a go at writing this system in BMax, and here it is. I hope someone finds it useful!


Damien Sturdy(Posted 2007) [#2]
Verlet, then :) Neat!


Beaker(Posted 2007) [#3]
Wierd to think I was messing about with this stuff in BlitzBasic 2D ('cloth 2d' before Blitz3D came out) all those years ago. And then again in Blitz3D ('boxing game' - inflated character mesh), before all the physics wrappers popped up. I'm sure you probably played with some of my physics stuff as well, I spammed IRC with it for quite a while. :)


Warpy(Posted 2007) [#4]
I'm not sure it's exactly like the normal verlet method everyone's using. The paper seemed to reckon they were doing something New And Exciting.


ImaginaryHuman(Posted 2007) [#5]
Nice. This sounds like it's what I need for doing some 2d physics. Does the contraints system support springs, and if so what types? If I have one vertex which separately connects to two other vertices via a fixed-distance constraint (or a fairly resistant linear spring), can I also restrain the angle between those two constraints, to keep them trying to rest at 90 degrees to each other, forming a right-angle? If it has these two kinds of springs that would be great.


Eric(Posted 2007) [#6]
I toyed around with something similar a while back.

http://www.blitzbasic.com/Community/posts.php?topic=48107#535088

Regards,
Eric


ImaginaryHuman(Posted 2007) [#7]
I read most of the article and played with your demo. I see you implemented a distance constraint. Are you going to be adding any others such as a linear spring and a bending spring? The math is difficult to follow so if these two were implemented it would be great. Also, is there any collision detection going on in your code? I know the article mentions it but I'm not sure how much of it you have implemented.


Warpy(Posted 2007) [#8]
Go on then, I'll have a go.


ImaginaryHuman(Posted 2009) [#9]
Hey Mr Warpy, did you ever have a go at this? ... implementing springs with this technique?


Warpy(Posted 2009) [#10]
Nope!


SoggyP(Posted 2009) [#11]
Hello.

C'mon Warpy, don't prevaricate - answer the man without wrapping it in hyperbole, nuance and subtleties ;o)

Goodbye.


ImaginaryHuman(Posted 2009) [#12]
It seemed like it was somehow promising to be more efficient than typical physics calculations due and offering better flexibility of changing point coordinates manually, just wondered if you had got the springs working with it cus that would be pretty handy. But oh well. You're one of few people around here that actually understands all that math ;-D


Warpy(Posted 2009) [#13]
Hah, so it turns out I didn't consider my answer deeply enough!

You can create an effective spring out of the normal distance constraint by setting the stiffness parameter to something less than 1. I've modified the code so it actually multiplies constraint projections by the stiffness parameter - I must have lost interest in this so quickly I never put that in!

Download the file again to see it look. The bouncy triangle is cute!


Nate the Great(Posted 2009) [#14]
so is anyone ever going to figure out how to do poly to poly collisions? I still cant get them to work for my physics engine. For now I am just staying with circle-circle collisions but that becomes annoying after a while.