constraints setLimit problem
Posted: Wed Jun 01, 2011 3:29 am
Hello,
I'm trying to make the Bullet physics run on flash player. if you installed the new flash player11(http://labs.adobe.com/downloads/flashpl ... bator.html), you can look this demo: http://www.muzerly.com/showcase/flash/B ... yTest.html, the dynamics and collision is works fine.
But I had some trouble in creating hinge and generic 6Dof constraints. When I create a hinge constraint, it works fine if there is no limit, but once I set the limit, the hinge start auto rotate and shake.
look this two test: (click the mouse left button shoot ball)
http://www.muzerly.com/test/HingeConstraintTest1.html
http://www.muzerly.com/test/HingeConstraintTest2.html
the first test there is no limit, works fine. the second test has set limit.
here is the code I create the hinge:
I think maybe I have made some mistake on understanding operating mechanism. but I'm not find out what cause this.
So I post here hope anyone have experience on this. Any suggestion will be appreciate!
I'm trying to make the Bullet physics run on flash player. if you installed the new flash player11(http://labs.adobe.com/downloads/flashpl ... bator.html), you can look this demo: http://www.muzerly.com/showcase/flash/B ... yTest.html, the dynamics and collision is works fine.
But I had some trouble in creating hinge and generic 6Dof constraints. When I create a hinge constraint, it works fine if there is no limit, but once I set the limit, the hinge start auto rotate and shake.
look this two test: (click the mouse left button shoot ball)
http://www.muzerly.com/test/HingeConstraintTest1.html
http://www.muzerly.com/test/HingeConstraintTest2.html
the first test there is no limit, works fine. the second test has set limit.
here is the code I create the hinge:
Code: Select all
btDefaultCollisionConfiguration* collisionConfiguration = new btDefaultCollisionConfiguration();
btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfiguration);
btBroadphaseInterface* overlappingPairCache = new btDbvtBroadphase();
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();
btDiscreteDynamicsWorld* dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver,collisionConfiguration);
btCollisionShape* shape = new btBoxShape(btVector3(5.0f,10.0f,1.0f));
double mass=1;
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);
if (isDynamic)
shape->calculateLocalInertia(mass,localInertia);
btDefaultMotionState* myMotionState = new btDefaultMotionState();
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,shape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);
dynamicsWorld->addRigidBody(body);
btVector3 pivot(0,0,0);
btVector3 axis(0,1,0);
btHingeConstraint* hinge = new btHingeConstraint(*body, pivot, axis);
hinge->setLimit( -SIMD_PI * 0.25f, SIMD_PI * 0.25f );//there is problem if add this line
dynamicsWorld->addConstraint(hinge);
So I post here hope anyone have experience on this. Any suggestion will be appreciate!