Direct manipulation of Rigid Bodies

conormcc
Posts: 6
Joined: Thu Apr 09, 2009 9:25 am

Direct manipulation of Rigid Bodies

Post by conormcc »

Hi All,

I have an iPhone app consisting of set of dice (box shaped rigid bodies) in a box. I use Bullet to shake the dice and let them roll around the screen. However, the user needs to be able to rearrange/rotate the dice around in the box using touch.

I tried using applyCentralForce(moveDirection) but the dice would drag around behind the user's finger (like it was on a string) and would slide past after the touch had stopped. It needs to be a lot more accurate. Instead i have tried using setWorldTransform(touchPosition) followed step which almost works but when I push the dice against another dice that cannot move (either pressed against wall or another immovable dice) they slightly merge and the one i am moving kicks back in the opposite direction. Is there a way for me to suppress the collision reaction so that they don't merge but don't kick? I also tried setting its mass to 0 but then it just went through the other dice.

The only other thing I can think of is turning off bullet after the shake and then implementing my own crude collision detection but I really don't want to do that!

I'd really appreciate some help on this as its my first bullet project. Also, congrats to everyone who has worked on Bullet, its an excellent project and I realise that its probably a bad idea to directly manipulate the dice in the way I am trying to!

Many thanks,
Conor
User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

Re: Direct manipulation of Rigid Bodies

Post by ejtttje »

I think you need to keep Bullet in the loop if you want the objects to interact in a physical way. Think about it in terms of what happens in the "real world" when you grab an object and move it around: you apply more or less force depending how quickly you try to move and the weight of the object, and you have an opposable thumb on the other side to stop the object again.

So I think if you write a controller which applies force proportional to its distance from the target position with some dampening/friction (aka PD control), you can tune the parameters so it tracks the target, but with realistic interaction with the other dice.
User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

Re: Direct manipulation of Rigid Bodies

Post by ejtttje »

See also my other recent threads:
http://bulletphysics.com/Bullet/phpBB3/ ... f=9&t=3315
http://bulletphysics.com/Bullet/phpBB3/ ... f=9&t=3895
where I'm also waiting for implementation tips on a similar problems (how best to apply forces in the world)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Direct manipulation of Rigid Bodies

Post by Erwin Coumans »

For picking, you can try using a constraint. In Bullet/Demos/OpenGL/DemoApplication.cpp check out:

Code: Select all

void DemoApplication::mouseFunc(int button, int state, int x, int y)
Alternatively, you can using motors or velocity based instead of force/position.

Hope this helps,
Erwin