mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
Rename MWRender's Player to Camera
This commit is contained in:
parent
dbba126344
commit
d17e1e83d5
11 changed files with 113 additions and 135 deletions
|
@ -14,7 +14,7 @@ set(GAME_HEADER
|
||||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||||
|
|
||||||
add_openmw_dir (mwrender
|
add_openmw_dir (mwrender
|
||||||
renderingmanager debugging sky player animation npcanimation creatureanimation activatoranimation
|
renderingmanager debugging sky camera animation npcanimation creatureanimation activatoranimation
|
||||||
actors objects renderinginterface localmap occlusionquery terrain terrainmaterial water shadows
|
actors objects renderinginterface localmap occlusionquery terrain terrainmaterial water shadows
|
||||||
compositors characterpreview externalrendering globalmap videoplayer ripplesimulation refraction
|
compositors characterpreview externalrendering globalmap videoplayer ripplesimulation refraction
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "player.hpp"
|
#include "camera.hpp"
|
||||||
|
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
#include <OgreCamera.h>
|
#include <OgreCamera.h>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
Player::Player (Ogre::Camera *camera)
|
Camera::Camera (Ogre::Camera *camera)
|
||||||
: mCamera(camera),
|
: mCamera(camera),
|
||||||
mCameraNode(NULL),
|
mCameraNode(NULL),
|
||||||
mFirstPersonView(true),
|
mFirstPersonView(true),
|
||||||
|
@ -33,11 +33,11 @@ namespace MWRender
|
||||||
mPreviewCam.offset = 400.f;
|
mPreviewCam.offset = 400.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Camera::~Camera()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::rotateCamera(const Ogre::Vector3 &rot, bool adjust)
|
void Camera::rotateCamera(const Ogre::Vector3 &rot, bool adjust)
|
||||||
{
|
{
|
||||||
if (adjust) {
|
if (adjust) {
|
||||||
setYaw(getYaw() + rot.z);
|
setYaw(getYaw() + rot.z);
|
||||||
|
@ -56,12 +56,12 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &Player::getHandle() const
|
const std::string &Camera::getHandle() const
|
||||||
{
|
{
|
||||||
return mTrackingPtr.getRefData().getHandle();
|
return mTrackingPtr.getRefData().getHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::attachTo(const MWWorld::Ptr &ptr)
|
void Camera::attachTo(const MWWorld::Ptr &ptr)
|
||||||
{
|
{
|
||||||
mTrackingPtr = ptr;
|
mTrackingPtr = ptr;
|
||||||
Ogre::SceneNode *node = mTrackingPtr.getRefData().getBaseNode()->createChildSceneNode(Ogre::Vector3(0.0f, 0.0f, mHeight));
|
Ogre::SceneNode *node = mTrackingPtr.getRefData().getBaseNode()->createChildSceneNode(Ogre::Vector3(0.0f, 0.0f, mHeight));
|
||||||
|
@ -76,7 +76,7 @@ namespace MWRender
|
||||||
mCameraNode->attachObject(mCamera);
|
mCameraNode->attachObject(mCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::updateListener()
|
void Camera::updateListener()
|
||||||
{
|
{
|
||||||
Ogre::Vector3 pos = mCamera->getRealPosition();
|
Ogre::Vector3 pos = mCamera->getRealPosition();
|
||||||
Ogre::Vector3 dir = mCamera->getRealDirection();
|
Ogre::Vector3 dir = mCamera->getRealDirection();
|
||||||
|
@ -85,7 +85,7 @@ namespace MWRender
|
||||||
MWBase::Environment::get().getSoundManager()->setListenerPosDir(pos, dir, up);
|
MWBase::Environment::get().getSoundManager()->setListenerPosDir(pos, dir, up);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::update(float duration)
|
void Camera::update(float duration)
|
||||||
{
|
{
|
||||||
updateListener();
|
updateListener();
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::toggleViewMode()
|
void Camera::toggleViewMode()
|
||||||
{
|
{
|
||||||
mFirstPersonView = !mFirstPersonView;
|
mFirstPersonView = !mFirstPersonView;
|
||||||
mAnimation->setViewMode(isFirstPerson() ? NpcAnimation::VM_FirstPerson :
|
mAnimation->setViewMode(isFirstPerson() ? NpcAnimation::VM_FirstPerson :
|
||||||
|
@ -115,14 +115,14 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::allowVanityMode(bool allow)
|
void Camera::allowVanityMode(bool allow)
|
||||||
{
|
{
|
||||||
if (!allow && mVanity.enabled)
|
if (!allow && mVanity.enabled)
|
||||||
toggleVanityMode(false);
|
toggleVanityMode(false);
|
||||||
mVanity.allowed = allow;
|
mVanity.allowed = allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::toggleVanityMode(bool enable)
|
bool Camera::toggleVanityMode(bool enable)
|
||||||
{
|
{
|
||||||
if(!mVanity.allowed && enable)
|
if(!mVanity.allowed && enable)
|
||||||
return false;
|
return false;
|
||||||
|
@ -155,7 +155,7 @@ namespace MWRender
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::togglePreviewMode(bool enable)
|
void Camera::togglePreviewMode(bool enable)
|
||||||
{
|
{
|
||||||
if(mPreviewMode == enable)
|
if(mPreviewMode == enable)
|
||||||
return;
|
return;
|
||||||
|
@ -181,14 +181,14 @@ namespace MWRender
|
||||||
rotateCamera(Ogre::Vector3(getPitch(), 0.f, getYaw()), false);
|
rotateCamera(Ogre::Vector3(getPitch(), 0.f, getYaw()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Player::getYaw()
|
float Camera::getYaw()
|
||||||
{
|
{
|
||||||
if(mVanity.enabled || mPreviewMode)
|
if(mVanity.enabled || mPreviewMode)
|
||||||
return mPreviewCam.yaw;
|
return mPreviewCam.yaw;
|
||||||
return mMainCam.yaw;
|
return mMainCam.yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setYaw(float angle)
|
void Camera::setYaw(float angle)
|
||||||
{
|
{
|
||||||
if (angle > Ogre::Math::PI) {
|
if (angle > Ogre::Math::PI) {
|
||||||
angle -= Ogre::Math::TWO_PI;
|
angle -= Ogre::Math::TWO_PI;
|
||||||
|
@ -202,7 +202,7 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Player::getPitch()
|
float Camera::getPitch()
|
||||||
{
|
{
|
||||||
if (mVanity.enabled || mPreviewMode) {
|
if (mVanity.enabled || mPreviewMode) {
|
||||||
return mPreviewCam.pitch;
|
return mPreviewCam.pitch;
|
||||||
|
@ -210,7 +210,7 @@ namespace MWRender
|
||||||
return mMainCam.pitch;
|
return mMainCam.pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setPitch(float angle)
|
void Camera::setPitch(float angle)
|
||||||
{
|
{
|
||||||
const float epsilon = 0.000001f;
|
const float epsilon = 0.000001f;
|
||||||
float limit = Ogre::Math::HALF_PI - epsilon;
|
float limit = Ogre::Math::HALF_PI - epsilon;
|
||||||
|
@ -229,7 +229,7 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setCameraDistance(float dist, bool adjust, bool override)
|
void Camera::setCameraDistance(float dist, bool adjust, bool override)
|
||||||
{
|
{
|
||||||
if(mFirstPersonView && !mPreviewMode && !mVanity.enabled)
|
if(mFirstPersonView && !mPreviewMode && !mVanity.enabled)
|
||||||
return;
|
return;
|
||||||
|
@ -258,7 +258,7 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setCameraDistance()
|
void Camera::setCameraDistance()
|
||||||
{
|
{
|
||||||
if (mDistanceAdjusted) {
|
if (mDistanceAdjusted) {
|
||||||
if (mVanity.enabled || mPreviewMode) {
|
if (mVanity.enabled || mPreviewMode) {
|
||||||
|
@ -270,7 +270,7 @@ namespace MWRender
|
||||||
mDistanceAdjusted = false;
|
mDistanceAdjusted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setAnimation(NpcAnimation *anim)
|
void Camera::setAnimation(NpcAnimation *anim)
|
||||||
{
|
{
|
||||||
// If we're switching to a new NpcAnimation, ensure the old one is
|
// If we're switching to a new NpcAnimation, ensure the old one is
|
||||||
// using a normal view mode
|
// using a normal view mode
|
||||||
|
@ -281,18 +281,18 @@ namespace MWRender
|
||||||
NpcAnimation::VM_Normal);
|
NpcAnimation::VM_Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setHeight(float height)
|
void Camera::setHeight(float height)
|
||||||
{
|
{
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
mCameraNode->setPosition(0.f, 0.f, mHeight);
|
mCameraNode->setPosition(0.f, 0.f, mHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Player::getHeight()
|
float Camera::getHeight()
|
||||||
{
|
{
|
||||||
return mHeight * mTrackingPtr.getRefData().getBaseNode()->getScale().z;
|
return mHeight * mTrackingPtr.getRefData().getBaseNode()->getScale().z;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::getPosition(Ogre::Vector3 &player, Ogre::Vector3 &camera)
|
bool Camera::getPosition(Ogre::Vector3 &player, Ogre::Vector3 &camera)
|
||||||
{
|
{
|
||||||
mCamera->getParentSceneNode ()->needUpdate(true);
|
mCamera->getParentSceneNode ()->needUpdate(true);
|
||||||
camera = mCamera->getRealPosition();
|
camera = mCamera->getRealPosition();
|
||||||
|
@ -301,23 +301,23 @@ namespace MWRender
|
||||||
return mFirstPersonView && !mVanity.enabled && !mPreviewMode;
|
return mFirstPersonView && !mVanity.enabled && !mPreviewMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::Vector3 Player::getPosition()
|
Ogre::Vector3 Camera::getPosition()
|
||||||
{
|
{
|
||||||
return mTrackingPtr.getRefData().getBaseNode()->getPosition();
|
return mTrackingPtr.getRefData().getBaseNode()->getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::getSightAngles(float &pitch, float &yaw)
|
void Camera::getSightAngles(float &pitch, float &yaw)
|
||||||
{
|
{
|
||||||
pitch = mMainCam.pitch;
|
pitch = mMainCam.pitch;
|
||||||
yaw = mMainCam.yaw;
|
yaw = mMainCam.yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::togglePlayerLooking(bool enable)
|
void Camera::togglePlayerLooking(bool enable)
|
||||||
{
|
{
|
||||||
mFreeLook = enable;
|
mFreeLook = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setLowHeight(bool low)
|
void Camera::setLowHeight(bool low)
|
||||||
{
|
{
|
||||||
if (low) {
|
if (low) {
|
||||||
mCameraNode->setPosition(0.f, 0.f, mHeight * 0.85);
|
mCameraNode->setPosition(0.f, 0.f, mHeight * 0.85);
|
||||||
|
@ -326,7 +326,7 @@ namespace MWRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::isVanityOrPreviewModeEnabled()
|
bool Camera::isVanityOrPreviewModeEnabled()
|
||||||
{
|
{
|
||||||
return mPreviewMode || mVanity.enabled;
|
return mPreviewMode || mVanity.enabled;
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef GAME_MWRENDER_PLAYER_H
|
#ifndef GAME_MWRENDER_CAMERA_H
|
||||||
#define GAME_MWRENDER_PLAYER_H
|
#define GAME_MWRENDER_CAMERA_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
class NpcAnimation;
|
class NpcAnimation;
|
||||||
|
|
||||||
/// \brief Player character rendering and camera control
|
/// \brief Camera control
|
||||||
class Player
|
class Camera
|
||||||
{
|
{
|
||||||
struct CamData {
|
struct CamData {
|
||||||
float pitch, yaw, offset;
|
float pitch, yaw, offset;
|
||||||
|
@ -49,10 +49,10 @@ namespace MWRender
|
||||||
void setLowHeight(bool low = true);
|
void setLowHeight(bool low = true);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Player(Ogre::Camera *camera);
|
Camera(Ogre::Camera *camera);
|
||||||
~Player();
|
~Camera();
|
||||||
|
|
||||||
/// Set where the player is looking at. Uses Morrowind (euler) angles
|
/// Set where the camera is looking at. Uses Morrowind (euler) angles
|
||||||
/// \param rot Rotation angles in radians
|
/// \param rot Rotation angles in radians
|
||||||
void rotateCamera(const Ogre::Vector3 &rot, bool adjust);
|
void rotateCamera(const Ogre::Vector3 &rot, bool adjust);
|
||||||
|
|
||||||
|
@ -65,8 +65,6 @@ namespace MWRender
|
||||||
const std::string &getHandle() const;
|
const std::string &getHandle() const;
|
||||||
|
|
||||||
/// Attach camera to object
|
/// Attach camera to object
|
||||||
/// \note there is no protection from attaching the same camera to
|
|
||||||
/// several different objects
|
|
||||||
void attachTo(const MWWorld::Ptr &);
|
void attachTo(const MWWorld::Ptr &);
|
||||||
|
|
||||||
void toggleViewMode();
|
void toggleViewMode();
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
#include "player.hpp"
|
|
||||||
#include "renderconst.hpp"
|
#include "renderconst.hpp"
|
||||||
|
|
||||||
using namespace Ogre;
|
using namespace Ogre;
|
||||||
|
|
|
@ -39,8 +39,6 @@ namespace MWWorld
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
class Player;
|
|
||||||
|
|
||||||
class Debugging
|
class Debugging
|
||||||
{
|
{
|
||||||
OEngine::Physic::PhysicEngine* mEngine;
|
OEngine::Physic::PhysicEngine* mEngine;
|
||||||
|
|
|
@ -49,8 +49,9 @@ using namespace Ogre;
|
||||||
|
|
||||||
namespace MWRender {
|
namespace MWRender {
|
||||||
|
|
||||||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
||||||
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,MWWorld::Fallback* fallback)
|
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,
|
||||||
|
MWWorld::Fallback* fallback)
|
||||||
: mRendering(_rend)
|
: mRendering(_rend)
|
||||||
, mFallback(fallback)
|
, mFallback(fallback)
|
||||||
, mObjects(mRendering, mFallback)
|
, mObjects(mRendering, mFallback)
|
||||||
|
@ -155,7 +156,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const
|
||||||
mObjects.setRootNode(mRootNode);
|
mObjects.setRootNode(mRootNode);
|
||||||
mActors.setRootNode(mRootNode);
|
mActors.setRootNode(mRootNode);
|
||||||
|
|
||||||
mPlayer = new MWRender::Player(mRendering.getCamera());
|
mCamera = new MWRender::Camera(mRendering.getCamera());
|
||||||
|
|
||||||
mShadows = new Shadows(&mRendering);
|
mShadows = new Shadows(&mRendering);
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ RenderingManager::~RenderingManager ()
|
||||||
mRendering.removeWindowEventListener(this);
|
mRendering.removeWindowEventListener(this);
|
||||||
|
|
||||||
delete mPlayerAnimation;
|
delete mPlayerAnimation;
|
||||||
delete mPlayer;
|
delete mCamera;
|
||||||
delete mSkyManager;
|
delete mSkyManager;
|
||||||
delete mDebugging;
|
delete mDebugging;
|
||||||
delete mShadows;
|
delete mShadows;
|
||||||
|
@ -269,8 +270,8 @@ void RenderingManager::rotateObject(const MWWorld::Ptr &ptr)
|
||||||
{
|
{
|
||||||
Ogre::Vector3 rot(ptr.getRefData().getPosition().rot);
|
Ogre::Vector3 rot(ptr.getRefData().getPosition().rot);
|
||||||
|
|
||||||
if(ptr.getRefData().getHandle() == mPlayer->getHandle())
|
if(ptr.getRefData().getHandle() == mCamera->getHandle())
|
||||||
mPlayer->rotateCamera(rot, false);
|
mCamera->rotateCamera(rot, false);
|
||||||
|
|
||||||
Ogre::Quaternion newo = Ogre::Quaternion(Ogre::Radian(-rot.z), Ogre::Vector3::UNIT_Z);
|
Ogre::Quaternion newo = Ogre::Quaternion(Ogre::Radian(-rot.z), Ogre::Vector3::UNIT_Z);
|
||||||
if(!MWWorld::Class::get(ptr).isActor())
|
if(!MWWorld::Class::get(ptr).isActor())
|
||||||
|
@ -300,7 +301,7 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
MWWorld::Ptr player = world->getPlayer().getPlayer();
|
||||||
|
|
||||||
int blind = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude;
|
int blind = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude;
|
||||||
mRendering.getFader()->setFactor(1.f-(blind / 100.f));
|
mRendering.getFader()->setFactor(1.f-(blind / 100.f));
|
||||||
|
@ -313,16 +314,16 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
Ogre::Vector3 playerPos(_playerPos[0], _playerPos[1], _playerPos[2]);
|
Ogre::Vector3 playerPos(_playerPos[0], _playerPos[1], _playerPos[2]);
|
||||||
|
|
||||||
Ogre::Vector3 orig, dest;
|
Ogre::Vector3 orig, dest;
|
||||||
mPlayer->setCameraDistance();
|
mCamera->setCameraDistance();
|
||||||
if (!mPlayer->getPosition(orig, dest)) {
|
if(!mCamera->getPosition(orig, dest))
|
||||||
orig.z += mPlayer->getHeight() * mRootNode->getScale().z;
|
{
|
||||||
|
orig.z += mCamera->getHeight() * mRootNode->getScale().z;
|
||||||
|
|
||||||
btVector3 btOrig(orig.x, orig.y, orig.z);
|
btVector3 btOrig(orig.x, orig.y, orig.z);
|
||||||
btVector3 btDest(dest.x, dest.y, dest.z);
|
btVector3 btDest(dest.x, dest.y, dest.z);
|
||||||
std::pair<std::string, float> test =
|
std::pair<std::string,float> test = mPhysicsEngine->rayTest(btOrig, btDest);
|
||||||
mPhysicsEngine->rayTest(btOrig, btDest);
|
|
||||||
if (!test.first.empty()) {
|
if (!test.first.empty()) {
|
||||||
mPlayer->setCameraDistance(test.second * orig.distance(dest), false, false);
|
mCamera->setCameraDistance(test.second * orig.distance(dest), false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,14 +337,12 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
|
|
||||||
Ogre::Vector3 cam = mRendering.getCamera()->getRealPosition();
|
Ogre::Vector3 cam = mRendering.getCamera()->getRealPosition();
|
||||||
|
|
||||||
applyFog(world->isUnderwater (world->getPlayer().getPlayer().getCell(), cam));
|
applyFog(world->isUnderwater(player.getCell(), cam));
|
||||||
|
|
||||||
if(paused)
|
if(paused)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
mPlayer->update(duration);
|
mCamera->update(duration);
|
||||||
|
|
||||||
mActors.update (duration);
|
mActors.update (duration);
|
||||||
mObjects.update (duration);
|
mObjects.update (duration);
|
||||||
|
@ -354,18 +353,11 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
mSkyManager->setGlare(mOcclusionQuery->getSunVisibility());
|
mSkyManager->setGlare(mOcclusionQuery->getSunVisibility());
|
||||||
|
|
||||||
Ogre::SceneNode *node = data.getBaseNode();
|
Ogre::SceneNode *node = data.getBaseNode();
|
||||||
//Ogre::Quaternion orient =
|
Ogre::Quaternion orient = node->_getDerivedOrientation();
|
||||||
//node->convertLocalToWorldOrientation(node->_getDerivedOrientation());
|
|
||||||
Ogre::Quaternion orient =
|
|
||||||
node->_getDerivedOrientation();
|
|
||||||
|
|
||||||
mLocalMap->updatePlayer(playerPos, orient);
|
mLocalMap->updatePlayer(playerPos, orient);
|
||||||
|
|
||||||
mWater->updateUnderwater(
|
mWater->updateUnderwater(world->isUnderwater(player.getCell(), cam));
|
||||||
world->isUnderwater(
|
|
||||||
world->getPlayer().getPlayer().getCell(),
|
|
||||||
cam)
|
|
||||||
);
|
|
||||||
|
|
||||||
mWater->update(duration, playerPos);
|
mWater->update(duration, playerPos);
|
||||||
}
|
}
|
||||||
|
@ -862,7 +854,7 @@ void RenderingManager::getTriangleBatchCount(unsigned int &triangles, unsigned i
|
||||||
void RenderingManager::setupPlayer(const MWWorld::Ptr &ptr)
|
void RenderingManager::setupPlayer(const MWWorld::Ptr &ptr)
|
||||||
{
|
{
|
||||||
ptr.getRefData().setBaseNode(mRendering.getScene()->getSceneNode("player"));
|
ptr.getRefData().setBaseNode(mRendering.getScene()->getSceneNode("player"));
|
||||||
mPlayer->attachTo(ptr);
|
mCamera->attachTo(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
|
void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
|
||||||
|
@ -881,27 +873,27 @@ void RenderingManager::renderPlayer(const MWWorld::Ptr &ptr)
|
||||||
MWWorld::Class::get(ptr).getInventoryStore(ptr),
|
MWWorld::Class::get(ptr).getInventoryStore(ptr),
|
||||||
RV_Actors);
|
RV_Actors);
|
||||||
}
|
}
|
||||||
mPlayer->setAnimation(mPlayerAnimation);
|
mCamera->setAnimation(mPlayerAnimation);
|
||||||
mWater->removeEmitter(ptr);
|
mWater->removeEmitter(ptr);
|
||||||
mWater->addEmitter(ptr);
|
mWater->addEmitter(ptr);
|
||||||
// apply race height
|
// apply race height
|
||||||
MWBase::Environment::get().getWorld()->scaleObject(ptr, 1.f);
|
MWBase::Environment::get().getWorld()->scaleObject(ptr, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderingManager::getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw)
|
void RenderingManager::getCameraData(Ogre::Vector3 &eyepos, float &pitch, float &yaw)
|
||||||
{
|
{
|
||||||
eyepos = mPlayer->getPosition();
|
eyepos = mCamera->getPosition();
|
||||||
eyepos.z += mPlayer->getHeight();
|
eyepos.z += mCamera->getHeight();
|
||||||
mPlayer->getSightAngles(pitch, yaw);
|
mCamera->getSightAngles(pitch, yaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderingManager::vanityRotateCamera(float* rot)
|
bool RenderingManager::vanityRotateCamera(const float *rot)
|
||||||
{
|
{
|
||||||
if(!mPlayer->isVanityOrPreviewModeEnabled())
|
if(!mCamera->isVanityOrPreviewModeEnabled())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Ogre::Vector3 vRot(rot);
|
Ogre::Vector3 vRot(rot);
|
||||||
mPlayer->rotateCamera(vRot, true);
|
mCamera->rotateCamera(vRot, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "objects.hpp"
|
#include "objects.hpp"
|
||||||
#include "actors.hpp"
|
#include "actors.hpp"
|
||||||
#include "player.hpp"
|
#include "camera.hpp"
|
||||||
#include "occlusionquery.hpp"
|
#include "occlusionquery.hpp"
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
|
@ -50,47 +50,42 @@ namespace MWRender
|
||||||
class VideoPlayer;
|
class VideoPlayer;
|
||||||
class Animation;
|
class Animation;
|
||||||
|
|
||||||
class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener, public Ogre::RenderTargetListener {
|
class RenderingManager: private RenderingInterface, public Ogre::WindowEventListener, public Ogre::RenderTargetListener
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
virtual MWRender::Objects& getObjects();
|
virtual MWRender::Objects& getObjects();
|
||||||
virtual MWRender::Actors& getActors();
|
virtual MWRender::Actors& getActors();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
RenderingManager(OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir,
|
||||||
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,MWWorld::Fallback* fallback);
|
const boost::filesystem::path& cacheDir, OEngine::Physic::PhysicEngine* engine,
|
||||||
|
MWWorld::Fallback* fallback);
|
||||||
virtual ~RenderingManager();
|
virtual ~RenderingManager();
|
||||||
|
|
||||||
void togglePOV() {
|
void togglePOV()
|
||||||
mPlayer->toggleViewMode();
|
{ mCamera->toggleViewMode(); }
|
||||||
|
|
||||||
|
void togglePreviewMode(bool enable)
|
||||||
|
{ mCamera->togglePreviewMode(enable); }
|
||||||
|
|
||||||
|
bool toggleVanityMode(bool enable)
|
||||||
|
{ return mCamera->toggleVanityMode(enable); }
|
||||||
|
|
||||||
|
void allowVanityMode(bool allow)
|
||||||
|
{ mCamera->allowVanityMode(allow); }
|
||||||
|
|
||||||
|
void togglePlayerLooking(bool enable)
|
||||||
|
{ mCamera->togglePlayerLooking(enable); }
|
||||||
|
|
||||||
|
void changeVanityModeScale(float factor)
|
||||||
|
{
|
||||||
|
if(mCamera->isVanityOrPreviewModeEnabled())
|
||||||
|
mCamera->setCameraDistance(-factor/120.f*10, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void togglePreviewMode(bool enable) {
|
bool vanityRotateCamera(const float *rot);
|
||||||
mPlayer->togglePreviewMode(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool toggleVanityMode(bool enable) {
|
void getCameraData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
|
||||||
return mPlayer->toggleVanityMode(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void allowVanityMode(bool allow) {
|
|
||||||
mPlayer->allowVanityMode(allow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void togglePlayerLooking(bool enable) {
|
|
||||||
mPlayer->togglePlayerLooking(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeVanityModeScale(float factor) {
|
|
||||||
if (mPlayer->isVanityOrPreviewModeEnabled())
|
|
||||||
mPlayer->setCameraDistance(-factor/120.f*10, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool vanityRotateCamera(float* rot);
|
|
||||||
|
|
||||||
void getPlayerData(Ogre::Vector3 &eyepos, float &pitch, float &yaw);
|
|
||||||
|
|
||||||
void setupPlayer(const MWWorld::Ptr &ptr);
|
void setupPlayer(const MWWorld::Ptr &ptr);
|
||||||
void renderPlayer(const MWWorld::Ptr &ptr);
|
void renderPlayer(const MWWorld::Ptr &ptr);
|
||||||
|
@ -204,12 +199,11 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
||||||
void stopVideo();
|
void stopVideo();
|
||||||
void frameStarted(float dt);
|
void frameStarted(float dt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void windowResized(Ogre::RenderWindow* rw);
|
virtual void windowResized(Ogre::RenderWindow* rw);
|
||||||
virtual void windowClosed(Ogre::RenderWindow* rw);
|
virtual void windowClosed(Ogre::RenderWindow* rw);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sh::Factory* mFactory;
|
sh::Factory* mFactory;
|
||||||
|
|
||||||
void setAmbientMode();
|
void setAmbientMode();
|
||||||
|
@ -254,7 +248,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList
|
||||||
|
|
||||||
OEngine::Physic::PhysicEngine* mPhysicsEngine;
|
OEngine::Physic::PhysicEngine* mPhysicsEngine;
|
||||||
|
|
||||||
MWRender::Player *mPlayer;
|
MWRender::Camera *mCamera;
|
||||||
|
|
||||||
MWRender::Debugging *mDebugging;
|
MWRender::Debugging *mDebugging;
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ unsigned int Moon::getPhaseInt() const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkyManager::SkyManager (SceneNode* root, Camera* pCamera)
|
SkyManager::SkyManager(Ogre::SceneNode *root, Ogre::Camera *pCamera)
|
||||||
: mHour(0.0f)
|
: mHour(0.0f)
|
||||||
, mDay(0)
|
, mDay(0)
|
||||||
, mMonth(0)
|
, mMonth(0)
|
||||||
|
|
|
@ -260,14 +260,13 @@ namespace MWWorld
|
||||||
std::pair<float, std::string> PhysicsSystem::getFacedHandle (MWWorld::World& world, float queryDistance)
|
std::pair<float, std::string> PhysicsSystem::getFacedHandle (MWWorld::World& world, float queryDistance)
|
||||||
{
|
{
|
||||||
btVector3 dir(0, 1, 0);
|
btVector3 dir(0, 1, 0);
|
||||||
dir = dir.rotate(btVector3(1, 0, 0), mPlayerData.pitch);
|
dir = dir.rotate(btVector3(1, 0, 0), mCameraData.pitch);
|
||||||
dir = dir.rotate(btVector3(0, 0, 1), mPlayerData.yaw);
|
dir = dir.rotate(btVector3(0, 0, 1), mCameraData.yaw);
|
||||||
dir.setX(-dir.x());
|
dir.setX(-dir.x());
|
||||||
|
|
||||||
btVector3 origin(
|
btVector3 origin(mCameraData.eyepos.x,
|
||||||
mPlayerData.eyepos.x,
|
mCameraData.eyepos.y,
|
||||||
mPlayerData.eyepos.y,
|
mCameraData.eyepos.z);
|
||||||
mPlayerData.eyepos.z);
|
|
||||||
origin += dir * 5;
|
origin += dir * 5;
|
||||||
|
|
||||||
btVector3 dest = origin + dir * queryDistance;
|
btVector3 dest = origin + dir * queryDistance;
|
||||||
|
@ -280,14 +279,13 @@ namespace MWWorld
|
||||||
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedHandles (float queryDistance)
|
std::vector < std::pair <float, std::string> > PhysicsSystem::getFacedHandles (float queryDistance)
|
||||||
{
|
{
|
||||||
btVector3 dir(0, 1, 0);
|
btVector3 dir(0, 1, 0);
|
||||||
dir = dir.rotate(btVector3(1, 0, 0), mPlayerData.pitch);
|
dir = dir.rotate(btVector3(1, 0, 0), mCameraData.pitch);
|
||||||
dir = dir.rotate(btVector3(0, 0, 1), mPlayerData.yaw);
|
dir = dir.rotate(btVector3(0, 0, 1), mCameraData.yaw);
|
||||||
dir.setX(-dir.x());
|
dir.setX(-dir.x());
|
||||||
|
|
||||||
btVector3 origin(
|
btVector3 origin(mCameraData.eyepos.x,
|
||||||
mPlayerData.eyepos.x,
|
mCameraData.eyepos.y,
|
||||||
mPlayerData.eyepos.y,
|
mCameraData.eyepos.z);
|
||||||
mPlayerData.eyepos.z);
|
|
||||||
origin += dir * 5;
|
origin += dir * 5;
|
||||||
|
|
||||||
btVector3 dest = origin + dir * queryDistance;
|
btVector3 dest = origin + dir * queryDistance;
|
||||||
|
@ -552,10 +550,10 @@ namespace MWWorld
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsSystem::updatePlayerData(Ogre::Vector3 &eyepos, float pitch, float yaw)
|
void PhysicsSystem::updateCameraData(const Ogre::Vector3 &eyepos, float pitch, float yaw)
|
||||||
{
|
{
|
||||||
mPlayerData.eyepos = eyepos;
|
mCameraData.eyepos = eyepos;
|
||||||
mPlayerData.pitch = pitch;
|
mCameraData.pitch = pitch;
|
||||||
mPlayerData.yaw = yaw;
|
mCameraData.yaw = yaw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,13 +77,13 @@ 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);
|
void updateCameraData(const Ogre::Vector3 &eyepos, float pitch, float yaw);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct {
|
struct {
|
||||||
Ogre::Vector3 eyepos;
|
Ogre::Vector3 eyepos;
|
||||||
float pitch, yaw;
|
float pitch, yaw;
|
||||||
} mPlayerData;
|
} mCameraData;
|
||||||
|
|
||||||
OEngine::Render::OgreRenderer &mRender;
|
OEngine::Render::OgreRenderer &mRender;
|
||||||
OEngine::Physic::PhysicEngine* mEngine;
|
OEngine::Physic::PhysicEngine* mEngine;
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "../mwmechanics/movement.hpp"
|
#include "../mwmechanics/movement.hpp"
|
||||||
|
|
||||||
#include "../mwrender/sky.hpp"
|
#include "../mwrender/sky.hpp"
|
||||||
#include "../mwrender/player.hpp"
|
|
||||||
|
|
||||||
#include "../mwclass/door.hpp"
|
#include "../mwclass/door.hpp"
|
||||||
|
|
||||||
|
@ -1146,8 +1145,8 @@ namespace MWWorld
|
||||||
|
|
||||||
float pitch, yaw;
|
float pitch, yaw;
|
||||||
Ogre::Vector3 eyepos;
|
Ogre::Vector3 eyepos;
|
||||||
mRendering->getPlayerData(eyepos, pitch, yaw);
|
mRendering->getCameraData(eyepos, pitch, yaw);
|
||||||
mPhysics->updatePlayerData(eyepos, pitch, yaw);
|
mPhysics->updateCameraData(eyepos, pitch, yaw);
|
||||||
|
|
||||||
performUpdateSceneQueries ();
|
performUpdateSceneQueries ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue