Browse Source

Adding more camera types (WIP)

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
adfdcb2aee
3 changed files with 35 additions and 10 deletions
  1. 6 6
      src/Renderer/Renderer.cpp
  2. 15 4
      src/Scene/Camera.h
  3. 14 0
      src/Scene/PerspectiveCamera.h

+ 6 - 6
src/Renderer/Renderer.cpp

@@ -116,12 +116,12 @@ Vec3 Renderer::unproject(const Vec3& windowCoords, const Mat4& modelViewMat, con
 //======================================================================================================================
 Mat4 Renderer::ortho(float left, float right, float bottom, float top, float near, float far)
 {
-	float difx = right-left;
-	float dify = top-bottom;
-	float difz = far-near;
-	float tx = -(right+left) / difx;
-	float ty = -(top+bottom) / dify;
-	float tz = -(far+near) / difz;
+	float difx = right - left;
+	float dify = top - bottom;
+	float difz = far - near;
+	float tx = -(right + left) / difx;
+	float ty = -(top + bottom) / dify;
+	float tz = -(far + near) / difz;
 	Mat4 m;
 
 	m(0, 0) = 2.0 / difx;

+ 15 - 4
src/Scene/Camera.h

@@ -19,6 +19,12 @@ class PointLight;
 class Camera: public SceneNode
 {
 	public:
+		enum CameraType
+		{
+			CT_PERSPECTIVE,
+			CT_ORTHOGRAPHIC
+		};
+
 		enum FrustrumPlanes
 		{
 			FP_LEFT = 0,
@@ -35,15 +41,20 @@ class Camera: public SceneNode
 
 		/// @name Accessors
 		/// @{
+		float getFovX() const {return fovX;}
 		void setFovX(float fovx);
+
+		float getFovY() const {return fovY;}
 		void setFovY(float fovy);
+
+		float getZNear() const {return zNear;}
 		void setZNear(float znear);
+
+		float getZFar() const {return zFar;}
 		void setZFar(float zfar);
+
 		void setAll(float fovx, float fovy, float znear, float zfar);
-		float getFovX() const {return fovX;}
-		float getFovY() const {return fovY;}
-		float getZNear() const {return zNear;}
-		float getZFar() const {return zFar;}
+
 		const Mat4& getProjectionMatrix() const {return projectionMat;}
 		const Mat4& getViewMatrix() const {return viewMat;}
 

+ 14 - 0
src/Scene/PerspectiveCamera.h

@@ -0,0 +1,14 @@
+#ifndef PERSPECTIVE_CAMERA_H
+#define PERSPECTIVE_CAMERA_H
+
+#include "Camera.h"
+
+
+class PerspectiveCamera: public Camera
+{
+	public:
+	private:
+};
+
+
+#endif