Fixed up functions

This commit is contained in:
Robin Engman 2014-02-11 10:49:37 +01:00
parent 985dcf9691
commit ee1dc530fa
2 changed files with 16 additions and 16 deletions

View File

@ -184,7 +184,7 @@ void API_Impl::UpdateWorld()
simpleBody->GetMotionState()->getWorldTransform(trans); simpleBody->GetMotionState()->getWorldTransform(trans);
this->customBodies[i]->SetPosition(Float3(trans.getOrigin().x(), trans.getOrigin().y(), trans.getOrigin().z())); this->customBodies[i]->SetPosition(Float3(trans.getOrigin().x(), trans.getOrigin().y(), trans.getOrigin().z()));
this->customBodies[i]->SetRotation(Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w())); this->customBodies[i]->SetRotation(Quaternion(Float3(trans.getRotation().x(), trans.getRotation().y(), trans.getRotation().z()), trans.getRotation().w()));
//simpleBody->SetUpAndRight(Float3(0,1,0), Float3(-1,0,0));
if(simpleBody->GetRigidBody()->getActivationState() == ACTIVE_TAG) if(simpleBody->GetRigidBody()->getActivationState() == ACTIVE_TAG)
{ {
simpleBody->CallSubscription_Move(); simpleBody->CallSubscription_Move();

View File

@ -141,40 +141,40 @@ void SimpleRigidBody::SetAngularFactor(Float factor)
void SimpleRigidBody::SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right) void SimpleRigidBody::SetUpAndRight(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 right)
{ {
btTransform trans;
btMatrix3x3 rotation; btMatrix3x3 rotation;
btVector3 upVector(up.x, up.y, up.z); btVector3 upVector(up.x, up.y, up.z);
btVector3 rightVector(right.x, right.y, right.z); btVector3 rightVector(right.x, right.y, right.z);
rotation[1] = upVector.normalized(); rotation[1] = upVector.normalized();
rotation[0] = rightVector.normalized(); rotation[0] = rightVector.normalized();
rotation[2] = upVector.cross(rightVector).normalized(); rotation[2] = rightVector.cross(upVector).normalized();
this->motionState->getWorldTransform(trans);
trans.setBasis(rotation);
this->motionState->setWorldTransform(trans);
btQuaternion quaternion; btQuaternion quaternion;
rotation.getRotation(quaternion); quaternion = trans.getRotation();
this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w()); this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w());
btTransform trans;
this->motionState->getWorldTransform(trans);
trans.setRotation(quaternion);
this->motionState->setWorldTransform(trans);
} }
void SimpleRigidBody::SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward) void SimpleRigidBody::SetUpAndForward(::Oyster::Math::Float3 up, ::Oyster::Math::Float3 forward)
{ {
btTransform trans;
btMatrix3x3 rotation; btMatrix3x3 rotation;
btVector3 upVector(up.x, up.y, up.z); btVector3 upVector(up.x, up.y, up.z);
btVector3 forwardVector(forward.x, forward.y, forward.z); btVector3 forwardVector(forward.x, forward.y, forward.z);
rotation[1] = upVector.normalized(); rotation[1] = upVector.normalized();
rotation[0] = forwardVector.normalized(); rotation[2] = forwardVector.normalized();
rotation[2] = upVector.cross(forwardVector).normalized(); rotation[0] = forwardVector.cross(upVector).normalized();
this->motionState->getWorldTransform(trans);
trans.setBasis(rotation);
this->motionState->setWorldTransform(trans);
btQuaternion quaternion; btQuaternion quaternion;
rotation.getRotation(quaternion); quaternion = trans.getRotation();
this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w()); this->state.quaternion = Quaternion(Float3(quaternion.x(), quaternion.y(), quaternion.z()), quaternion.w());
btTransform trans;
this->motionState->getWorldTransform(trans);
trans.setRotation(quaternion);
this->motionState->setWorldTransform(trans);
} }
Float4x4 SimpleRigidBody::GetRotation() const Float4x4 SimpleRigidBody::GetRotation() const