1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-30 02:06:43 +00:00

added camera flip control, fixed input rotation axis

This commit is contained in:
greye 2012-08-09 10:24:18 +04:00
parent ec9cf4d3c6
commit a2d87d5f5b
3 changed files with 32 additions and 4 deletions

View file

@ -24,5 +24,5 @@ void MouseLookEvent::event(Type type, int index, const void *p)
float y = arg->state.Y.rel * sensY;
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);
}

View file

@ -24,14 +24,16 @@ namespace MWRender
// we are only interested in X and Y rotation
// Rotate around X axis
Ogre::Quaternion xr(Ogre::Radian(rot.x), Ogre::Vector3::UNIT_X);
Ogre::Quaternion xr(Ogre::Degree(rot.x), Ogre::Vector3::UNIT_X);
// Rotate around Y axis
Ogre::Quaternion yr(Ogre::Radian(-rot.z), Ogre::Vector3::UNIT_Y);
Ogre::Quaternion yr(Ogre::Degree(-rot.z), Ogre::Vector3::UNIT_Y);
pitchNode->setOrientation(xr);
yawNode->setOrientation(yr);
controlFlip();
return !mVanityModeEnabled;
}
@ -51,8 +53,32 @@ namespace MWRender
Ogre::SceneNode *yawNode = pitchNode->getParentSceneNode();
pitchNode->pitch(Ogre::Degree(rot.x));
yawNode->yaw(Ogre::Degree(rot.z));
yawNode->yaw(Ogre::Degree(-rot.z));
controlFlip();
return !mVanityModeEnabled;
}
void Player::controlFlip()
{
Ogre::SceneNode *pitchNode = mCamera->getParentSceneNode();
Ogre::Quaternion orient = pitchNode->getOrientation();
float pitchAngle =
(2 * Ogre::Degree(Ogre::Math::ACos(orient.w)).valueDegrees());
// Limit the pitch between -90 degress and +90 degrees, Quake3-style.
if (pitchAngle > 90.0f)
{
Ogre::Real sqrt = Ogre::Math::Sqrt(0.5f);
if (orient.x > 0) {
// Set orientation to 90 degrees on X-axis.
pitchNode->setOrientation(Ogre::Quaternion(sqrt, sqrt, 0, 0));
} else if (orient.x < 0) {
// Sets orientation to -90 degrees on X-axis.
pitchNode->setOrientation(Ogre::Quaternion(sqrt, -sqrt, 0, 0));
}
}
}
}

View file

@ -27,6 +27,8 @@ namespace MWRender
bool mFirstPersonView;
bool mVanityModeEnabled;
void controlFlip();
public:
Player (Ogre::Camera *camera, Ogre::SceneNode* mNode);