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