added getRotation
This commit is contained in:
parent
298f013819
commit
44650eed0c
|
@ -110,7 +110,8 @@ class irrDynamics
|
|||
static void applyTorque(irr::scene::ISceneNode* node, const irr::core::vector3df& torque);
|
||||
static void setDamping(irr::scene::ISceneNode* node, irr::f32 linearDamping, irr::f32 angularDamping);
|
||||
static void setPosition(irr::scene::ISceneNode* node, const irr::core::vector3df& newPos);
|
||||
static void setRotation(irr::scene::ISceneNode* node, const irr::core::vector3df& newRotation);
|
||||
static void setRotation(irr::scene::ISceneNode* node, const irr::core::quaternion& newRotation);
|
||||
static bool getRotation(irr::scene::ISceneNode* node, irr::core::quaternion&);
|
||||
//! Change default gravity
|
||||
/** Per default, irrDynamics is set to an earth-like gravitational force. Modify that for other planets
|
||||
* or your space sim game.
|
||||
|
|
|
@ -456,7 +456,7 @@ void irrDynamics::setPosition(scene::ISceneNode* node, const core::vector3df& ne
|
|||
iter->second->setWorldTransform(transform);
|
||||
}
|
||||
|
||||
void irrDynamics::setRotation(scene::ISceneNode* node, const core::vector3df& newRotation)
|
||||
void irrDynamics::setRotation(scene::ISceneNode* node, const core::quaternion& r)
|
||||
{
|
||||
irrDynamics* inst = getInstance();
|
||||
//find the corresponding rigid body:
|
||||
|
@ -466,15 +466,29 @@ void irrDynamics::setRotation(scene::ISceneNode* node, const core::vector3df& ne
|
|||
cout << "irrdynamics: Unable to find node in list. Rotation update aborted." << endl;
|
||||
return;
|
||||
}
|
||||
btTransform transform; // = iter->second->getWorldTransform();
|
||||
transform.setIdentity();
|
||||
auto transform= iter->second->getWorldTransform();
|
||||
btQuaternion quat;
|
||||
quat.setEuler(core::degToRad(newRotation.Y), core::degToRad(newRotation.X), core::degToRad(newRotation.Z));
|
||||
quat.setValue(r.X, r.Y, r.Z, r.W);
|
||||
transform.setRotation(quat);
|
||||
transform.setOrigin(iter->second->getCenterOfMassPosition());
|
||||
iter->second->setCenterOfMassTransform(transform);
|
||||
}
|
||||
|
||||
bool irrDynamics::getRotation(irr::scene::ISceneNode *node, core::quaternion& rotationOut)
|
||||
{
|
||||
irrDynamics* inst = getInstance();
|
||||
//find the corresponding rigid body:
|
||||
auto iter = inst->objects.find(node);
|
||||
if (iter == inst->objects.end())
|
||||
{
|
||||
cout << "irrdynamics: Unable to find node in list. getrotation aborted." << endl;
|
||||
return false;
|
||||
}
|
||||
auto rot = iter->second->getWorldTransform().getRotation();
|
||||
rotationOut.set(rot.x(), rot.y(), rot.z(), rot.w());
|
||||
return true;
|
||||
}
|
||||
|
||||
void irrDynamics::removeConstraints(btRigidBody* rigidBody)
|
||||
{
|
||||
const int len = rigidBody->getNumConstraintRefs();
|
||||
|
|
Loading…
Reference in New Issue