mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
fix sky in preview mode movement
This commit is contained in:
parent
6961830efb
commit
60fb1e8df6
@ -19,7 +19,6 @@ namespace MWRender
|
|||||||
: mCamera(camera),
|
: mCamera(camera),
|
||||||
mPlayerNode(node),
|
mPlayerNode(node),
|
||||||
mCameraNode(mPlayerNode->createChildSceneNode()),
|
mCameraNode(mPlayerNode->createChildSceneNode()),
|
||||||
mVanityNode(mPlayerNode->createChildSceneNode()),
|
|
||||||
mFirstPersonView(true),
|
mFirstPersonView(true),
|
||||||
mPreviewMode(false),
|
mPreviewMode(false),
|
||||||
mHeight(128.f),
|
mHeight(128.f),
|
||||||
@ -50,14 +49,14 @@ namespace MWRender
|
|||||||
|
|
||||||
/// \note rotate player on forced vanity
|
/// \note rotate player on forced vanity
|
||||||
if (mVanity.forced) {
|
if (mVanity.forced) {
|
||||||
moveCameraNode(mPlayerNode);
|
float diff = (adjust) ? rot.z : mMainCam.yaw - rot.z;
|
||||||
|
|
||||||
mVanity.enabled = false;
|
mVanity.enabled = false;
|
||||||
|
|
||||||
rotateCamera(rot, adjust);
|
rotateCamera(rot, adjust);
|
||||||
|
|
||||||
moveCameraNode(mVanityNode);
|
|
||||||
mVanity.enabled = true;
|
mVanity.enabled = true;
|
||||||
|
|
||||||
|
compensateYaw(diff);
|
||||||
|
|
||||||
trueRot.z = 0.f;
|
trueRot.z = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,9 +68,6 @@ namespace MWRender
|
|||||||
|
|
||||||
void Player::rotateCamera(const Ogre::Vector3 &rot, bool adjust)
|
void Player::rotateCamera(const Ogre::Vector3 &rot, bool adjust)
|
||||||
{
|
{
|
||||||
Ogre::SceneNode *pitchNode = mCamera->getParentSceneNode();
|
|
||||||
Ogre::SceneNode *yawNode = pitchNode->getParentSceneNode();
|
|
||||||
|
|
||||||
if (adjust) {
|
if (adjust) {
|
||||||
setYaw(getYaw() + rot.z);
|
setYaw(getYaw() + rot.z);
|
||||||
setPitch(getPitch() + rot.x);
|
setPitch(getPitch() + rot.x);
|
||||||
@ -83,11 +79,16 @@ namespace MWRender
|
|||||||
Ogre::Radian(getPitch() + Ogre::Math::HALF_PI),
|
Ogre::Radian(getPitch() + Ogre::Math::HALF_PI),
|
||||||
Ogre::Vector3::UNIT_X
|
Ogre::Vector3::UNIT_X
|
||||||
);
|
);
|
||||||
Ogre::Quaternion zr(Ogre::Radian(getYaw()), Ogre::Vector3::NEGATIVE_UNIT_Z);
|
Ogre::Quaternion zr(
|
||||||
|
Ogre::Radian(getYaw()),
|
||||||
pitchNode->setOrientation(xr);
|
Ogre::Vector3::NEGATIVE_UNIT_Z
|
||||||
yawNode->setOrientation(zr);
|
);
|
||||||
|
if (!mVanity.enabled && !mPreviewMode) {
|
||||||
|
mPlayerNode->setOrientation(zr);
|
||||||
|
mCameraNode->setOrientation(xr);
|
||||||
|
} else {
|
||||||
|
mCameraNode->setOrientation(zr * xr);
|
||||||
|
}
|
||||||
updateListener();
|
updateListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,12 +177,10 @@ namespace MWRender
|
|||||||
rot.x = Ogre::Degree(-30.f).valueRadians();
|
rot.x = Ogre::Degree(-30.f).valueRadians();
|
||||||
mMainCam.offset = mCamera->getPosition().z;
|
mMainCam.offset = mCamera->getPosition().z;
|
||||||
|
|
||||||
moveCameraNode(mVanityNode);
|
|
||||||
} else {
|
} else {
|
||||||
rot.x = getPitch();
|
rot.x = getPitch();
|
||||||
offset = mMainCam.offset;
|
offset = mMainCam.offset;
|
||||||
|
|
||||||
moveCameraNode(mPlayerNode);
|
|
||||||
mPlayerNode->setVisible(!mFirstPersonView, false);
|
mPlayerNode->setVisible(!mFirstPersonView, false);
|
||||||
}
|
}
|
||||||
rot.z = getYaw();
|
rot.z = getYaw();
|
||||||
@ -203,12 +202,10 @@ namespace MWRender
|
|||||||
mMainCam.offset = offset;
|
mMainCam.offset = offset;
|
||||||
offset = mPreviewCam.offset;
|
offset = mPreviewCam.offset;
|
||||||
|
|
||||||
moveCameraNode(mVanityNode);
|
|
||||||
} else {
|
} else {
|
||||||
mPreviewCam.offset = offset;
|
mPreviewCam.offset = offset;
|
||||||
offset = mMainCam.offset;
|
offset = mMainCam.offset;
|
||||||
|
|
||||||
moveCameraNode(mPlayerNode);
|
|
||||||
mPlayerNode->setVisible(!mFirstPersonView, false);
|
mPlayerNode->setVisible(!mFirstPersonView, false);
|
||||||
}
|
}
|
||||||
mCamera->setPosition(0.f, 0.f, offset);
|
mCamera->setPosition(0.f, 0.f, offset);
|
||||||
@ -263,12 +260,6 @@ namespace MWRender
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::moveCameraNode(Ogre::SceneNode *node)
|
|
||||||
{
|
|
||||||
mCameraNode->getParentSceneNode()->removeChild(mCameraNode);
|
|
||||||
node->addChild(mCameraNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setCameraDistance(float dist, bool adjust, bool override)
|
void Player::setCameraDistance(float dist, bool adjust, bool override)
|
||||||
{
|
{
|
||||||
if (mFirstPersonView && !mPreviewMode && !mVanity.enabled) {
|
if (mFirstPersonView && !mPreviewMode && !mVanity.enabled) {
|
||||||
@ -345,4 +336,17 @@ namespace MWRender
|
|||||||
pitch = mMainCam.pitch;
|
pitch = mMainCam.pitch;
|
||||||
yaw = mMainCam.yaw;
|
yaw = mMainCam.yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::compensateYaw(float diff)
|
||||||
|
{
|
||||||
|
mPreviewCam.yaw -= diff;
|
||||||
|
Ogre::Quaternion zr(
|
||||||
|
Ogre::Radian(mPreviewCam.yaw),
|
||||||
|
Ogre::Vector3::NEGATIVE_UNIT_Z
|
||||||
|
);
|
||||||
|
Ogre::Quaternion xr(
|
||||||
|
Ogre::Radian(mPreviewCam.pitch),
|
||||||
|
Ogre::Vector3::UNIT_X);
|
||||||
|
mCameraNode->setOrientation(zr * xr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ namespace MWRender
|
|||||||
float getPitch();
|
float getPitch();
|
||||||
void setPitch(float angle);
|
void setPitch(float angle);
|
||||||
|
|
||||||
void moveCameraNode(Ogre::SceneNode *node);
|
void compensateYaw(float diff);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user