Adjust third person camera height based on character height

pull/801/head
scrawl 9 years ago
parent 64abdbabe3
commit 1b52749ae1

@ -42,7 +42,8 @@ namespace MWRender
{
Camera::Camera (osg::Camera* camera)
: mCamera(camera),
: mHeightScale(1.f),
mCamera(camera),
mAnimation(NULL),
mFirstPersonView(true),
mPreviewMode(false),
@ -93,7 +94,7 @@ namespace MWRender
osg::Vec3d position = worldMat.getTrans();
if (!isFirstPerson())
position.z() += mHeight;
position.z() += mHeight * mHeightScale;
return position;
}
@ -372,11 +373,17 @@ namespace MWRender
mTrackingNode = mAnimation->getNode("Camera");
if (!mTrackingNode)
mTrackingNode = mAnimation->getNode("Head");
mHeightScale = 1.f;
}
else
{
mAnimation->setViewMode(NpcAnimation::VM_Normal);
mTrackingNode = mTrackingPtr.getRefData().getBaseNode();
osg::PositionAttitudeTransform* transform = mTrackingPtr.getRefData().getBaseNode();
mTrackingNode = transform;
if (transform)
mHeightScale = mTrackingPtr.getRefData().getBaseNode()->getScale().z();
else
mHeightScale = 1.f;
}
rotateCamera(getPitch(), getYaw(), false);
}

@ -29,6 +29,7 @@ namespace MWRender
MWWorld::Ptr mTrackingPtr;
osg::ref_ptr<const osg::Node> mTrackingNode;
float mHeightScale;
osg::ref_ptr<osg::Camera> mCamera;
@ -97,6 +98,8 @@ namespace MWRender
bool isFirstPerson() const
{ return !(mVanity.enabled || mPreviewMode || !mFirstPersonView); }
void updateScale();
void processViewChange();
void update(float duration, bool paused=false);

@ -439,6 +439,9 @@ namespace MWRender
void RenderingManager::scaleObject(const MWWorld::Ptr &ptr, const osg::Vec3f &scale)
{
ptr.getRefData().getBaseNode()->setScale(scale);
if (ptr == mCamera->getTrackingPtr()) // update height of camera
mCamera->processViewChange();
}
void RenderingManager::removeObject(const MWWorld::Ptr &ptr)

Loading…
Cancel
Save