I have been working on an independent project for school, and my Professor doesn't know much about physics engines and as such said that I should come and ask on the community forums. I am working on creating a series of gears that interlock, and eventually will power wheels, claws, or other simple items that can be created and linked in with toothed edges and such. However, I am having issues with making the one powered gear continuously rotate the other gear at a reasonably consistent rate. I have tried changing tooth sizes and such, but it does not seem to help much, it will still run into this issue. I am linking Ogre with bullet for this.
If you wish to see my entire project so far, I have uploaded it to http://www.megaupload.com/?d=LZCOWCA7.
Otherwise, what I believe to be relevant for physics the gears, I extracted and ordered in the following code block.
Code: Select all
// make the collision shape
btCompoundShape* gear = new btCompoundShape();
btCollisionShape* cylinder = new btCylinderShape(btVector3(radius, thickness, 0));
btTransform norm;
norm.setIdentity();
gear->addChildShape(norm, cylinder);
entityMotionState = new QuickLinkMotionState(entityX, entityY, entityZ, entityNode);
for(int i = 0; i < numExtrusions; i++)
{ // cubes for extrusions/teeth
// some bullet cubes so not doing extra loops
btCollisionShape* bulletCube = new btBoxShape(btVector3(scaler, thickness, scaler * .2) / 2);
btTransform cubeTransform;
cubeTransform.setIdentity();
cubeTransform.setOrigin(btVector3(radius * cos(i * ((Ogre::Math::PI * 2) / numExtrusions)), 0, radius * sin(i * ((Ogre::Math::PI * 2) / numExtrusions))));
btQuaternion bulletRotation(cos(i * ((Ogre::Math::PI * 2) / numExtrusions)), 0, sin(i * ((Ogre::Math::PI * 2) / numExtrusions)), 0);
cubeTransform.setRotation(bulletRotation);
gear->addChildShape(cubeTransform, bulletCube);
}
// finish physics
gear->calculateLocalInertia(entityMass, entityInertia);
btRigidBody::btRigidBodyConstructionInfo CI(entityMass, entityMotionState, gear, entityInertia);
entityRigidBody = new btRigidBody(CI);
if(entityKinematic)
{ // make kinimatic
entityRigidBody->setMassProps(0, btVector3(0,0,0));
entityRigidBody->setCollisionFlags(entityRigidBody->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
entityRigidBody->setActivationState(DISABLE_DEACTIVATION);
}
// add to world
dynamicsWorld->addRigidBody(entityRigidBody);
Code: Select all
btHingeConstraint* test = new btHingeConstraint(*gear->getEntityRigidBody(), btVector3(0, 0, 0), btVector3(0, 1, 0));//new btHingeConstraint(*gear2->getEntityRigidBody(),*gear->getEntityRigidBody(), localA, localB);
btHingeConstraint* test2 = new btHingeConstraint(*gear2->getEntityRigidBody(), btVector3(0, 0, 0), btVector3(0, 1, 0));
dynamicsWorld->addConstraint(test, true);
dynamicsWorld->addConstraint(test2, true);Code: Select all
gear2->getEntityRigidBody()->setAngularVelocity(btVector3(0, 4.0f, 0));
Code: Select all
btTransform btt;
btt.setIdentity();
btt.setOrigin(btVector3(entityX, entityY, entityZ));
entityY += .05;
entityMotionState->getWorldTransform(btt);
btQuaternion additionalRotation(entityRotationY, 0, 0);
entityRotationY += 0.01;
btt.setRotation(additionalRotation);
entityMotionState->setWorldTransform(btt);Thanks very much in advance, and please let me know if there is any information other than this needed.