originalmoose
04-05-2011 16:43:31
I have been fiddling with ogre bullet for the past couple of weeks. I was able to get the tutorial 2 finished and working. I have extended that project to include some boxes to knock over ect. What I would like to do now is try and figure out how to add a hinge constraint or some other constraint to make a see-saw but I am kinda lost at the moment. I looked into the HingeConstraint(rigidbody1, pivot1, axis1) and the corresponding function that needs 2 rigid bodies. No matter what I input for the pivot or axis I cannot get it to work. I realize I am obviously doing something wrong.
Any help would be greatly appreciated
Ogre::Real rX = 0.0, rY=0.0, rZ = 1.0, rW = 0.0;
Ogre::Vector3 position = Ogre::Vector3(-10, 100, -20);
Ogre::Quaternion rotation = Ogre::Quaternion(0.0,0.0,0.0,1.0);
Ogre::Entity *hingeBox1 = mSceneMgr->createEntity("hinge_cube1","cube.mesh");
hingeBox1->setCastShadows(true);
Ogre::AxisAlignedBox boundingB = hingeBox1->getBoundingBox();
size = boundingB.getSize(); size /= 2.0f; // only the half needed
size *= 0.95f; // Bullet margin is a bit bigger so we need a smaller size
hingeBox1->setMaterialName("BoxTextures/wood");
Ogre::SceneNode* hingeBoxNode1 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "hingeBoxNode1", position );
hingeBoxNode1->attachObject(hingeBox1);
hingeBoxNode1->scale(0.1f, 0.25f, 0.02f);
size *= Ogre::Vector3(0.1f, 0.25f, 0.02f);
OgreBulletCollisions::BoxCollisionShape *sceneBoxShape1 = new OgreBulletCollisions::BoxCollisionShape(size);
OgreBulletDynamics::RigidBody *defaultBody1 = new OgreBulletDynamics::RigidBody("hingeRigidBody" + Ogre::StringConverter::toString(1), mWorld);
defaultBody1->setShape( hingeBoxNode1,
sceneBoxShape1,
0.6f, // dynamic body restitution
0.6f, // dynamic body friction
1.0f, // dynamic bodymass
position, // starting position of the box
rotation);// orientation of the box
Ogre::Vector3 pivot1(0.0,100,0.0);
Ogre::Vector3 axis1(0.0,0.0,1.0);
OgreBulletDynamics::HingeConstraint(defaultBody1, pivot1, axis1);
Any help would be greatly appreciated