diff --git a/apps/openmw/mwrender/actors.hpp b/apps/openmw/mwrender/actors.hpp index be6486fd7..93ec07f98 100644 --- a/apps/openmw/mwrender/actors.hpp +++ b/apps/openmw/mwrender/actors.hpp @@ -16,6 +16,7 @@ #include "../mwworld/environment.hpp" #include "npcanimation.hpp" #include "creatureanimation.hpp" +#include namespace MWRender{ class Actors{ diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index bea0873b7..b272980c7 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -410,6 +410,11 @@ namespace MWRender{ bone->setPosition(t); if(bQuats) bone->setOrientation(r); + + if(iter == transformations->begin()){ + trans = bone->_getDerivedPosition(); + rotate = bone->_getDerivedOrientation(); + } skel->getManualBonesDirty(); skel->_updateTransforms(); skel->_notifyManualBonesDirty(); diff --git a/apps/openmw/mwrender/animation.hpp b/apps/openmw/mwrender/animation.hpp index 65f872e0a..9c240f7a6 100644 --- a/apps/openmw/mwrender/animation.hpp +++ b/apps/openmw/mwrender/animation.hpp @@ -8,6 +8,7 @@ #include "../mwworld/environment.hpp" #include #include +#include namespace MWRender{ @@ -15,9 +16,12 @@ class Animation{ protected: + OEngine::Physic::PhysicEngine* engine; OEngine::Render::OgreRenderer &mRend; MWWorld::Environment& mEnvironment; static std::map mUniqueIDs; + Ogre::Quaternion rotate; + Ogre::Vector3 trans; std::vector* > shapeparts; //All the NiTriShape data that we need for animating an npc float time; @@ -38,8 +42,6 @@ class Animation{ std::vector* shapes; //All the NiTriShapeData for this creature std::vector entityparts; - - std::vector* transformations; std::map textmappings; diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 9466fd9ab..4630f0d3b 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -259,6 +259,16 @@ void NpcAnimation::runAnimation(float timepassed){ } handleAnimationTransforms(); + //mEnvironment.mWorld-> + /*if(base->hasSkeleton()) + { + + Ogre::Quaternion boneQuat = rotate; + Ogre::Vector3 boneTrans = trans; + mEnvironment.mWorld->setObjectPhysicsPosition(insert->getName(), boneTrans + insert->getPosition()); + mEnvironment.mWorld->setObjectPhysicsRotation(insert->getName(), boneQuat * insert->getOrientation()); + + }*/ // handleAnimationTransforms(base); //handleAnimationTransforms(hand); // diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index cfe5edab4..e74e201f5 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -145,6 +145,12 @@ namespace MWWorld void PhysicsSystem::rotateObject (const std::string& handle, const Ogre::Quaternion& rotation) { + if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) + { + // TODO very dirty hack to avoid crash during setup -> needs cleaning up to allow + // start positions others than 0, 0, 0 + act->setRotation(btQuaternion(rotation.x, rotation.y, rotation.z, rotation.w)); + } } void PhysicsSystem::scaleObject (const std::string& handle, float scale) diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index a4f167103..2232e8a1d 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -685,4 +685,10 @@ namespace MWWorld { mRendering.skipAnimation (ptr); } + void World::setObjectPhysicsRotation(const std::string& handle, Ogre::Quaternion quat){ + mPhysics->rotateObject(handle, quat); + } + void World::setObjectPhysicsPosition(const std::string& handle, Ogre::Vector3 vec){ + mPhysics->moveObject(handle, vec); + } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 2c7b43280..235d203a6 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -218,6 +218,8 @@ namespace MWWorld void skipAnimation (const MWWorld::Ptr& ptr); ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. + void setObjectPhysicsRotation(const std::string& handle,Ogre::Quaternion quat); + void setObjectPhysicsPosition(const std::string& handle,Ogre::Vector3 vector); }; }