mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-26 23:11:33 +00:00
camera control related script instructions
This commit is contained in:
parent
60fb1e8df6
commit
0e6e141fd4
7 changed files with 44 additions and 19 deletions
|
@ -253,6 +253,7 @@ namespace MWBase
|
||||||
virtual void togglePreviewMode(bool enable) = 0;
|
virtual void togglePreviewMode(bool enable) = 0;
|
||||||
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 renderPlayer() = 0;
|
virtual void renderPlayer() = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -443,10 +443,7 @@ private:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Start mouse-looking again if allowed.
|
mouse->enable();
|
||||||
if (mControlSwitch["playerlooking"]) {
|
|
||||||
mouse->enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable GUI events
|
// Disable GUI events
|
||||||
guiEvents->enabled = false;
|
guiEvents->enabled = false;
|
||||||
|
@ -467,16 +464,19 @@ private:
|
||||||
} else if (sw == "playerjumping" && !value) {
|
} else if (sw == "playerjumping" && !value) {
|
||||||
/// \fixme maybe crouching at this time
|
/// \fixme maybe crouching at this time
|
||||||
player.setUpDown(0);
|
player.setUpDown(0);
|
||||||
|
} else if (sw == "vanitymode") {
|
||||||
|
MWBase::Environment::get().getWorld()->allowVanityMode(value);
|
||||||
} else if (sw == "playerlooking") {
|
} else if (sw == "playerlooking") {
|
||||||
if (value) {
|
MWBase::Environment::get().getWorld()->togglePlayerLooking(value);
|
||||||
mouse->enable();
|
|
||||||
} else {
|
|
||||||
mouse->disable();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mControlSwitch[sw] = value;
|
mControlSwitch[sw] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getControlSwitch(std::string sw)
|
||||||
|
{
|
||||||
|
return mControlSwitch[sw];
|
||||||
|
}
|
||||||
|
|
||||||
void togglePOV()
|
void togglePOV()
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->togglePOV();
|
MWBase::Environment::get().getWorld()->togglePOV();
|
||||||
|
@ -535,4 +535,9 @@ private:
|
||||||
{
|
{
|
||||||
impl->toggleControlSwitch(sw, value);
|
impl->toggleControlSwitch(sw, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MWInputManager::getControlSwitch(std::string sw)
|
||||||
|
{
|
||||||
|
return impl->getControlSwitch(sw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ namespace MWInput
|
||||||
|
|
||||||
virtual void setDragDrop(bool dragDrop);
|
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
|
#endif
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "../mwworld/refdata.hpp"
|
#include "../mwworld/refdata.hpp"
|
||||||
|
|
||||||
#include "npcanimation.hpp"
|
#include "npcanimation.hpp"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
@ -21,6 +20,7 @@ namespace MWRender
|
||||||
mCameraNode(mPlayerNode->createChildSceneNode()),
|
mCameraNode(mPlayerNode->createChildSceneNode()),
|
||||||
mFirstPersonView(true),
|
mFirstPersonView(true),
|
||||||
mPreviewMode(false),
|
mPreviewMode(false),
|
||||||
|
mFreeLook(true),
|
||||||
mHeight(128.f),
|
mHeight(128.f),
|
||||||
mCameraDistance(300.f),
|
mCameraDistance(300.f),
|
||||||
mDistanceAdjusted(false)
|
mDistanceAdjusted(false)
|
||||||
|
@ -49,18 +49,21 @@ namespace MWRender
|
||||||
|
|
||||||
/// \note rotate player on forced vanity
|
/// \note rotate player on forced vanity
|
||||||
if (mVanity.forced) {
|
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;
|
mVanity.enabled = false;
|
||||||
rotateCamera(rot, adjust);
|
rotateCamera(rot, adjust);
|
||||||
mVanity.enabled = true;
|
mVanity.enabled = true;
|
||||||
|
|
||||||
compensateYaw(diff);
|
|
||||||
|
|
||||||
|
compensateYaw(diff);
|
||||||
|
}
|
||||||
trueRot.z = 0.f;
|
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
|
/// \note if vanity mode is forced by TVM then rotate player
|
||||||
return (!mVanity.enabled && !mPreviewMode) || mVanity.forced;
|
return (!mVanity.enabled && !mPreviewMode) || mVanity.forced;
|
||||||
|
@ -349,4 +352,9 @@ namespace MWRender
|
||||||
Ogre::Vector3::UNIT_X);
|
Ogre::Vector3::UNIT_X);
|
||||||
mCameraNode->setOrientation(zr * xr);
|
mCameraNode->setOrientation(zr * xr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::togglePlayerLooking(bool enable)
|
||||||
|
{
|
||||||
|
mFreeLook = enable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,12 +29,12 @@ namespace MWRender
|
||||||
|
|
||||||
Ogre::SceneNode *mPlayerNode;
|
Ogre::SceneNode *mPlayerNode;
|
||||||
Ogre::SceneNode *mCameraNode;
|
Ogre::SceneNode *mCameraNode;
|
||||||
Ogre::SceneNode *mVanityNode;
|
|
||||||
|
|
||||||
NpcAnimation *mAnimation;
|
NpcAnimation *mAnimation;
|
||||||
|
|
||||||
bool mFirstPersonView;
|
bool mFirstPersonView;
|
||||||
bool mPreviewMode;
|
bool mPreviewMode;
|
||||||
|
bool mFreeLook;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool enabled, allowed, forced;
|
bool enabled, allowed, forced;
|
||||||
|
@ -106,6 +106,8 @@ namespace MWRender
|
||||||
Ogre::Vector3 getPosition();
|
Ogre::Vector3 getPosition();
|
||||||
|
|
||||||
void getSightAngles(float &pitch, float &yaw);
|
void getSightAngles(float &pitch, float &yaw);
|
||||||
|
|
||||||
|
void togglePlayerLooking(bool enable);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,10 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
||||||
mPlayer->allowVanityMode(allow);
|
mPlayer->allowVanityMode(allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void togglePlayerLooking(bool enable) {
|
||||||
|
mPlayer->togglePlayerLooking(enable);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
@ -293,6 +293,10 @@ namespace MWWorld
|
||||||
mRendering->allowVanityMode(allow);
|
mRendering->allowVanityMode(allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void togglePlayerLooking(bool enable) {
|
||||||
|
mRendering->togglePlayerLooking(enable);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void renderPlayer();
|
virtual void renderPlayer();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue