Is there a way to utilize the motor functionality of the constraints with a single body? I've tried adding a generic 6DOF constraint to a body with no partner (thus constraining it to "the world") but this results in some undesired issues with the constraint's frame of reference (which doesn't track with the object(?)).
So is there a way to get a constraint on a single object to track its frame of reference with that object? I realize we could implement motor-like behavior by just applying forces, but frankly in our experience the constraint motors generally work better, and it seems like a wheel-reinvention of sorts.
Using a constraint motor on a single body
-
- Posts: 35
- Joined: Wed Jun 25, 2008 2:52 pm
-
- Posts: 35
- Joined: Wed Jun 25, 2008 2:52 pm
Re: Using a constraint motor on a single body
Bump. Anybody? Bueller?
-
- Posts: 56
- Joined: Sat Mar 08, 2008 12:37 am
Re: Using a constraint motor on a single body
Hello,
Actually all Bullet constraints always have 2 frames.
In the case when constraint is attached to the world, the second frame is in the world coordinate system.
Try the following code - it is a slider-like Generic6Dof constraint with linear motor.
You can see that one frame is attached to the world and second is located in the center of mass of the rigid body
Hope this will help,
Roman Ponomarev
Actually all Bullet constraints always have 2 frames.
In the case when constraint is attached to the world, the second frame is in the world coordinate system.
Try the following code - it is a slider-like Generic6Dof constraint with linear motor.
You can see that one frame is attached to the world and second is located in the center of mass of the rigid body
Code: Select all
{ // 6DOF connected to the world, with motor
btTransform tr;
tr.setIdentity();
tr.setOrigin(btVector3(btScalar(10.), btScalar(0.), btScalar(0.)));
btRigidBody* pBody = localCreateRigidBody( 1.0, tr, shape);
pBody->setActivationState(DISABLE_DEACTIVATION);
btTransform frameB;
frameB.setIdentity();
btGeneric6DofConstraint* pGen6Dof = new btGeneric6DofConstraint( *pBody, frameB, false );
m_dynamicsWorld->addConstraint(pGen6Dof);
pGen6Dof->setDbgDrawSize(btScalar(5.f));
pGen6Dof->setAngularLowerLimit(btVector3(0,0,0));
pGen6Dof->setAngularUpperLimit(btVector3(0,0,0));
pGen6Dof->setLinearLowerLimit(btVector3(-10., 0, 0));
pGen6Dof->setLinearUpperLimit(btVector3(10., 0, 0));
pGen6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
pGen6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
}
Roman Ponomarev
-
- Posts: 35
- Joined: Wed Jun 25, 2008 2:52 pm
Re: Using a constraint motor on a single body
Hi Roman. Thanks for the response. I did realize that in the absence of a second body, the constraint would use the world as the second frame of reference. I was confused about how the axes of rotation for the constraint would be affected if the body translated away from its original position - however it may be that I was mistaking some of the y-axis gimble lock issues w/ the 6DOF constraint for something else.
For now, I think I've got what I need. If my issue crops up again I'll see if I can come up with a better explanation. Thanks!
For now, I think I've got what I need. If my issue crops up again I'll see if I can come up with a better explanation. Thanks!