btHingeConstraint - Object Floating?

tisdadd
Posts: 4
Joined: Tue Mar 29, 2011 2:48 am

btHingeConstraint - Object Floating?

Post by tisdadd »

Hello,

I am trying to figure out why my objects are floating apart from each other instead of next to each other.

Code: Select all

		////btHingeConstraint* testConstraint = new btHingeConstraint(*squareTest->getEntityRigidBody(), *gear2->getEntityRigidBody(), btVector3(0, 0, 0), btVector3(0, Ogre::Math::PI * 2, 0), btVector3(0, 0, 0), btVector3(0, 1, 0), true);
		btTransform localA, localB;
		localA.setIdentity();
		localB.setIdentity();
		localA.getBasis().setEulerZYX(0, 0, 0);
		localA.setOrigin(btVector3(0.0, 0, 0));
		localB.getBasis().setEulerZYX(0, 0, 0);
		localB.setOrigin(btVector3(0.0, 0, 0));
		btHingeConstraint* testConstraint = new btHingeConstraint(*gear2->getEntityRigidBody(), *squareTest->getEntityRigidBody(), localA, localB, false);
		//btHingeConstraint* testConstraint = new btHingeConstraint(*gear2->getEntityRigidBody(), *squareTest->getEntityRigidBody(), btVector3(0, 0, 0), btVector3(0, 0, 0), btVector3(0, 0, 0), btVector3(0, 0, 0), false);
		testConstraint->setAxis(btVector3(0, 1, 0));
		testConstraint->enableAngularMotor(true, 6, 3);
		dynamicsWorld->addConstraint(testConstraint);
I have tried 3 different types of constructors and each ends with my gear floating above the square. The square is 1 unit thick, and the gear is .1 unit thick. The surface area is large enough... this happens with one gear or many. It is annoying as I am trying to attach gearedwheels to make it move rather than make an actual vehicle. It happens if the gear is at (0, 1.1, 0), or another position that is outside of the square... always appears to be the same distance.
Image

I had all of the gears working together when they were attached just to the world in blank space, but trying to attach them to a cube is proving most frustrating.

Image

If anyone could explain the hinge constraint a bit more and why it may be moving the location of my gears so that they no longer line up as they should, that would be excellent.