Neo  0.5.0
Developer Documentation
OCamera.h
Go to the documentation of this file.
1 //========================================================================
2 // Copyright (c) 2003-2011 Anael Seghezzi <www.maratis3d.com>
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 //
8 // Permission is granted to anyone to use this software for any purpose,
9 // including commercial applications, and to alter it and redistribute it
10 // freely, subject to the following restrictions:
11 //
12 // 1. The origin of this software must not be misrepresented; you must not
13 // claim that you wrote the original software. If you use this software
14 // in a product, an acknowledgment in the product documentation would
15 // be appreciated but is not required.
16 //
17 // 2. Altered source versions must be plainly marked as such, and must not
18 // be misrepresented as being the original software.
19 //
20 // 3. This notice may not be removed or altered from any source
21 // distribution.
22 //
23 //========================================================================
24 
25 #ifndef __OCAMERA_H
26 #define __OCAMERA_H
27 
28 namespace Neo
29 {
30 class NEO_ENGINE_EXPORT OCamera : public Object3d
31 {
32 private:
33 
34  // properties
35  bool m_fog;
36  Vector3 m_fogColor;
37  bool m_ortho;
38  float m_fov;
39  float m_fogDistance;
40  float m_clippingNear;
41  float m_clippingFar;
42  Vector3 m_clearColor;
43 
44  // current matrices
45  Matrix4x4 m_currentViewMatrix; // current model view matrix
46  Matrix4x4 m_currentProjMatrix; // current projection matrix
47 
48  // current viewport
49  int m_currentViewport[4]; // 0=x 1=y 2=width 3=height
50 
51  // frustum (camera volume for elimination)
52  Frustum m_frustum;
53 
54  // scene layer (used for GUI etc)
55  unsigned int m_sceneLayer;
56 
57  // render to texture
58  TextureRef * m_renderColorTexture;
59  TextureRef * m_renderDepthTexture;
60 
61  Skybox m_skybox;
62 
63 public:
64 
65  // constructor
66  OCamera(void);
67 
68  // destructor
69  ~OCamera(void);
70 
71  // copy constructor
72  OCamera(const OCamera & camera);
73 
74 public:
75 
76  // type
77  int getType(void){ return OBJECT3D_CAMERA; }
78 
79  // properties
80  inline void enableFog(const bool fog){ m_fog = fog; }
81  inline Vector3 getFogColor() { return m_fogColor; }
82  inline void setFogColor(Vector3 color) { m_fogColor = color; }
83  inline void enableOrtho(const bool ortho){ m_ortho = ortho; }
84  inline void setFov(const float fov){ m_fov = fov; }
85  inline void setFogDistance(const float fogDistance){ m_fogDistance = fogDistance; }
86  inline void setClippingNear(const float clippingNear){ m_clippingNear = clippingNear; }
87  inline void setClippingFar(const float clippingFar){ m_clippingFar = clippingFar; }
88  inline bool isOrtho(void){ return m_ortho; }
89  inline bool hasFog(void){ return m_fog; }
90  inline float getClippingNear(void){ return m_clippingNear; }
91  inline float getClippingFar(void){ return m_clippingFar; }
92  inline float getFov(void){ return m_fov; }
93  inline float getFogDistance(void){ return m_fogDistance; }
94  inline void setClearColor(Vector3 clearColor) { m_clearColor = clearColor; }
95  inline Vector3 getClearColor(void) const { return m_clearColor; }
96 
97  // projection
98  Vector3 getProjectedPoint(const Vector3 & point) const;
99  Vector3 getUnProjectedPoint(const Vector3 & point) const;
100 
101  // matrices
102  inline Matrix4x4 * getCurrentViewMatrix(void){ return &m_currentViewMatrix; }
103  inline Matrix4x4 * getCurrentProjMatrix(void){ return &m_currentProjMatrix; }
104 
105  // viewport
106  int * getCurrentViewport(void){ return m_currentViewport; }
107 
108  // frustum
109  inline Frustum * getFrustum(void){ return &m_frustum; }
110 
111  // scene layer
112  inline void setSceneLayer(unsigned int sceneLayer){ m_sceneLayer = sceneLayer; }
113  inline unsigned int getSceneLayer(void){ return m_sceneLayer; }
114 
115  // render to texture
116  inline void setRenderColorTexture(TextureRef * renderColorTexture){ m_renderColorTexture = renderColorTexture; }
117  inline void setRenderDepthTexture(TextureRef * renderDepthTexture){ m_renderDepthTexture = renderDepthTexture; }
118  inline TextureRef * getRenderColorTexture(void){ return m_renderColorTexture; }
119  inline TextureRef * getRenderDepthTexture(void){ return m_renderDepthTexture; }
120 
121  inline void drawSkybox() { enable(); m_skybox.drawSkybox(getTransformedPosition(), getTransformedRotation()); }
122  inline void loadSkybox(const char* path) { m_skybox.loadSkyboxTextures(path); }
123  inline Skybox * getSkybox() { return &m_skybox; }
124 
125  // listener
126  void updateListener(void);
127 
128  // enable
129  void enable(void);
130  Matrix4x4 setPerspectiveView(float fov, float ratio, float zNear, float zFar);
131  Matrix4x4 setOrthoView(float left, float right, float bottom, float top, float zNear, float zFar);
132 };
133 }
134 #endif
Vector3 getClearColor(void) const
Definition: OCamera.h:95
void setFogDistance(const float fogDistance)
Definition: OCamera.h:85
void setSceneLayer(unsigned int sceneLayer)
Definition: OCamera.h:112
void setRenderDepthTexture(TextureRef *renderDepthTexture)
Definition: OCamera.h:117
void drawSkybox()
Definition: OCamera.h:121
int * getCurrentViewport(void)
Definition: OCamera.h:106
Matrix4x4 * getCurrentProjMatrix(void)
Definition: OCamera.h:103
void enableOrtho(const bool ortho)
Definition: OCamera.h:83
Definition: Frustum.h:31
Definition: Matrix4x4.h:31
int getType(void)
Returns the type of the object.
Definition: OCamera.h:77
Definition: Vector3.h:31
void enableFog(const bool fog)
Definition: OCamera.h:80
float getClippingFar(void)
Definition: OCamera.h:91
Definition: NeoEngine.h:46
float getFogDistance(void)
Definition: OCamera.h:93
void setClearColor(Vector3 clearColor)
Definition: OCamera.h:94
void setClippingNear(const float clippingNear)
Definition: OCamera.h:86
void setClippingFar(const float clippingFar)
Definition: OCamera.h:87
unsigned int getSceneLayer(void)
Definition: OCamera.h:113
void setFogColor(Vector3 color)
Definition: OCamera.h:82
void loadSkyboxTextures(const char *path)
void setFov(const float fov)
Definition: OCamera.h:84
bool isOrtho(void)
Definition: OCamera.h:88
float getClippingNear(void)
Definition: OCamera.h:90
Vector3 getFogColor()
Definition: OCamera.h:81
void drawSkybox(Vector3 position, Vector3 rotation)
void setRenderColorTexture(TextureRef *renderColorTexture)
Definition: OCamera.h:116
The Object3d class represents a general object in a 3D scene.
Definition: Object3d.h:43
bool hasFog(void)
Definition: OCamera.h:89
TextureRef * getRenderDepthTexture(void)
Definition: OCamera.h:119
Matrix4x4 * getCurrentViewMatrix(void)
Definition: OCamera.h:102
float getFov(void)
Definition: OCamera.h:92
Definition: TextureRef.h:32
Definition: OCamera.h:30
Definition: Skybox.h:33
Definition: Color.h:29
TextureRef * getRenderColorTexture(void)
Definition: OCamera.h:118
Skybox * getSkybox()
Definition: OCamera.h:123
Frustum * getFrustum(void)
Definition: OCamera.h:109
void loadSkybox(const char *path)
Definition: OCamera.h:122