mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Adjust third person camera height based on character height
This commit is contained in:
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…
x
Reference in New Issue
Block a user