Ops, messed up on which engine implements what. Anyways, I looked through the most obvious places to eventually put a "lift"-joint, and I couldn't find anything.
Anyways, using Ogre::Quaternion (for multiplication with vectors), I managed to get a very smooth lifting-system. Goes something like this:
Upon interaction (lifting):
Code:
//Calculate the direction vector
mConTime = 0;
Ogre::Vector3 v = mPlayer->camYNode->getOrientation() *
mPlayer->camXNode->getOrientation() * vp(0,0,1);
mConBody = (btRigidBody*)mTarget;
mConBody->activate();
//Create an ogre Quaternion (btQuaternion has trouble with vector3 mult)
btVector3 conRot( mConBody->getOrientation().getX(),
mConBody->getOrientation().getY(),
mConBody->getOrientation().getZ());
Ogre::Quaternion oq(mConBody->getOrientation().getW(), conRot.x(), conRot.y(), conRot.z());
//Get the local vector in the targetted shape
Ogre::Vector3 p = btToOg(mTargetPt - mConBody->getWorldTransform().getOrigin());
//Multiply it with the inverse of the quaternion
p = oq.Inverse() * p;
mCon = new btPoint2PointConstraint(*mConBody, *mBaseBody, ogToBt(p), btVector3(0,0,0));
//Calculate the distance
Ogre::Vector3 a = btToOg( mTargetPt );
Ogre::Vector3 b = mPlayer->mainNode->getPosition();
mConDist = sqrt( pow(b.x-a.x,2) + pow(b.y-a.y,2) + pow(b.z-a.z,2) );
mWorld->addConstraint(mCon);
Called every frame:
Code:
if (mCon)
{
if (!mCon->isEnabled())
{
dismiss();
return;
}
Ogre::Vector3 v = mPlayer->camYNode->getOrientation() *
mPlayer->camXNode->getOrientation() * vp(0,0,1);
Ogre::Vector3 f = vp(v.x,v.y,v.z)*-mConDist + mPlayer->mainNode->getPosition();
mConTime += dt;
if (mConTime > 0.1f)
{
mCon->setBreakingImpulseThreshold(1500);
}
mCon->setPivotB( ogToBt( f ) );
}
Hope this is of any help to anyone
