camera control related script instructions

This commit is contained in:
greye 2012-08-17 13:23:02 +04:00
parent 60fb1e8df6
commit 0e6e141fd4
7 changed files with 44 additions and 19 deletions

View file

@ -253,6 +253,7 @@ namespace MWBase
virtual void togglePreviewMode(bool enable) = 0;
virtual bool toggleVanityMode(bool enable, bool force) = 0;
virtual void allowVanityMode(bool allow) = 0;
virtual void togglePlayerLooking(bool enable) = 0;
virtual void renderPlayer() = 0;
};

View file

@ -443,10 +443,7 @@ private:
}
else
{
// Start mouse-looking again if allowed.
if (mControlSwitch["playerlooking"]) {
mouse->enable();
}
mouse->enable();
// Disable GUI events
guiEvents->enabled = false;
@ -467,16 +464,19 @@ private:
} else if (sw == "playerjumping" && !value) {
/// \fixme maybe crouching at this time
player.setUpDown(0);
} else if (sw == "vanitymode") {
MWBase::Environment::get().getWorld()->allowVanityMode(value);
} else if (sw == "playerlooking") {
if (value) {
mouse->enable();
} else {
mouse->disable();
}
MWBase::Environment::get().getWorld()->togglePlayerLooking(value);
}
mControlSwitch[sw] = value;
}
bool getControlSwitch(std::string sw)
{
return mControlSwitch[sw];
}
void togglePOV()
{
MWBase::Environment::get().getWorld()->togglePOV();
@ -535,4 +535,9 @@ private:
{
impl->toggleControlSwitch(sw, value);
}
bool MWInputManager::getControlSwitch(std::string sw)
{
return impl->getControlSwitch(sw);
}
}

View file

@ -60,7 +60,8 @@ namespace MWInput
virtual void setDragDrop(bool dragDrop);
virtual void toggleControlSwitch (const std::string& sw, bool value);
void toggleControlSwitch(std::string sw, bool value);
bool getControlSwitch(std::string sw);
};
}
#endif

View file

@ -11,7 +11,6 @@
#include "../mwworld/refdata.hpp"
#include "npcanimation.hpp"
#include <stdio.h>
namespace MWRender
{
@ -21,6 +20,7 @@ namespace MWRender
mCameraNode(mPlayerNode->createChildSceneNode()),
mFirstPersonView(true),
mPreviewMode(false),
mFreeLook(true),
mHeight(128.f),
mCameraDistance(300.f),
mDistanceAdjusted(false)
@ -49,18 +49,21 @@ namespace MWRender
/// \note rotate player on forced vanity
if (mVanity.forced) {
float diff = (adjust) ? rot.z : mMainCam.yaw - rot.z;
if (mFreeLook) {
float diff = (adjust) ? rot.z : mMainCam.yaw - rot.z;
mVanity.enabled = false;
rotateCamera(rot, adjust);
mVanity.enabled = true;
compensateYaw(diff);
mVanity.enabled = false;
rotateCamera(rot, adjust);
mVanity.enabled = true;
compensateYaw(diff);
}
trueRot.z = 0.f;
}
rotateCamera(trueRot, adjust);
if (mFreeLook || mVanity.enabled || mPreviewMode) {
rotateCamera(trueRot, adjust);
}
/// \note if vanity mode is forced by TVM then rotate player
return (!mVanity.enabled && !mPreviewMode) || mVanity.forced;
@ -349,4 +352,9 @@ namespace MWRender
Ogre::Vector3::UNIT_X);
mCameraNode->setOrientation(zr * xr);
}
void Player::togglePlayerLooking(bool enable)
{
mFreeLook = enable;
}
}

View file

@ -29,12 +29,12 @@ namespace MWRender
Ogre::SceneNode *mPlayerNode;
Ogre::SceneNode *mCameraNode;
Ogre::SceneNode *mVanityNode;
NpcAnimation *mAnimation;
bool mFirstPersonView;
bool mPreviewMode;
bool mFreeLook;
struct {
bool enabled, allowed, forced;
@ -106,6 +106,8 @@ namespace MWRender
Ogre::Vector3 getPosition();
void getSightAngles(float &pitch, float &yaw);
void togglePlayerLooking(bool enable);
};
}

View file

@ -72,6 +72,10 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
mPlayer->allowVanityMode(allow);
}
virtual void togglePlayerLooking(bool enable) {
mPlayer->togglePlayerLooking(enable);
}
void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
void attachCameraTo(const MWWorld::Ptr &ptr);

View file

@ -293,6 +293,10 @@ namespace MWWorld
mRendering->allowVanityMode(allow);
}
virtual void togglePlayerLooking(bool enable) {
mRendering->togglePlayerLooking(enable);
}
virtual void renderPlayer();
};
}