Hi,
I'm new to Bullet and physics engine in general, so I hope you all can forgive a possibly naive question.
I want to be able to make objects grabable using the ray cast from an input device that has 6 DoF. Namely, if I point the device at the object and "grab" it, it is as if a solid bar is connected between the input device and the object. So, until its release, the object would follow all translations and rotations of the input device, as if one was holding the end of the bar and swinging it around.
Could / should this be done using the btGeneric6DofConstraint ?
Thanks for any help,
Braden
Constraining all 6 Degrees of Freedom
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Constraining all 6 Degrees of Freedom
Indeed, you can use the btGeneric6DofConstraint. In fact, by default all degrees of freedom are locked, so no need to configure the limits. Just choose an appropriate local coordinate frame for the attachment.daBrado wrote:Hi,
I'm new to Bullet and physics engine in general, so I hope you all can forgive a possibly naive question.
I want to be able to make objects grabable using the ray cast from an input device that has 6 DoF. Namely, if I point the device at the object and "grab" it, it is as if a solid bar is connected between the input device and the object. So, until its release, the object would follow all translations and rotations of the input device, as if one was holding the end of the bar and swinging it around.
Could / should this be done using the btGeneric6DofConstraint ?
Thanks for any help,
Braden
See the ColladaDemo for an example implementation:
Code: Select all
btGeneric6DofConstraint* genericConstraint = new btGeneric6DofConstraint(
*bodyRef,*bodyOther,
localAttachmentFrameRef,localAttachmentOther);
m_demoApp->getDynamicsWorld()->addConstraint( genericConstraint );
Please let me know if there are any issues.
Thanks,
Erwin
-
- Posts: 11
- Joined: Thu Oct 05, 2006 10:41 am
Re: Constraining all 6 Degrees of Freedom
So, using btGeneric6DofConstraint, would I create a dummy btRigidBody that represents the input device, and then change its m_worldTransform to track the input device's location and orientation?Erwin Coumans wrote:Indeed, you can use the btGeneric6DofConstraint. In fact, by default all degrees of freedom are locked, so no need to configure the limits. Just choose an appropriate local coordinate frame for the attachment.
Thanks,
Braden
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Constraining all 6 Degrees of Freedom
Yes, you create a fixed rigidbody, setup the constraint and move that fixed body.daBrado wrote:So, using btGeneric6DofConstraint, would I create a dummy btRigidBody that represents the input device, and then change its m_worldTransform to track the input device's location and orientation?Erwin Coumans wrote:Indeed, you can use the btGeneric6DofConstraint. In fact, by default all degrees of freedom are locked, so no need to configure the limits. Just choose an appropriate local coordinate frame for the attachment.
Thanks,
Braden
Note that Bullet is undergoing refactoring, and although the largest changes are over, the API and internals are still changing.
Creating a fixed rigidbody in Bullet 2.14 will look like:
Code: Select all
float mass = 0.f; //means fixed
btCollisionShape* collisionShape = 0;
btRigidBody fixed(mass, btTransform::getIdentity(),collisionShape);
Erwin