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.
I want to create a car which can not turn over, How can I implement it?
use btGeneric6DofConstraint to restrict rotation around Y
-
- Posts: 2
- Joined: Wed Mar 09, 2011 3:19 pm
use btGeneric6DofConstraint to restrict rotation around Y
You do not have the required permissions to view the files attached to this post.
-
- Posts: 7
- Joined: Fri Mar 20, 2009 3:26 am
Re: use btGeneric6DofConstraint to restrict rotation around
Check out this thread: http://bulletphysics.org/Bullet/phpBB3/ ... 494#p19494
--Christopher
--Christopher
-
- Posts: 2
- Joined: Wed Mar 09, 2011 3:19 pm
Re: use btGeneric6DofConstraint to restrict rotation around
It's very useful. Thank you.arcwf wrote:Check out this thread: http://bulletphysics.org/Bullet/phpBB3/ ... 494#p19494
--Christopher