How to implement grabbing of objects?
Posted: Wed Feb 01, 2012 8:30 am
Hi all,
I'm currently using Bullet (in combination with my 3D engine Crystal Space) and I would like to have realistic grabbing of objects. I don't know if any of you are aware of the games Penumbra or Amnesia: The Dark Descent? In that game you have a first person camera and you can grab objects by clicking on them. This is done in a realistic way. For example, to open a door you simply grab the door and then move backwards or forwards. The door will open or close depending on the speed with which you move your mouse. Same for drawers. You can pull out a drawer just the way that you would expect. You can start pulling and stop halfway and then continue or go back. And so on. Same for levers, turning wheels and so on. It all feels very realistic and very nice to use.
So I'm trying to achieve the same. I got a very similar result by creating a pivot joint using btPoint2PointConstraint and dynamicWorld->addConstraint(). This works great.
However there is a small problem in combination with btGeneric6DofConstraint. When the player grabs an object that is connected to such a 6DOF constraint then I guess bullet doesn't know which constraint to fully honor. The problem is that the 6DOF constraint is slightly violated (and so is the pivot joint) because the player is dragging a bit too far. So if you have such a constraint to simulate a door then the player can slightly rotate the door in wrong directions. I guess the problem is that bullet doesn't know which of the two constraints (6dof and pivot) to honor completely so it probably decides to honor both a bit.
I would like the 6DOF constraints to be strict. The player should not be able to pull the door out of its hinges. How can I achieve that? Is there a way I can create a more loosely coupled pivot joint?
In addition, a related problem (I think) is how to make grabbing weight dependend. A heavier object should be harder to grab and if it is very heavy then the player should only be able to drag it on the floor but not lift it in the air. With the pivot joint there is no such restriction. The player can lift anything.
Any advice here?
Thanks!
I'm currently using Bullet (in combination with my 3D engine Crystal Space) and I would like to have realistic grabbing of objects. I don't know if any of you are aware of the games Penumbra or Amnesia: The Dark Descent? In that game you have a first person camera and you can grab objects by clicking on them. This is done in a realistic way. For example, to open a door you simply grab the door and then move backwards or forwards. The door will open or close depending on the speed with which you move your mouse. Same for drawers. You can pull out a drawer just the way that you would expect. You can start pulling and stop halfway and then continue or go back. And so on. Same for levers, turning wheels and so on. It all feels very realistic and very nice to use.
So I'm trying to achieve the same. I got a very similar result by creating a pivot joint using btPoint2PointConstraint and dynamicWorld->addConstraint(). This works great.
However there is a small problem in combination with btGeneric6DofConstraint. When the player grabs an object that is connected to such a 6DOF constraint then I guess bullet doesn't know which constraint to fully honor. The problem is that the 6DOF constraint is slightly violated (and so is the pivot joint) because the player is dragging a bit too far. So if you have such a constraint to simulate a door then the player can slightly rotate the door in wrong directions. I guess the problem is that bullet doesn't know which of the two constraints (6dof and pivot) to honor completely so it probably decides to honor both a bit.
I would like the 6DOF constraints to be strict. The player should not be able to pull the door out of its hinges. How can I achieve that? Is there a way I can create a more loosely coupled pivot joint?
In addition, a related problem (I think) is how to make grabbing weight dependend. A heavier object should be harder to grab and if it is very heavy then the player should only be able to drag it on the floor but not lift it in the air. With the pivot joint there is no such restriction. The player can lift anything.
Any advice here?
Thanks!