forked from teamnwah/openmw-tes3coop
First/Third person transitions with mouse wheel
This commit is contained in:
parent
3fa4a194a7
commit
d2b7cb5bb2
3 changed files with 40 additions and 7 deletions
|
@ -25,7 +25,9 @@ namespace MWRender
|
|||
mHeight(128.f),
|
||||
mCameraDistance(300.f),
|
||||
mDistanceAdjusted(false),
|
||||
mAnimation(NULL)
|
||||
mAnimation(NULL),
|
||||
mNearest(30.f),
|
||||
mFurthest(800.f)
|
||||
{
|
||||
mVanity.enabled = false;
|
||||
mVanity.allowed = true;
|
||||
|
@ -232,16 +234,21 @@ namespace MWRender
|
|||
if(mFirstPersonView && !mPreviewMode && !mVanity.enabled)
|
||||
return;
|
||||
|
||||
mIsFurthest = false;
|
||||
mIsNearest = false;
|
||||
|
||||
Ogre::Vector3 v(0.f, 0.f, dist);
|
||||
if (adjust) {
|
||||
v += mCamera->getPosition();
|
||||
}
|
||||
if (v.z > 800.f) {
|
||||
v.z = 800.f;
|
||||
} else if (v.z < 10.f) {
|
||||
if (v.z >= mFurthest) {
|
||||
v.z = mFurthest;
|
||||
mIsFurthest = true;
|
||||
} else if (!override && v.z < 10.f) {
|
||||
v.z = 10.f;
|
||||
} else if (override && v.z < 50.f) {
|
||||
v.z = 50.f;
|
||||
} else if (override && v.z <= mNearest) {
|
||||
v.z = mNearest;
|
||||
mIsNearest = true;
|
||||
}
|
||||
mCamera->setPosition(v);
|
||||
|
||||
|
@ -320,4 +327,14 @@ namespace MWRender
|
|||
{
|
||||
return mPreviewMode || mVanity.enabled;
|
||||
}
|
||||
|
||||
bool Camera::isNearest()
|
||||
{
|
||||
return mIsNearest;
|
||||
}
|
||||
|
||||
bool Camera::isFurthest()
|
||||
{
|
||||
return mIsFurthest;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,10 @@ namespace MWRender
|
|||
bool mFirstPersonView;
|
||||
bool mPreviewMode;
|
||||
bool mFreeLook;
|
||||
float mNearest;
|
||||
float mFurthest;
|
||||
bool mIsNearest;
|
||||
bool mIsFurthest;
|
||||
|
||||
struct {
|
||||
bool enabled, allowed;
|
||||
|
@ -99,6 +103,10 @@ namespace MWRender
|
|||
void togglePlayerLooking(bool enable);
|
||||
|
||||
bool isVanityOrPreviewModeEnabled();
|
||||
|
||||
bool isNearest();
|
||||
|
||||
bool isFurthest();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -903,7 +903,15 @@ void RenderingManager::setCameraDistance(float dist, bool adjust, bool override)
|
|||
{
|
||||
if(!mCamera->isVanityOrPreviewModeEnabled() && !mCamera->isFirstPerson())
|
||||
{
|
||||
mCamera->setCameraDistance(-dist / 120.f * 10, adjust, override);
|
||||
if(mCamera->isNearest() && dist > 0.f)
|
||||
mCamera->toggleViewMode();
|
||||
else
|
||||
mCamera->setCameraDistance(-dist / 120.f * 10, adjust, override);
|
||||
}
|
||||
else if(mCamera->isFirstPerson() && dist < 0.f)
|
||||
{
|
||||
mCamera->toggleViewMode();
|
||||
mCamera->setCameraDistance(0.f, false, override);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue