| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "imodule.h" |
| 4 |
#include "iinteractiveview.h" |
| 5 |
#include "irenderview.h" |
| 6 |
|
| 7 |
template<typename Element>class BasicVector3; |
| 8 |
typedef BasicVector3<double> Vector3; |
| 9 |
class Matrix4; |
| 10 |
|
| 11 |
namespace camera |
| 12 |
{ |
| 13 |
|
| 14 |
enum |
| 15 |
{ |
| 16 |
CAMERA_PITCH = 0, // up / down |
| 17 |
CAMERA_YAW = 1, // left / right |
| 18 |
CAMERA_ROLL = 2, // fall over |
| 19 |
}; |
| 20 |
|
| 21 |
// Abstract class used when handling mouse events |
| 22 |
// see also: class IOrthoView in iorthoview.h |
| 23 |
class ICameraView : |
| 24 |
public virtual IInteractiveView |
| 25 |
{ |
| 26 |
public: |
| 27 |
typedef std::shared_ptr<ICameraView> Ptr; |
| 28 |
|
| 29 |
virtual ~ICameraView() {} |
| 30 |
|
| 31 |
// Sets the device width and height, updates the projection |
| 32 |
virtual void setDeviceDimensions(int width, int height) = 0; |
| 33 |
|
| 34 |
// Move the camera's origin |
| 35 |
virtual const Vector3& getCameraOrigin() const = 0; |
| 36 |
virtual void setCameraOrigin(const Vector3& newOrigin) = 0; |
| 37 |
|
| 38 |
virtual const Vector3& getCameraAngles() const = 0; |
| 39 |
virtual void setCameraAngles(const Vector3& newAngles) = 0; |
| 40 |
|
| 41 |
// Combined setter for position and angles - triggers only one callback to potential observers |
| 42 |
virtual void setOriginAndAngles(const Vector3& newOrigin, const Vector3& newAngles) = 0; |
| 43 |
|
| 44 |
// Returns the vector pointing to the "right" |
| 45 |
virtual const Vector3& getRightVector() const = 0; |
| 46 |
// Returns the vector pointing "up" |
| 47 |
virtual const Vector3& getUpVector() const = 0; |
| 48 |
// Returns the vector pointing "forward" |
| 49 |
virtual const Vector3& getForwardVector() const = 0; |
| 50 |
|
| 51 |
virtual const Matrix4& getModelView() const = 0; |
| 52 |
virtual const Matrix4& getProjection() const = 0; |
| 53 |
|
| 54 |
// Cubic clipping |
| 55 |
virtual float getFarClipPlaneDistance() const = 0; |
| 56 |
virtual void setFarClipPlaneDistance(float distance) = 0; |
| 57 |
virtual bool getFarClipPlaneEnabled() const = 0; |
| 58 |
virtual void setFarClipPlaneEnabled(bool enabled) = 0; |
| 59 |
}; |
| 60 |
|
| 61 |
class IFreeMoveView : |
| 62 |
public virtual IInteractiveView |
| 63 |
{ |
| 64 |
public: |
| 65 |
virtual ~IFreeMoveView() {} |
| 66 |
|
| 67 |
// Freemove mode |
| 68 |
virtual void enableFreeMove() = 0; |
| 69 |
virtual void disableFreeMove() = 0; |
| 70 |
virtual bool freeMoveEnabled() const = 0; |
| 71 |
}; |
| 72 |
|
| 73 |
class ICameraViewManager : |
| 74 |
public RegisterableModule |
| 75 |
{ |
| 76 |
public: |
| 77 |
virtual ~ICameraViewManager() {} |
| 78 |
|
| 79 |
// Create a new camera instance. The ICameraViewManager is keeping a reference to this |
| 80 |
// object for broadcasting the focusCamera() calls, so be sure to notify the manager |
| 81 |
// if this camera is no longer in use by invoking destroyCamera(). |
| 82 |
// The requestRedraw takes a bool indicating whether the redraw should be queued (false) |
| 83 |
// or a redraw should be forced (true) |
| 84 |
virtual ICameraView::Ptr createCamera(render::IRenderView& view, const std::function<void(bool)>& requestRedraw) = 0; |
| 85 |
|
| 86 |
// Releases this camera instance, clearing any internal references to it |
| 87 |
virtual void destroyCamera(const ICameraView::Ptr& camera) = 0; |
| 88 |
|
| 89 |
// Sets the position and angles of all active cameras to the given values |
| 90 |
virtual void focusAllCameras(const Vector3& position, const Vector3& angles) = 0; |
| 91 |
|
| 92 |
// A reference to the currently active view. Will throw a std::runtime_error if no camera is present |
| 93 |
virtual ICameraView& getActiveView() = 0; |
| 94 |
|
| 95 |
// Signal emitted when any camera position or angles changed |
| 96 |
virtual sigc::signal<void>& signal_cameraChanged() = 0; |
| 97 |
}; |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
constexpr const char* const MODULE_CAMERA_MANAGER("CameraManager"); |
| 102 |
|
| 103 |
constexpr const char* const RKEY_CAMERA_DRAG_SELECTION_ENABLED = "user/ui/camera/dragSelectionEnabled"; |
| 104 |
|
| 105 |
// Module accessor |
| 106 |
inline camera::ICameraViewManager& GlobalCameraManager() |
| 107 |
{ |
| 108 |
static module::InstanceReference<camera::ICameraViewManager> _reference(MODULE_CAMERA_MANAGER); |
| 109 |
return _reference; |
| 110 |
} |