forked from mirror/openmw-tes3mp
using real player eye direction when moving
This commit is contained in:
parent
e8fc942bef
commit
6961830efb
7 changed files with 51 additions and 10 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "../mwworld/refdata.hpp"
|
#include "../mwworld/refdata.hpp"
|
||||||
|
|
||||||
#include "npcanimation.hpp"
|
#include "npcanimation.hpp"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
@ -333,4 +334,15 @@ namespace MWRender
|
||||||
|
|
||||||
return mFirstPersonView && !mVanity.enabled && !mPreviewMode;
|
return mFirstPersonView && !mVanity.enabled && !mPreviewMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ogre::Vector3 Player::getPosition()
|
||||||
|
{
|
||||||
|
return mPlayerNode->getPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::getSightAngles(float &pitch, float &yaw)
|
||||||
|
{
|
||||||
|
pitch = mMainCam.pitch;
|
||||||
|
yaw = mMainCam.yaw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,9 @@ namespace MWRender
|
||||||
/// Stores player and camera world positions in passed arguments
|
/// Stores player and camera world positions in passed arguments
|
||||||
/// \return true if camera at the eye-place
|
/// \return true if camera at the eye-place
|
||||||
bool getPosition(Ogre::Vector3 &player, Ogre::Vector3 &camera);
|
bool getPosition(Ogre::Vector3 &player, Ogre::Vector3 &camera);
|
||||||
|
Ogre::Vector3 getPosition();
|
||||||
|
|
||||||
|
void getSightAngles(float &pitch, float &yaw);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -856,4 +856,11 @@ void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
|
||||||
mPlayer->setAnimation(anim);
|
mPlayer->setAnimation(anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderingManager::getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw)
|
||||||
|
{
|
||||||
|
eyepos = mPlayer->getPosition();
|
||||||
|
eyepos.z += mPlayer->getHeight();
|
||||||
|
mPlayer->getSightAngles(pitch, yaw);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -72,6 +72,8 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
||||||
mPlayer->allowVanityMode(allow);
|
mPlayer->allowVanityMode(allow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
|
||||||
|
|
||||||
void attachCameraTo(const MWWorld::Ptr &ptr);
|
void attachCameraTo(const MWWorld::Ptr &ptr);
|
||||||
void renderPlayer(const MWWorld::Ptr &ptr);
|
void renderPlayer(const MWWorld::Ptr &ptr);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "class.hpp"
|
#include "class.hpp"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
@ -42,10 +44,8 @@ namespace MWWorld
|
||||||
return mEngine;
|
return mEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::string, float> PhysicsSystem::getFacedHandle (MWWorld::World& world)
|
std::pair<std::string, float> PhysicsSystem::getFacedHandle (MWWorld::World& world)
|
||||||
{
|
{
|
||||||
std::string handle = "";
|
|
||||||
|
|
||||||
//get a ray pointing to the center of the viewport
|
//get a ray pointing to the center of the viewport
|
||||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
||||||
mRender.getViewport()->getWidth()/2,
|
mRender.getViewport()->getWidth()/2,
|
||||||
|
@ -190,12 +190,11 @@ namespace MWWorld
|
||||||
float pitch = 0.f;
|
float pitch = 0.f;
|
||||||
|
|
||||||
if (iter->first == "player") {
|
if (iter->first == "player") {
|
||||||
/// \fixme should not rely on player camera, real pitch needed
|
playerphysics->ps.viewangles.x =
|
||||||
Ogre::SceneNode *node = mRender.getCamera()->getParentSceneNode();
|
Ogre::Radian(mPlayerData.pitch).valueDegrees();
|
||||||
pitch = node->getOrientation().getPitch().valueDegrees();
|
|
||||||
|
|
||||||
playerphysics->ps.viewangles.x = pitch - 90;
|
playerphysics->ps.viewangles.y =
|
||||||
playerphysics->ps.viewangles.y = -yaw + 90;
|
Ogre::Radian(mPlayerData.yaw).valueDegrees() + 90;
|
||||||
|
|
||||||
pm_ref.rightmove = -iter->second.x;
|
pm_ref.rightmove = -iter->second.x;
|
||||||
pm_ref.forwardmove = -iter->second.y;
|
pm_ref.forwardmove = -iter->second.y;
|
||||||
|
@ -392,4 +391,11 @@ namespace MWWorld
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhysicsSystem::updatePlayerData(Ogre::Vector3 &eyepos, float pitch, float yaw)
|
||||||
|
{
|
||||||
|
mPlayerData.eyepos = eyepos;
|
||||||
|
mPlayerData.pitch = pitch;
|
||||||
|
mPlayerData.yaw = yaw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,14 @@ namespace MWWorld
|
||||||
|
|
||||||
bool getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max);
|
bool getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max);
|
||||||
|
|
||||||
|
void updatePlayerData(Ogre::Vector3 &eyepos, float pitch, float yaw);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct {
|
||||||
|
Ogre::Vector3 eyepos;
|
||||||
|
float pitch, yaw;
|
||||||
|
} mPlayerData;
|
||||||
|
|
||||||
OEngine::Render::OgreRenderer &mRender;
|
OEngine::Render::OgreRenderer &mRender;
|
||||||
OEngine::Physic::PhysicEngine* mEngine;
|
OEngine::Physic::PhysicEngine* mEngine;
|
||||||
bool mFreeFly;
|
bool mFreeFly;
|
||||||
|
@ -80,7 +87,6 @@ namespace MWWorld
|
||||||
PhysicsSystem (const PhysicsSystem&);
|
PhysicsSystem (const PhysicsSystem&);
|
||||||
PhysicsSystem& operator= (const PhysicsSystem&);
|
PhysicsSystem& operator= (const PhysicsSystem&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -806,6 +806,11 @@ namespace MWWorld
|
||||||
/// \todo split this function up into subfunctions
|
/// \todo split this function up into subfunctions
|
||||||
|
|
||||||
mWorldScene->update (duration);
|
mWorldScene->update (duration);
|
||||||
|
|
||||||
|
float pitch, yaw;
|
||||||
|
Ogre::Vector3 eyepos;
|
||||||
|
mRendering->getPlayerData(eyepos, pitch, yaw);
|
||||||
|
mPhysics->updatePlayerData(eyepos, pitch, yaw);
|
||||||
|
|
||||||
mWeatherManager->update (duration);
|
mWeatherManager->update (duration);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue