Rotate the neck when looking up and down in first-person

This commit is contained in:
Chris Robinson 2013-07-13 12:39:06 -07:00
parent 4df1f198a7
commit 2d7620e774
4 changed files with 18 additions and 0 deletions

View file

@ -45,6 +45,7 @@ void Animation::destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectL
Animation::Animation(const MWWorld::Ptr &ptr)
: mPtr(ptr)
, mCamera(NULL)
, mInsert(NULL)
, mSkelBase(NULL)
, mAccumRoot(NULL)

View file

@ -11,6 +11,7 @@
namespace MWRender
{
class Camera;
class Animation
{
@ -80,6 +81,7 @@ protected:
typedef std::map<std::string,AnimState> AnimStateMap;
MWWorld::Ptr mPtr;
Camera *mCamera;
Ogre::SceneNode *mInsert;
Ogre::Entity *mSkelBase;
@ -210,6 +212,9 @@ public:
virtual void showWeapons(bool showWeapon);
void setCamera(Camera *cam)
{ mCamera = cam; }
Ogre::Node *getNode(const std::string &name);
};

View file

@ -283,10 +283,14 @@ namespace MWRender
// If we're switching to a new NpcAnimation, ensure the old one is
// using a normal view mode
if(mAnimation && mAnimation != anim)
{
mAnimation->setViewMode(NpcAnimation::VM_Normal);
mAnimation->setCamera(NULL);
}
mAnimation = anim;
mAnimation->setViewMode(isFirstPerson() ? NpcAnimation::VM_FirstPerson :
NpcAnimation::VM_Normal);
mAnimation->setCamera(this);
}
void Camera::setHeight(float height)

View file

@ -14,6 +14,7 @@
#include "../mwbase/mechanicsmanager.hpp"
#include "renderconst.hpp"
#include "camera.hpp"
namespace MWRender
@ -415,6 +416,13 @@ Ogre::Vector3 NpcAnimation::runAnimation(float timepassed)
Ogre::Vector3 ret = Animation::runAnimation(timepassed);
Ogre::SkeletonInstance *baseinst = mSkelBase->getSkeleton();
if(mViewMode == VM_FirstPerson && mCamera)
{
float pitch = mCamera->getPitch();
Ogre::Node *node = baseinst->getBone("Bip01 Neck");
node->pitch(Ogre::Radian(pitch*0.75f), Ogre::Node::TS_WORLD);
}
for(size_t i = 0;i < sPartListSize;i++)
{
Ogre::Entity *ent = mObjectParts[i].mSkelBase;