1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 03:54:40 +00:00
OpenMW/apps/openmw/mwrender/camera.hpp

127 lines
3.2 KiB
C++
Raw Normal View History

2013-04-29 12:50:40 +00:00
#ifndef GAME_MWRENDER_CAMERA_H
#define GAME_MWRENDER_CAMERA_H
#include <string>
2011-02-10 11:56:19 +00:00
#include "../mwworld/ptr.hpp"
namespace Ogre
2012-08-12 14:35:35 +00:00
{
class Vector3;
class Camera;
class SceneNode;
}
namespace MWRender
{
2012-08-14 16:33:29 +00:00
class NpcAnimation;
2013-04-29 12:50:40 +00:00
/// \brief Camera control
class Camera
{
2012-08-13 22:36:18 +00:00
struct CamData {
float pitch, yaw, offset;
};
MWWorld::Ptr mTrackingPtr;
2012-08-12 11:50:37 +00:00
Ogre::Camera *mCamera;
2012-08-12 11:50:37 +00:00
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;
float mNearest;
float mFurthest;
bool mIsNearest;
bool mIsFurthest;
2012-08-12 11:50:37 +00:00
2012-08-14 10:37:48 +00:00
struct {
2013-04-27 08:24:36 +00:00
bool enabled, allowed;
2012-08-14 10:37:48 +00:00
} 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;
bool mVanityToggleQueued;
bool mViewModeToggleQueued;
/// Updates sound manager listener data
void updateListener();
public:
2013-04-29 12:50:40 +00:00
Camera(Ogre::Camera *camera);
~Camera();
2013-05-17 20:53:43 +00:00
/// Reset to defaults
void reset();
2013-04-29 12:50:40 +00:00
/// Set where the camera is looking at. Uses Morrowind (euler) angles
2012-08-11 09:23:54 +00:00
/// \param rot Rotation angles in radians
void rotateCamera(const Ogre::Vector3 &rot, bool adjust);
float getYaw();
void setYaw(float angle);
float getPitch();
void setPitch(float angle);
2013-04-28 08:14:58 +00:00
const std::string &getHandle() const;
/// Attach camera to object
void attachTo(const MWWorld::Ptr &);
2011-02-10 11:56:19 +00:00
/// @param Force view mode switch, even if currently not allowed by the animation.
void toggleViewMode(bool force=false);
2012-08-12 11:50:37 +00:00
2013-04-27 08:24:36 +00:00
bool toggleVanityMode(bool enable);
2012-08-14 10:37:48 +00:00
void allowVanityMode(bool allow);
2012-08-12 11:50:37 +00:00
/// @note this may be ignored if an important animation is currently playing
2012-08-13 22:36:18 +00:00
void togglePreviewMode(bool enable);
/// \brief Lowers the camera for sneak.
/// As animation is tied to the camera, this needs
/// to be set each frame after the animation is
/// applied.
void setSneakOffset(float offset);
bool isFirstPerson() const
{ return !(mVanity.enabled || mPreviewMode || !mFirstPersonView); }
void processViewChange();
void update(float duration, bool paused=false);
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
float getCameraDistance() const;
2013-01-17 23:48:09 +00:00
void setAnimation(NpcAnimation *anim);
2012-08-14 16:33:29 +00:00
2013-07-23 08:37:41 +00:00
/// Stores focal and camera world positions in passed arguments
void getPosition(Ogre::Vector3 &focal, Ogre::Vector3 &camera);
void togglePlayerLooking(bool enable);
bool isVanityOrPreviewModeEnabled();
bool isNearest();
bool isFurthest();
};
}
#endif