2010-06-21 21:39:59 +00:00
|
|
|
#ifndef _MWRENDER_PLAYERPOS_H
|
|
|
|
#define _MWRENDER_PLAYERPOS_H
|
|
|
|
|
|
|
|
#include "OgreCamera.h"
|
|
|
|
|
2010-07-05 10:09:04 +00:00
|
|
|
#include <components/esm_store/cell_store.hpp>
|
|
|
|
|
|
|
|
#include "../mwworld/refdata.hpp"
|
2010-07-26 10:59:50 +00:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2010-07-05 10:09:04 +00:00
|
|
|
|
2010-08-21 10:31:04 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class World;
|
|
|
|
}
|
|
|
|
|
2010-06-21 21:39:59 +00:00
|
|
|
namespace MWRender
|
|
|
|
{
|
|
|
|
// This class keeps track of the player position. It takes care of
|
|
|
|
// camera movement, sound listener updates, and collision handling
|
|
|
|
// (to be done).
|
|
|
|
class PlayerPos
|
|
|
|
{
|
2010-07-05 10:09:04 +00:00
|
|
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> mPlayer;
|
2010-07-26 10:59:50 +00:00
|
|
|
MWWorld::Ptr::CellStore *mCellStore;
|
2010-06-21 21:39:59 +00:00
|
|
|
Ogre::Camera *camera;
|
2010-08-21 10:31:04 +00:00
|
|
|
MWWorld::World& mWorld;
|
2010-09-15 10:22:06 +00:00
|
|
|
std::string mName;
|
2010-09-15 12:33:02 +00:00
|
|
|
bool mMale;
|
|
|
|
std::string mRace;
|
|
|
|
std::string mBirthsign;
|
|
|
|
ESM::Class *mClass;
|
2010-06-21 21:39:59 +00:00
|
|
|
|
|
|
|
public:
|
2010-09-15 12:33:02 +00:00
|
|
|
|
|
|
|
PlayerPos(Ogre::Camera *cam, const ESM::NPC *player, MWWorld::World& world);
|
|
|
|
|
|
|
|
~PlayerPos();
|
2010-06-21 21:39:59 +00:00
|
|
|
|
|
|
|
// Set the player position. Uses Morrowind coordinates.
|
2010-08-21 10:31:04 +00:00
|
|
|
void setPos(float _x, float _y, float _z, bool updateCamera = false);
|
2010-08-20 15:14:07 +00:00
|
|
|
|
2010-07-26 10:59:50 +00:00
|
|
|
void setCell (MWWorld::Ptr::CellStore *cellStore)
|
|
|
|
{
|
|
|
|
mCellStore = cellStore;
|
|
|
|
}
|
2010-06-21 21:39:59 +00:00
|
|
|
|
2010-06-22 08:15:22 +00:00
|
|
|
Ogre::Camera *getCamera() { return camera; }
|
|
|
|
|
2010-06-21 21:39:59 +00:00
|
|
|
// Move the player relative to her own position and
|
|
|
|
// orientation. After the call, the new position is returned.
|
|
|
|
void moveRel(float &relX, float &relY, float &relZ)
|
|
|
|
{
|
|
|
|
using namespace Ogre;
|
|
|
|
|
|
|
|
// Move camera relative to its own direction
|
|
|
|
camera->moveRelative(Vector3(relX,0,relZ));
|
|
|
|
|
|
|
|
// Up/down movement is always done relative the world axis.
|
|
|
|
camera->move(Vector3(0,relY,0));
|
|
|
|
|
|
|
|
// Get new camera position, converting back to MW coords.
|
|
|
|
Vector3 pos = camera->getPosition();
|
|
|
|
relX = pos[0];
|
2010-08-22 19:30:48 +00:00
|
|
|
relY = -pos[2];
|
|
|
|
relZ = pos[1];
|
2010-06-21 21:39:59 +00:00
|
|
|
|
|
|
|
// TODO: Collision detection must be used to find the REAL new
|
|
|
|
// position.
|
|
|
|
|
|
|
|
// Set the position
|
|
|
|
setPos(relX, relY, relZ);
|
|
|
|
}
|
2010-08-20 15:14:07 +00:00
|
|
|
|
2010-07-26 11:09:44 +00:00
|
|
|
MWWorld::Ptr getPlayer()
|
2010-07-05 10:09:04 +00:00
|
|
|
{
|
2010-07-26 11:09:44 +00:00
|
|
|
MWWorld::Ptr ptr (&mPlayer, mCellStore);
|
|
|
|
return ptr;
|
2010-07-05 10:09:04 +00:00
|
|
|
}
|
2010-09-15 10:22:06 +00:00
|
|
|
|
|
|
|
void setName (const std::string& name)
|
|
|
|
{
|
|
|
|
mName = name;
|
|
|
|
}
|
|
|
|
|
2010-09-15 12:33:02 +00:00
|
|
|
void setGender (bool male)
|
|
|
|
{
|
|
|
|
mMale = male;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setRace (const std::string& race)
|
|
|
|
{
|
|
|
|
mRace = race;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setBirthsign (const std::string& birthsign)
|
|
|
|
{
|
|
|
|
mBirthsign = birthsign;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setClass (const ESM::Class& class_);
|
|
|
|
|
2010-09-15 10:22:06 +00:00
|
|
|
std::string getName() const
|
|
|
|
{
|
|
|
|
return mName;
|
|
|
|
}
|
2010-09-15 12:33:02 +00:00
|
|
|
|
|
|
|
bool isMale() const
|
|
|
|
{
|
|
|
|
return mMale;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getRace() const
|
|
|
|
{
|
|
|
|
return mRace;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getBirthsign() const
|
|
|
|
{
|
|
|
|
return mBirthsign;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ESM::Class& getClass() const
|
|
|
|
{
|
|
|
|
return *mClass;
|
|
|
|
}
|
2010-06-21 21:39:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|