1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 15:39:02 +00:00
OpenMW/apps/openmw/mwrender/player.hpp

115 lines
2.9 KiB
C++
Raw Normal View History

#ifndef GAME_MWRENDER_PLAYER_H
#define GAME_MWRENDER_PLAYER_H
#include <string>
2011-02-10 11:56:19 +00:00
namespace Ogre
2012-08-12 14:35:35 +00:00
{
class Vector3;
class Camera;
class SceneNode;
}
namespace MWWorld
{
class Ptr;
}
namespace MWRender
{
2012-08-14 16:33:29 +00:00
class NpcAnimation;
/// \brief Player character rendering and camera control
class Player
{
2012-08-13 22:36:18 +00:00
struct CamData {
float pitch, yaw, offset;
};
Ogre::Camera *mCamera;
2012-08-12 11:50:37 +00:00
Ogre::SceneNode *mPlayerNode;
Ogre::SceneNode *mCameraNode;
2012-08-14 16:33:29 +00:00
NpcAnimation *mAnimation;
bool mFirstPersonView;
2012-08-12 11:50:37 +00:00
bool mPreviewMode;
bool mFreeLook;
2012-08-12 11:50:37 +00:00
2012-08-14 10:37:48 +00:00
struct {
bool enabled, allowed, forced;
} mVanity;
float mHeight, mCameraDistance;
2012-08-13 22:36:18 +00:00
CamData mMainCam, mPreviewCam;
2012-08-12 14:35:35 +00:00
bool mDistanceAdjusted;
/// Updates sound manager listener data
void updateListener();
void setLowHeight(bool low = true);
public:
Player (Ogre::Camera *camera, Ogre::SceneNode* mNode);
2012-09-13 17:03:31 +00:00
~Player();
/// Set where the player is looking at. Uses Morrowind (euler) angles
2012-08-11 09:23:54 +00:00
/// \param rot Rotation angles in radians
/// \return true if player object needs to bo rotated physically
2012-08-12 11:50:37 +00:00
bool rotate(const Ogre::Vector3 &rot, bool adjust);
void rotateCamera(const Ogre::Vector3 &rot, bool adjust);
float getYaw();
void setYaw(float angle);
float getPitch();
void setPitch(float angle);
void compensateYaw(float diff);
std::string getHandle() const;
/// Attach camera to object
/// \note there is no protection from attaching the same camera to
/// several different objects
void attachTo(const MWWorld::Ptr &);
2011-02-10 11:56:19 +00:00
2012-08-12 11:50:37 +00:00
void toggleViewMode();
2012-08-14 10:37:48 +00:00
bool toggleVanityMode(bool enable, bool force = false);
void allowVanityMode(bool allow);
2012-08-12 11:50:37 +00:00
2012-08-13 22:36:18 +00:00
void togglePreviewMode(bool enable);
2012-08-12 11:50:37 +00:00
void update(float duration);
2012-08-14 10:37:48 +00:00
/// Set camera distance for current mode. Don't work on 1st person view.
/// \param adjust Indicates should distance be adjusted or set.
/// \param override If true new distance will be used as default.
/// If false, default distance can be restored with setCameraDistance().
void setCameraDistance(float dist, bool adjust = false, bool override = true);
/// Restore default camera distance for current mode.
void setCameraDistance();
2012-08-14 16:33:29 +00:00
2012-08-15 11:17:35 +00:00
void setAnimation(MWRender::NpcAnimation *anim);
2012-08-14 16:33:29 +00:00
void setHeight(float height);
float getHeight();
/// 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);
void togglePlayerLooking(bool enable);
};
}
#endif