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 "npcanimation.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
|
@ -333,4 +334,15 @@ namespace MWRender
|
|||
|
||||
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
|
||||
/// \return true if camera at the eye-place
|
||||
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);
|
||||
}
|
||||
|
||||
void RenderingManager::getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw)
|
||||
{
|
||||
eyepos = mPlayer->getPosition();
|
||||
eyepos.z += mPlayer->getHeight();
|
||||
mPlayer->getSightAngles(pitch, yaw);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -72,6 +72,8 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
|||
mPlayer->allowVanityMode(allow);
|
||||
}
|
||||
|
||||
void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
|
||||
|
||||
void attachCameraTo(const MWWorld::Ptr &ptr);
|
||||
void renderPlayer(const MWWorld::Ptr &ptr);
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include "ptr.hpp"
|
||||
#include "class.hpp"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Ogre;
|
||||
namespace MWWorld
|
||||
{
|
||||
|
@ -42,10 +44,8 @@ namespace MWWorld
|
|||
return mEngine;
|
||||
}
|
||||
|
||||
std::pair<std::string, float> PhysicsSystem::getFacedHandle (MWWorld::World& world)
|
||||
{
|
||||
std::string handle = "";
|
||||
|
||||
std::pair<std::string, float> PhysicsSystem::getFacedHandle (MWWorld::World& world)
|
||||
{
|
||||
//get a ray pointing to the center of the viewport
|
||||
Ray centerRay = mRender.getCamera()->getCameraToViewportRay(
|
||||
mRender.getViewport()->getWidth()/2,
|
||||
|
@ -190,12 +190,11 @@ namespace MWWorld
|
|||
float pitch = 0.f;
|
||||
|
||||
if (iter->first == "player") {
|
||||
/// \fixme should not rely on player camera, real pitch needed
|
||||
Ogre::SceneNode *node = mRender.getCamera()->getParentSceneNode();
|
||||
pitch = node->getOrientation().getPitch().valueDegrees();
|
||||
playerphysics->ps.viewangles.x =
|
||||
Ogre::Radian(mPlayerData.pitch).valueDegrees();
|
||||
|
||||
playerphysics->ps.viewangles.x = pitch - 90;
|
||||
playerphysics->ps.viewangles.y = -yaw + 90;
|
||||
playerphysics->ps.viewangles.y =
|
||||
Ogre::Radian(mPlayerData.yaw).valueDegrees() + 90;
|
||||
|
||||
pm_ref.rightmove = -iter->second.x;
|
||||
pm_ref.forwardmove = -iter->second.y;
|
||||
|
@ -392,4 +391,11 @@ namespace MWWorld
|
|||
|
||||
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);
|
||||
|
||||
void updatePlayerData(Ogre::Vector3 &eyepos, float pitch, float yaw);
|
||||
|
||||
private:
|
||||
struct {
|
||||
Ogre::Vector3 eyepos;
|
||||
float pitch, yaw;
|
||||
} mPlayerData;
|
||||
|
||||
OEngine::Render::OgreRenderer &mRender;
|
||||
OEngine::Physic::PhysicEngine* mEngine;
|
||||
bool mFreeFly;
|
||||
|
@ -80,7 +87,6 @@ namespace MWWorld
|
|||
PhysicsSystem (const PhysicsSystem&);
|
||||
PhysicsSystem& operator= (const PhysicsSystem&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -807,6 +807,11 @@ namespace MWWorld
|
|||
|
||||
mWorldScene->update (duration);
|
||||
|
||||
float pitch, yaw;
|
||||
Ogre::Vector3 eyepos;
|
||||
mRendering->getPlayerData(eyepos, pitch, yaw);
|
||||
mPhysics->updatePlayerData(eyepos, pitch, yaw);
|
||||
|
||||
mWeatherManager->update (duration);
|
||||
|
||||
// inform the GUI about focused object
|
||||
|
|
Loading…
Reference in a new issue