1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#pragma once
#include "icameraview.h"
#include "math/Vector3.h"
#include "math/Matrix4.h"
#include "generic/callback.h"
#include "registry/CachedKey.h"
namespace camera
{
class Camera :
public ICameraView
{
static Vector3 _prevOrigin;
static Vector3 _prevAngles;
Vector3 _origin;
Vector3 _angles;
std::function<void(bool)> _requestRedraw;
float _fieldOfView;
float _farClipPlane;
bool _farClipPlaneEnabled;
int _width;
int _height;
Vector3 _forward, _right; // move matrix (TTimo: used to have up but it was not updated)
Vector3 _vup, _vpn, _vright; // view matrix (taken from the modelview matrix)
Matrix4 _projection;
Matrix4 _modelview;
render::IRenderView& _view;
registry::CachedKey<bool> _dragSelectionEnabled;
public:
Camera(render::IRenderView& view, const std::function<void(bool)>& requestRedraw);
Camera(const Camera& other) = delete;
Camera& operator=(const Camera& other) = delete;
void updateVectors();
void updateModelview();
float getFarClipPlaneDistance() const override;
void setFarClipPlaneDistance(float distance) override;
bool getFarClipPlaneEnabled() const override;
void setFarClipPlaneEnabled(bool enabled) override;
void freemoveUpdateAxes();
void moveUpdateAxes();
const Vector3& getCameraOrigin() const override;
void setCameraOrigin(const Vector3& newOrigin) override;
const Vector3& getCameraAngles() const override;
void setCameraAngles(const Vector3& newAngles) override;
void setOriginAndAngles(const Vector3& newOrigin, const Vector3& newAngles) override;
const Vector3& getRightVector() const override;
const Vector3& getUpVector() const override;
const Vector3& getForwardVector() const override;
const Matrix4& getModelView() const override;
const Matrix4& getProjection() const override;
int getDeviceWidth() const override;
int getDeviceHeight() const override;
void setDeviceDimensions(int width, int height) override;
SelectionTestPtr createSelectionTestForPoint(const Vector2& point) override;
const VolumeTest& getVolumeTest() const override;
bool supportsDragSelections() override;
void queueDraw() override;
void forceRedraw() override;
private:
// Set the origin without triggering any nofifications
void doSetOrigin(const Vector3& origin, bool updateModelView);
void doSetAngles(const Vector3& angles, bool updateModelView);
void updateProjection();
};
} // namespace
|