Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 49cba74792fc65d75835faa1996a315e1a4760e1 (plain)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* 
   render/camera.h
   This file is part of the Osirion project and is distributed under 
   the terms and conditions of the GNU General Public License version 2 
*/

#ifndef __INCLUDED_RENDER_CAMERA_H__
#define __INCLUDED_RENDER_CAMERA_H__

#include "math/mathlib.h"
#include "core/range.h"

namespace render {

const float WORLDSCALE = 4.0f;
const float FARPLANE = core::range::maxdistance;
const float FRUSTUMSIZE = 0.5f;
const float FRUSTUMFRONT = 1.0f;

/// camera functions
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; }

	/// gameworld coordinates of the camera target
	static inline const math::Vector3f & target() { return camera_target; }

	/// gameworld camera axis
	static inline const math::Axis & axis() { return camera_axis; }

	/// current camera mode
	static inline Mode mode() { return camera_mode; }

	/// 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
	 */
	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 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__