added getRotation
This commit is contained in:
parent
298f013819
commit
44650eed0c
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
irrDynamics - Light-weight Bullet Physics wrapper for the irrlicht graphics engine
|
||||
Copyright (C) 2014 Otto Naderer - otto.naderer@aec.at
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
Copyright (C) 2014 Otto Naderer - otto.naderer@aec.at
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
@ -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