use btGeneric6DofConstraint to restrict rotation around Y

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
leeco
Posts: 2
Joined: Wed Mar 09, 2011 3:19 pm

use btGeneric6DofConstraint to restrict rotation around Y

Post by leeco »

Hello everyone. I created three btGeneric6DofConstraint to restrict three Rigidbody rotation, code as below

{ //Allowed rotation around the x-axis only
trans.setOrigin(btVector3(-10,0,0));
d6body0 = localCreateRigidBody( mass,trans,shape);
d6body0->setActivationState(DISABLE_DEACTIVATION);

spSlider6Dof = new btGeneric6DofConstraint(*d6body0,btTransform::getIdentity(),true);
spSlider6Dof->setAngularLowerLimit(btVector3(1.0, 0, 0));
spSlider6Dof->setAngularUpperLimit(btVector3(-1.0,0, 0));

m_dynamicsWorld->addConstraint(spSlider6Dof);
spSlider6Dof->setDbgDrawSize(btScalar(5.f));
}
{ //Allowed rotation around the y-axis only
trans.setOrigin(btVector3(0,0,0));
d6body0 = localCreateRigidBody( mass,trans,shape);
d6body0->setActivationState(DISABLE_DEACTIVATION);

spSlider6Dof = new btGeneric6DofConstraint(*d6body0,btTransform::getIdentity(),true);
spSlider6Dof->setAngularLowerLimit(btVector3(0,1.0,0));
spSlider6Dof->setAngularUpperLimit(btVector3(0,-1.0,0));

m_dynamicsWorld->addConstraint(spSlider6Dof);
spSlider6Dof->setDbgDrawSize(btScalar(5.f));
}
{ //Allowed rotation around the z-axis only
trans.setOrigin(btVector3(10,0,0));
d6body0 = localCreateRigidBody( mass,trans,shape);
d6body0->setActivationState(DISABLE_DEACTIVATION);

spSlider6Dof = new btGeneric6DofConstraint(*d6body0,btTransform::getIdentity(),true);
spSlider6Dof->setAngularLowerLimit(btVector3(0, 0, 1.0));
spSlider6Dof->setAngularUpperLimit(btVector3(0, 0,-1.0));

m_dynamicsWorld->addConstraint(spSlider6Dof);
spSlider6Dof->setDbgDrawSize(btScalar(5.f));
}

But you can see the second constraint is weird. Why?

You can use the file in attachment instead of the same file in AppConstraintDemo to see it.
ConstraintDemo.rar
(2.92 KiB) Downloaded 604 times
I want to create a car which can not turn over, How can I implement it?
arcwf
Posts: 7
Joined: Fri Mar 20, 2009 3:26 am

Re: use btGeneric6DofConstraint to restrict rotation around

Post by arcwf »

Check out this thread: http://bulletphysics.org/Bullet/phpBB3/ ... 494#p19494
--Christopher
leeco
Posts: 2
Joined: Wed Mar 09, 2011 3:19 pm

Re: use btGeneric6DofConstraint to restrict rotation around

Post by leeco »

arcwf wrote:Check out this thread: http://bulletphysics.org/Bullet/phpBB3/ ... 494#p19494
--Christopher
It's very useful. Thank you.
Post Reply