Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/camera.h')
-rw-r--r--src/render/camera.h305
1 files changed, 213 insertions, 92 deletions
diff --git a/src/render/camera.h b/src/render/camera.h
index cc6eaa5..4d01fa2 100644
--- a/src/render/camera.h
+++ b/src/render/camera.h
@@ -7,114 +7,235 @@
#ifndef __INCLUDED_RENDER_CAMERA_H__
#define __INCLUDED_RENDER_CAMERA_H__
-#include "math/mathlib.h"
#include "core/range.h"
+#include "math/vector3f.h"
+#include "math/axis.h"
+
+namespace core
+{
+ class Entity;
+}
namespace render
{
const float WORLDSCALE = 4.0f;
-const float FARPLANE = core::range::maxdistance;
+
const float FRUSTUMSIZE = 0.5f;
const float FRUSTUMFRONT = 1.0f;
+const float FARPLANE = core::range::maxdistance * WORLDSCALE;
-/// camera functions
+/**
+ * @brief The Camera class draws a camera transformation determined by its current settings
+ * */
class Camera
{
public:
-
- /// enum indicating the camera mode
- enum Mode {Free, Track, Cockpit, Overview};
-
- /// initialize the camera
- static void init();
-
- /// shutdown the camera
- static void shutdown();
-
- /// gameworld coordinates of the camera eye
- static inline const math::Vector3f & eye() {
- return camera_eye;
+ /**
+ * @brief enum indicating the camera mode
+ * */
+ enum Mode {Track, Cockpit, Free, Overview};
+
+ /**
+ * @brief default constructor
+ * */
+ Camera(const Mode mode = Track);
+
+ /**
+ * @brief destructor
+ * */
+ ~Camera();
+
+ /* --- inspectors ------------------------------------------ */
+
+ /**
+ * @brief current camera mode
+ * */
+ inline const Mode mode() const
+ {
+ return _mode;
}
-
- /// gameworld coordinates of the camera target
- static inline const math::Vector3f & target() {
- return camera_target;
+
+ /**
+ * @brief distance between the camera eye and the target
+ * */
+ inline const float distance() const
+ {
+ return _distance;
}
-
- /// gameworld camera axis
- static inline const math::Axis & axis() {
- return camera_axis;
+
+ /**
+ * @brief distance multiplier
+ * The distance multiplier can be used to zoom the camera in or out
+ * */
+ inline const float multiplier() const
+ {
+ return _multiplier;
}
-
- /// current camera mode
- static inline Mode mode() {
- return camera_mode;
+
+ /**
+ * @brief camera eye location, translation part of the camera transformation
+ * */
+ inline const math::Vector3f & location() const
+ {
+ return _location;
}
-
- /// reset the current mode
- static void reset();
-
- /// progress the camera
- static void frame(float elapsed);
-
- /// enable camera frustum projection
- /** The camera frustum projection is used to draw the world
- */
- static void frustum();
-
- /// enable default frustum projection
- /** The default frustum projection is used to draw Gui 3D models
- */
- static void frustum_default(float distance, float cx, float cy);
-
- /// enable orthographic projection
- /** The ortographic projetion is used to draw the user interface
- */
+
+ /**
+ * @brief camera target location,point the camera is looking at
+ * */
+ inline const math::Vector3f & target_location() const
+ {
+ return _target_location;
+ }
+
+ /**
+ * @brief camera eye axis, rotation part of the camera transformation
+ * */
+ inline const math::Axis & axis() const
+ {
+ return _axis;
+ }
+
+ /**
+ * @brief the entity the camera is currently looking at
+ * */
+ inline const core::Entity *target()
+ {
+ return _target_entity;
+ }
+
+ /**
+ * @brief free look direction angle, in degrees
+ * */
+ inline const float freelook_direction() const
+ {
+ return _freelook_direction;
+ }
+
+ /**
+ * @brief free look pitch angle, in degrees
+ * */
+ inline const float freelook_pitch() const
+ {
+ return _freelook_pitch;
+ }
+
+ /**
+ * @brief free look direction rotation speed, -1..1
+ * */
+ inline const float movement_direction() const
+ {
+ return _movement_direction;
+ }
+
+ /**
+ * @brief free look pitch rotation speed, -1..1
+ * */
+ inline const float movement_pitch() const
+ {
+ return _movement_pitch;
+ }
+
+ /* --- mutators -------------------------------------------- */
+
+ /**
+ * @brief set the current camera mode
+ * */
+ void set_mode(const Mode mode);
+
+ /**
+ * @brief set next camera mode
+ * */
+ void cycle_mode_next();
+
+ /**
+ * @brief set previous camera mode
+ * */
+ void cycle_mode_previous();
+
+ /**
+ * @brief set camera target
+ * */
+ void set_target(const core::Entity *entity = 0);
+
+ /**
+ * @brief set distance multiplier
+ * */
+ void set_multiplier(const float multiplier);
+
+ /**
+ * @brief set the free look direction angle, in degrees
+ * */
+ void set_freelook_direction(const float angle);
+
+ /**
+ * @brief set the free look pitch angle, in degrees
+ * */
+ void set_freelook_pitch(const float angle);
+
+ /**
+ * @brief set the free look direction rotation speed, -1..1
+ * */
+ void set_movement_direction(const float speed);
+
+ /**
+ * @brief set the free look pitch rotation speed, -1..1
+ * */
+ void set_movement_pitch(const float speed);
+
+ /* --- actors ---------------------------------------------- */
+
+ void reset();
+
+ /**
+ * @brief update the camera location and axis.
+ * */
+ void frame(const float elapsed);
+
+ /**
+ * @brief draw the actual camera transformation
+ * This method is used to draw the camera projection for the world render
+ * and applies WORLDSCALE.
+ * */
+ void draw();
+
+ /**
+ * @brief draw the actual camera transformation
+ * This method variant is used by the user interface 3D model widget
+ * and ignores WORLDSCALE.
+ * */
+ void draw(const float center_x, const float center_y);
+
+ /* --- static ---------------------------------------------- */
+
+ /**
+ * @brief set the current transformation matrix to a orthographic projection
+ * This method is used while drawing the user interface.
+ * */
static void ortho();
- /// set target zoom
- static void set_zoom(float zoom);
-
- /// set target direction
- static void set_direction(float direction);
-
- /// set target pitch
- static void set_pitch(float pitch);
-
- /// switch to next camera mode
- static void view_next();
-
- /// wtich to previous camera mode
- static void view_previous();
-
- /// set specified camera mode
- static void set_mode(Mode newmode);
-
private:
- static math::Vector3f camera_eye;
- static math::Vector3f camera_target;
- static math::Axis camera_axis;
- static math::Axis camera_scene_axis;
- static Mode camera_mode;
- static Mode camera_previous_mode;
-
-
- // current and target yaw angle in XZ plane, positive is looking left
- static float direction_current;
- static float direction_target;
- static float target_direction;
-
- // current and target pitch angle in XY, positive is looking up
- static float pitch_current;
- static float pitch_target;
- static float target_pitch;
-
- static float distance;
- static float camera_zoom;
-
-};
-
-} // namespace client
-
-#endif // __INCLUDED_RENDER_CAMERA_H__
+ Mode _mode;
+
+ float _distance;
+ float _multiplier;
+ math::Vector3f _location;
+ math::Axis _axis;
+
+ const core::Entity * _target_entity;
+ math::Vector3f _target_location;
+ math::Axis _target_axis;
+
+ float _freelook_direction;
+ float _freelook_pitch;
+
+ float _movement_direction;
+ float _movement_pitch;
+
+
+}; // class camera
+
+} // namespace render
+
+#endif // __INCLUDED_RENDER_CAMERA_H__