2015-07-26 21:39:49 +00:00
|
|
|
#ifndef CCAMERA_H
|
|
|
|
#define CCAMERA_H
|
|
|
|
|
2015-09-27 22:02:53 +00:00
|
|
|
#include "CFrustumPlanes.h"
|
2015-07-26 21:39:49 +00:00
|
|
|
#include <Common/CAABox.h>
|
|
|
|
#include <Common/CMatrix4f.h>
|
|
|
|
#include <Common/CRay.h>
|
|
|
|
#include <Common/CVector2i.h>
|
|
|
|
#include <Common/CVector3f.h>
|
|
|
|
#include <Common/types.h>
|
|
|
|
#include <Common/EKeyInputs.h>
|
|
|
|
#include <Common/EMouseInputs.h>
|
|
|
|
|
|
|
|
enum ECameraMoveMode
|
|
|
|
{
|
|
|
|
eFreeCamera, eOrbitCamera
|
|
|
|
};
|
|
|
|
|
|
|
|
class CCamera
|
|
|
|
{
|
|
|
|
ECameraMoveMode mMode;
|
|
|
|
CVector3f mPosition;
|
|
|
|
CVector3f mDirection;
|
2015-11-25 21:37:34 +00:00
|
|
|
CVector3f mRightVector;
|
|
|
|
CVector3f mUpVector;
|
2015-07-26 21:39:49 +00:00
|
|
|
float mAspectRatio;
|
|
|
|
|
|
|
|
float mYaw;
|
|
|
|
float mPitch;
|
|
|
|
CVector3f mOrbitTarget;
|
2015-11-26 07:47:02 +00:00
|
|
|
float mOrbitDistance;
|
2015-07-26 21:39:49 +00:00
|
|
|
float mMoveSpeed;
|
|
|
|
float mLookSpeed;
|
|
|
|
|
|
|
|
CMatrix4f mCachedViewMatrix;
|
|
|
|
CMatrix4f mCachedProjectionMatrix;
|
2015-09-27 22:02:53 +00:00
|
|
|
CFrustumPlanes mCachedFrustumPlanes;
|
2015-07-26 21:39:49 +00:00
|
|
|
bool mViewOutdated;
|
|
|
|
bool mProjectionOutdated;
|
2015-09-27 22:02:53 +00:00
|
|
|
bool mFrustumPlanesOutdated;
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
CCamera();
|
|
|
|
CCamera(CVector3f Position, CVector3f Target);
|
|
|
|
|
|
|
|
void Pan(float XAmount, float YAmount);
|
|
|
|
void Rotate(float XAmount, float YAmount);
|
|
|
|
void Zoom(float Amount);
|
|
|
|
void Snap(CVector3f Position);
|
|
|
|
void ProcessKeyInput(EKeyInputs KeyFlags, double DeltaTime);
|
|
|
|
void ProcessMouseInput(EKeyInputs KeyFlags, EMouseInputs MouseFlags, float XMovement, float YMovement);
|
|
|
|
CRay CastRay(CVector2f DeviceCoords);
|
|
|
|
void LoadMatrices();
|
|
|
|
|
2015-11-26 07:47:02 +00:00
|
|
|
void SetMoveMode(ECameraMoveMode Mode);
|
|
|
|
void SetOrbit(const CVector3f& OrbitTarget, float Distance);
|
|
|
|
void SetOrbit(const CAABox& OrbitTarget, float DistScale = 2.5f);
|
|
|
|
void SetOrbitDistance(float Distance);
|
|
|
|
|
2015-07-26 21:39:49 +00:00
|
|
|
// Getters
|
|
|
|
CVector3f Position() const;
|
2015-09-01 17:05:48 +00:00
|
|
|
CVector3f Direction() const;
|
2015-11-25 21:37:34 +00:00
|
|
|
CVector3f UpVector() const;
|
|
|
|
CVector3f RightVector() const;
|
2015-09-01 17:05:48 +00:00
|
|
|
float Yaw() const;
|
|
|
|
float Pitch() const;
|
|
|
|
float FieldOfView() const;
|
2015-11-26 07:47:02 +00:00
|
|
|
ECameraMoveMode MoveMode() const;
|
2015-07-26 21:39:49 +00:00
|
|
|
const CMatrix4f& ViewMatrix();
|
|
|
|
const CMatrix4f& ProjectionMatrix();
|
2015-09-27 22:02:53 +00:00
|
|
|
const CFrustumPlanes& FrustumPlanes();
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
// Setters
|
|
|
|
void SetPosition(CVector3f Position);
|
|
|
|
void SetDirection(CVector3f Direction);
|
|
|
|
void SetYaw(float Yaw);
|
|
|
|
void SetPitch(float Pitch);
|
|
|
|
void SetMoveSpeed(float MoveSpeed);
|
|
|
|
void SetLookSpeed(float LookSpeed);
|
|
|
|
void SetAspectRatio(float AspectRatio);
|
|
|
|
|
|
|
|
// Private
|
|
|
|
private:
|
2015-11-26 07:47:02 +00:00
|
|
|
void Update();
|
|
|
|
void UpdateView();
|
|
|
|
void UpdateProjection();
|
|
|
|
void UpdateFrustum();
|
2015-07-26 21:39:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CCAMERA_H
|