Hi,
I'm new to this, but wanted to get my feet wet. Decided to try to see how hard it would be to extend Box2d to see how hard it was to get some dry friction action going on. (enough so I can simulate car wheels at least)
First attempt was just adding some force or impulses every step in "user land" to counteract the force up to a friction value. This didn't work out when there was contact and bodies pushing on joints (body would move even if the force being applied was significantly less than the friction force).
Then tried it with a controller. Same issue, more or less (even though it had better abstractions than the previous approach)
Long story short, I came up with just making a special type of joint that took one body so it would "fight" with the other joints during the contraint processing.
The joint isn't really a joint, but merely a constraint with one body (I feel a joint would be a subclass of the type of contraint with one body, but there's currently nothing that needs it). It's passed a vector for x and y friction. Ideally a production version of this would allow the user to choose a different alignment of this friction (and probably a point instead of it just being applied to the center of mass)
The same technique could be used for angular joints. Also, I plan on experimenting with making a Drag type friction joint.
Here's a quick video of the demo
http://screenr.com/fBBCode
http://github.com/mikelikespie/box2d-demo/tree/carMake sure you're looking at the
car branch.
The car demo can be found in /Box2d/Examples/TestBed/Test/TopDownCar.h
The joint I created is b2FrictionJoint. (
http://github.com/mikelikespie/box2d-de ... nJoint.cpp)
Had to hack up the core processing a bit to allow for joints with only one body defined.
Also hacked up the test bed to make steering more natural and having multiple keys pressed.
Please excuse the code quality, it's not meant for production.
Would like feedback on this method, and whatnot. if people are interested (and this is a reasonable approach I wouldn't mind making it better and contribbing and whatnot).
-- update --
I pushed a new version to git with a friction joint that's significantly cleaned up, and has support for angle friction too. I also cleaned up the hack I did to the world and island and whatnot.
The attached patch should apply to trunk.
p.s.
sup with the inconsistent cr lfs?