What is the best way to implement controllable sub-shapes for some user controlled object. For example, imagine a tank with a turret that points towards the users mouse cursor. As far as I see it, there are two options here:
1. Have a btCompoundShape with sub-childs for the tank body and tank turret, and then update the turret transform every frame.
or
2. Have the tank body and turret as two separate btRigidBodys and connect them using some sort of constraint (which would be the best to use here, if any?)
Thanks in advance.
Controllable child shapes
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Controllable child shapes
Both methods would work, and you might want to try what works best for you.
Method 2 is a bit more realistic. it depends what kind of motion you need for the turret. For the most simple motion, only rotation along 1 axis, the btHingeConstraint can be used. But if you want full 360 rotation around the up axis, but also a bit of rotation to move the turret up and down you could use a btGeneric6DofConstraint. Due to some restrictions of the btGeneric6DofConstraint you might need to do some work on chosing the constraint frames properly (in such a way that the Y axis can't rotate the full 360 degrees). Motors on the constraint might help to move the turret. See also the Bullet/Demos/ConstraintDemo.
Thanks,
Erwin
Method 2 is a bit more realistic. it depends what kind of motion you need for the turret. For the most simple motion, only rotation along 1 axis, the btHingeConstraint can be used. But if you want full 360 rotation around the up axis, but also a bit of rotation to move the turret up and down you could use a btGeneric6DofConstraint. Due to some restrictions of the btGeneric6DofConstraint you might need to do some work on chosing the constraint frames properly (in such a way that the Y axis can't rotate the full 360 degrees). Motors on the constraint might help to move the turret. See also the Bullet/Demos/ConstraintDemo.
Thanks,
Erwin
-
Poita_
- Posts: 9
- Joined: Sun Oct 04, 2009 10:00 am
Re: Controllable child shapes
Ok thanks. I guess I'll try the constraints first as that seems to be the most logical to me.