Allow zooming camera in vanity or preview mode with the mousewheel

This commit is contained in:
scrawl 2013-03-08 00:12:56 +01:00
parent d696da7677
commit 285b4bf726
6 changed files with 22 additions and 0 deletions

View file

@ -296,6 +296,7 @@ namespace MWBase
virtual bool toggleVanityMode(bool enable, bool force) = 0; virtual bool toggleVanityMode(bool enable, bool force) = 0;
virtual void allowVanityMode(bool allow) = 0; virtual void allowVanityMode(bool allow) = 0;
virtual void togglePlayerLooking(bool enable) = 0; virtual void togglePlayerLooking(bool enable) = 0;
virtual void changeVanityModeScale(float factor) = 0;
virtual void renderPlayer() = 0; virtual void renderPlayer() = 0;

View file

@ -548,6 +548,9 @@ namespace MWInput
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
world->rotateObject(world->getPlayer().getPlayer(), -y, 0.f, x, true); world->rotateObject(world->getPlayer().getPlayer(), -y, 0.f, x, true);
if (arg.state.Z.rel)
MWBase::Environment::get().getWorld()->changeVanityModeScale(arg.state.Z.rel);
} }
return true; return true;

View file

@ -271,6 +271,8 @@ namespace MWRender
v.z = 800.f; v.z = 800.f;
} else if (v.z < 10.f) { } else if (v.z < 10.f) {
v.z = 10.f; v.z = 10.f;
} else if (override && v.z < 50.f) {
v.z = 50.f;
} }
mCamera->setPosition(v); mCamera->setPosition(v);
@ -362,4 +364,9 @@ namespace MWRender
mCameraNode->setPosition(0.f, 0.f, mHeight); mCameraNode->setPosition(0.f, 0.f, mHeight);
} }
} }
bool Player::isVanityOrPreviewModeEnabled()
{
return mPreviewMode || mVanity.enabled;
}
} }

View file

@ -110,6 +110,8 @@ namespace MWRender
void getSightAngles(float &pitch, float &yaw); void getSightAngles(float &pitch, float &yaw);
void togglePlayerLooking(bool enable); void togglePlayerLooking(bool enable);
bool isVanityOrPreviewModeEnabled();
}; };
} }

View file

@ -83,6 +83,11 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
mPlayer->togglePlayerLooking(enable); mPlayer->togglePlayerLooking(enable);
} }
void changeVanityModeScale(float factor) {
if (mPlayer->isVanityOrPreviewModeEnabled())
mPlayer->setCameraDistance(-factor/120.f*10, true, true);
}
void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw); void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
void attachCameraTo(const MWWorld::Ptr &ptr); void attachCameraTo(const MWWorld::Ptr &ptr);

View file

@ -339,6 +339,10 @@ namespace MWWorld
mRendering->togglePlayerLooking(enable); mRendering->togglePlayerLooking(enable);
} }
virtual void changeVanityModeScale(float factor) {
mRendering->changeVanityModeScale(factor);
}
virtual void renderPlayer(); virtual void renderPlayer();
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering); virtual void setupExternalRendering (MWRender::ExternalRendering& rendering);