Browse Source

- Camera
- Light

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
20eac68402

+ 20 - 0
anki/collision/Frustum.h

@@ -53,6 +53,26 @@ public:
 	{
 		return type;
 	}
+
+	float getNear() const
+	{
+		return zNear;
+	}
+	void setNear(const float x)
+	{
+		zNear = x;
+		recalculate();
+	}
+
+	float getFar() const
+	{
+		return zFar;
+	}
+	void setFar(const float x)
+	{
+		zFar = x;
+		recalculate();
+	}
 	/// @}
 
 	/// Copy

+ 9 - 0
anki/math/Transform.h

@@ -53,6 +53,15 @@ public:
 	static const Transform& getIdentity();
 	static Transform combineTransformations(const Transform& a,
 		const Transform& b); ///< @copybrief Math::combineTransformations
+
+	/// Get the inverse transformation. Its faster that inverting a Mat4
+	Transform getInverse() const;
+	void invert();
+	/// @}
+
+	/// @name Friends
+	/// @{
+	friend std::ostream& operator<<(std::ostream& s, const Transform& a);
 	/// @}
 
 private:

+ 31 - 0
anki/math/Transform.inl.h

@@ -155,4 +155,35 @@ inline Transform Transform::combineTransformations(const Transform& a,
 }
 
 
+// getInverse
+inline Transform Transform::getInverse() const
+{
+	Transform o;
+	o.rotation = rotation.getTransposed(); // Rotation
+	o.scale = 1.0 / scale; // Apply scale
+	o.origin = -((o.rotation * o.scale) * origin); // Translation
+	return o;
+}
+
+
+// invert
+void Transform::invert()
+{
+	*this = getInverse();
+}
+
+
+//==============================================================================
+// Friends                                                                     =
+//==============================================================================
+
+// Print
+std::ostream& operator<<(std::ostream& s, const Transform& a)
+{
+	s << "o: " << a.origin << "\n" <<
+		"s: " << a.scale << "\n" <<
+		"r:\n" << a.rotation;
+	return s;
+}
+
 } // end namespace

+ 4 - 66
anki/scene/Camera.cpp

@@ -1,17 +1,18 @@
-#include <boost/foreach.hpp>
 #include "anki/scene/Camera.h"
 
 
 namespace anki {
 
 
+//==============================================================================
+// Camera                                                                      =
+//==============================================================================
+
 //==============================================================================
 Camera::~Camera()
 {}
 
 
-//==============================================================================
-// lookAtPoint                                                                 =
 //==============================================================================
 void Camera::lookAtPoint(const Vec3& point)
 {
@@ -23,67 +24,4 @@ void Camera::lookAtPoint(const Vec3& point)
 }
 
 
-//==============================================================================
-// updateWSpaceFrustumPlanes                                                   =
-//==============================================================================
-void Camera::updateWSpaceFrustumPlanes()
-{
-	for(uint i = 0; i < FP_NUM; i++)
-	{
-		wspaceFrustumPlanes[i] =
-			lspaceFrustumPlanes[i].getTransformed(getWorldTransform());
-	}
-}
-
-
-//==============================================================================
-// insideFrustum                                                               =
-//==============================================================================
-bool Camera::insideFrustum(const CollisionShape& bvol) const
-{
-	BOOST_FOREACH(const Plane& plane, wspaceFrustumPlanes)
-	{
-		if(bvol.testPlane(plane) < 0.0)
-		{
-			return false;
-		}
-	}
-
-	return true;
-}
-
-
-//==============================================================================
-// updateViewMatrix                                                            =
-//==============================================================================
-void Camera::updateViewMatrix()
-{
-	/*
-	 * The point at which the camera looks:
-	 * Vec3 viewpoint = translationLspace + z_axis;
-	 * as we know the up vector, we can easily use gluLookAt:
-	 * gluLookAt(translationLspace.x, translationLspace.x,
-	 *           translationLspace.z, z_axis.x, z_axis.y, z_axis.z, y_axis.x,
-	 *           y_axis.y, y_axis.z);
-	*/
-
-	// The view matrix is: Mview = camera.world_transform.Inverted().
-	// But instead of inverting we do the following:
-	Mat3 camInvertedRot = getWorldTransform().getRotation().getTransposed();
-	camInvertedRot *= 1.0 / getWorldTransform().getScale();
-	Vec3 camInvertedTsl = -(camInvertedRot * getWorldTransform().getOrigin());
-	viewMat = Mat4(camInvertedTsl, camInvertedRot);
-}
-
-
-//==============================================================================
-// moveUpdate                                                                  =
-//==============================================================================
-void Camera::moveUpdate()
-{
-	updateViewMatrix();
-	updateWSpaceFrustumPlanes();
-}
-
-
 } // end namespace

+ 183 - 15
anki/scene/Camera.h

@@ -5,9 +5,6 @@
 #include "anki/scene/Spartial.h"
 #include "anki/scene/Movable.h"
 #include "anki/scene/Frustumable.h"
-#include <boost/array.hpp>
-#include <deque>
-#include <vector>
 
 
 namespace anki {
@@ -29,15 +26,17 @@ public:
 		CT_COUNT
 	};
 
-	Camera(CameraType type,
+	/// @name Constructors
+	/// @{
+	Camera(CameraType type_,
 		const char* name, Scene* scene,
 		uint movableFlags, Movable* movParent,
 		CollisionShape* spartCs,
 		Frustum* frustum)
-		: type(type_), SceneNode(name, scene),
-			Movable(movableFlags, movParent), Spartial(spartCs),
-			Frustumable(frustum)
+		: SceneNode(name, scene), Movable(movableFlags, movParent),
+			Spartial(spartCs), Frustumable(frustum), type(type_)
 	{}
+	/// @}
 
 	virtual ~Camera();
 
@@ -47,19 +46,66 @@ public:
 	{
 		return type;
 	}
+
+	const Mat4& getProjectionMatrix() const
+	{
+		return projectionMat;
+	}
+
+	const Mat4& getInverseProjectionMatrix() const
+	{
+		return invProjectionMat;
+	}
+
+	const Mat4& getViewMatrix() const
+	{
+		return viewMat;
+	}
 	/// @}
 
-	/// @name
+	/// @name Implementation of virtuals
+	/// @{
+
+	/// Re-implements SceneNode::getMovable()
+	Movable* getMovable()
+	{
+		return this;
+	}
 
-	void lookAtPoint(const Vec3& point);
+	/// Re-implements SceneNode::getFrustumable()
+	virtual Frustumable* getFrustumable()
+	{
+		return this;
+	}
 
-	/// This does:
+	/// Re-implements SceneNode::getSpartial()
+	virtual Spartial* getSpartial()
+	{
+		return this;
+	}
+
+	/// Re-impements Movable::moveUpdate(). This does:
 	/// - Update view matrix
-	/// - Update frustum planes
-	virtual void moveUpdate();
+	/// - Update frustum
+	void moveUpdate()
+	{
+		Movable::moveUpdate();
+		updateViewMatrix();
+		getFrustum().transform(getWorldTransform());
+	}
+
+	/// Implements Frustumable::frustumUpdate(). Calculate the projection
+	/// matrix
+	void frustumUpdate()
+	{
+		projectionMat = getFrustum().calculateProjectionMatrix();
+		invProjectionMat = projectionMat.getInverse();
+	}
+	/// @}
 
-protected:
+	void lookAtPoint(const Vec3& point);
 
+private:
 	/// @name Matrices
 	/// @{
 	Mat4 projectionMat;
@@ -73,10 +119,132 @@ protected:
 	/// know re-calculates the matrices only when the parameters change!!
 	Mat4 invProjectionMat;
 	/// @}
-private:
+
 	CameraType type;
 
-	void updateViewMatrix();
+	/// Calculate the @a viewMat
+	///
+	/// The view matrix is the inverse world transformation
+	void updateViewMatrix()
+	{
+		viewMat = Mat4(getWorldTransform().getInverse());
+	}
+};
+
+
+/// Perspective camera
+class PerspectiveCamera: public Camera
+{
+public:
+	/// @name Constructors
+	/// @{
+	PerspectiveCamera(const char* name, Scene* scene,
+		uint movableFlags, Movable* movParent)
+		: Camera(CT_PERSPECTIVE, name, scene, movableFlags, movParent,
+			&frustum, &frustum)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float getFovX() const
+	{
+		return frustum.getFovX();
+	}
+	void setFovX(float ang)
+	{
+		frustum.setFovX(ang);
+		frustumUpdate();
+	}
+
+	float getFovY() const
+	{
+		return frustum.getFovY();
+	}
+	void setFovY(float ang)
+	{
+		frustum.setFovX(ang);
+		frustumUpdate();
+	}
+
+	void setAll(float fovX_, float fovY_, float zNear_, float zFar_)
+	{
+		frustum.setAll(fovX_, fovY_, zNear_, zFar_);
+		frustumUpdate();
+	}
+	/// @}
+
+private:
+	PerspectiveFrustum frustum;
+};
+
+
+/// Orthographic camera
+class OrthographicCamera: public Camera
+{
+public:
+	/// @name Constructors
+	/// @{
+	OrthographicCamera(const char* name, Scene* scene,
+		uint movableFlags, Movable* movParent)
+		: Camera(CT_ORTHOGRAPHIC, name, scene, movableFlags, movParent,
+			&frustum, &frustum)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float getLeft() const
+	{
+		return frustum.getLeft();
+	}
+	void setLeft(float f)
+	{
+		frustum.setLeft(f);
+		frustumUpdate();
+	}
+
+	float getRight() const
+	{
+		return frustum.getRight();
+	}
+	void setRight(float f)
+	{
+		frustum.setRight(f);
+		frustumUpdate();
+	}
+
+	float getTop() const
+	{
+		return frustum.getTop();
+	}
+	void setTop(float f)
+	{
+		frustum.setTop(f);
+		frustumUpdate();
+	}
+
+	float getBottom() const
+	{
+		return frustum.getBottom();
+	}
+	void setBottom(float f)
+	{
+		frustum.setBottom(f);
+		frustumUpdate();
+	}
+
+	/// Set all
+	void setAll(float left_, float right_, float zNear_,
+		float zFar_, float top_, float bottom_)
+	{
+		frustum.setAll(left_, right_, zNear_, zFar_, top_, bottom_);
+		frustumUpdate();
+	}
+	/// @}
+
+private:
+	OrthographicFrustum frustum;
 };
 /// @}
 

+ 0 - 30
anki/scene/Controller.cpp

@@ -1,30 +0,0 @@
-#include "anki/scene/Controller.h"
-#include "anki/scene/Scene.h"
-#include "anki/core/App.h"
-#include "anki/core/Globals.h"
-
-
-namespace anki {
-
-
-//==============================================================================
-// Constructor                                                                 =
-//==============================================================================
-Controller::Controller(ControllerType type_, SceneNode& node):
-	controlledNode(node),
-	type(type_)
-{
-	SceneSingleton::get().registerController(this);
-}
-
-
-//==============================================================================
-// Destructor                                                                  =
-//==============================================================================
-Controller::~Controller()
-{
-	SceneSingleton::get().unregisterController(this);
-}
-
-
-} // end namespace

+ 0 - 42
anki/scene/Controller.h

@@ -1,42 +0,0 @@
-#ifndef ANKI_SCENE_CONTROLLER_H
-#define ANKI_SCENE_CONTROLLER_H
-
-
-namespace anki {
-
-
-class SceneNode;
-
-
-/// Scenegraph node controller (A)
-class Controller
-{
-	public:
-		enum ControllerType
-		{ 
-			CT_SKEL_ANIM_SKIN_NODE,
-			CT_NUM
-		};
-	
-		Controller(ControllerType type, SceneNode& node);
-		virtual ~Controller();
-
-		/// @name Accessors
-		/// @{
-		ControllerType getType() const {return type;}
-		/// @}
-
-		virtual void update(float time) = 0;
-
-	protected:
-		SceneNode& controlledNode;
-
-	private:
-		ControllerType type; ///< Once the type is set nothing can change it
-};
-
-
-} // end namespace
-
-
-#endif

+ 85 - 0
anki/scene/Frustumable.h

@@ -14,10 +14,49 @@ namespace anki {
 class Frustumable
 {
 public:
+	/// @name Constructors
+	/// @{
+
 	/// Pass the frustum here so we can avoid the virtuals
 	Frustumable(Frustum* fr)
 		: frustum(fr)
 	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	const Frustum& getFrustum() const
+	{
+		return *frustum;
+	}
+	Frustum& getFrustum()
+	{
+		return *frustum;
+	}
+
+	float getNear() const
+	{
+		return frustum->getNear();
+	}
+	void setNear(const float x)
+	{
+		frustum->setNear(x);
+		frustumUpdate();
+	}
+
+	float getFar() const
+	{
+		return frustum->getFar();
+	}
+	void setFar(const float x)
+	{
+		frustum->setFar(x);
+		frustumUpdate();
+	}
+	/// @}
+
+	/// Called when a frustum parameter changes
+	virtual void frustumUpdate() = 0;
 
 	bool insideFrustum(const CollisionShape& cs) const
 	{
@@ -27,6 +66,52 @@ public:
 private:
 	Frustum* frustum;
 };
+
+
+/// XXX
+/*class PerspectiveFrustumable: public Frustumable
+{
+public:
+	/// @name Constructors
+	/// @{
+	PerspectiveFrustumable(PerspectiveFrustum* fr)
+		: Frustumable(fr)
+	{}
+	/// @}
+
+	/// @name Accessors
+	/// @{
+	float getFovX() const
+	{
+		return toPerpectiveFrustum()->getFovX();
+	}
+	void setFovX(float ang)
+	{
+		toPerpectiveFrustum()->setFovX(ang);
+		frustumUpdate();
+	}
+
+	float getFovY() const
+	{
+		return toPerpectiveFrustum()->getFovY();
+	}
+	void setFovY(float ang)
+	{
+		toPerpectiveFrustum()->setFovY(ang);
+		frustumUpdate();
+	}
+	/// @}
+
+private:
+	PerspectiveFrustum* toPerpectiveFrustum()
+	{
+		return static_cast<PerspectiveFrustum*>(frustum);
+	}
+	const PerspectiveFrustum* toPerpectiveFrustum() const
+	{
+		return static_cast<const PerspectiveFrustum*>(frustum);
+	}
+};*/
 /// @}
 
 

+ 0 - 26
anki/scene/GhostNode.h

@@ -1,26 +0,0 @@
-#ifndef ANKI_SCENE_GHOST_NODE_H
-#define ANKI_SCENE_GHOST_NODE_H
-
-#include "anki/scene/SceneNode.h"
-
-
-namespace anki {
-
-
-/// This is a node that does nothing
-class GhostNode: public SceneNode
-{
-	public:
-		GhostNode(Scene& scene): SceneNode(SNT_GHOST, scene, SNF_NONE, NULL)
-		{}
-		virtual ~GhostNode()
-		{}
-		void init(const char*)
-		{}
-};
-
-
-} // end namespace
-
-
-#endif

+ 97 - 53
anki/scene/Light.h

@@ -1,19 +1,18 @@
 #ifndef ANKI_SCENE_LIGHT_H
 #define ANKI_SCENE_LIGHT_H
 
-#include "anki/resource/Texture.h"
 #include "anki/scene/SceneNode.h"
-#include "anki/resource/Resource.h"
-#include "anki/resource/LightRsrc.h"
-#include "anki/scene/VisibilityInfo.h"
+#include "anki/scene/Movable.h"
 #include "anki/scene/Renderable.h"
+#include "anki/scene/Frustumable.h"
+#include "anki/scene/Spartial.h"
 
 
 namespace anki {
 
 
 /// Light scene node. It can be spot or point
-////
+///
 /// Explaining the lighting model:
 /// @code
 /// Final intensity:                If = Ia + Id + Is
@@ -28,55 +27,100 @@ namespace anki {
 /// Specular intensity of light:    Sl
 /// Specular intensity of material: Sm
 /// @endcode
-class Light: public SceneNode, public VisibilityInfo/*, public Renderable*/
+class Light: public SceneNode, public Movable, public Renderable,
+	public Spartial
 {
-	public:
-		enum LightType
-		{
-			LT_POINT,
-			LT_SPOT
-		};
-
-		Light(LightType t, Scene& scene, ulong flags, SceneNode* parent)
-			: SceneNode(SNT_LIGHT, scene, flags, parent), type(t)
-		{}
-
-		virtual ~Light();
-
-		/// @name Accessors
-		/// @{
-		LightType getLightType() const {return type;}
-
-		const Vec3& getDiffuseColor() const {return diffuseCol;}
-		Vec3& getDiffuseColor() {return diffuseCol;}
-		void setDiffuseColor(const Vec3& x) {diffuseCol = x;}
-
-		const Vec3& getSpecularColor() const {return specularCol;}
-		Vec3& getSpecularColor() {return specularCol;}
-		void setSpecularColor(const Vec3& x) {specularCol = x;}
-
-		bool getCastShadow() const {return castsShadowFlag;}
-		bool& getCastShadow() {return castsShadowFlag;}
-		void setCastShadow(bool x) {castsShadowFlag = x;}
-		/// @}
-
-		/// Implements Renderable::getMaterialRuntime
-		/*MaterialRuntime& getMaterialRuntime()
-		{
-			return *mtlr;
-		}*/
-
-		void init(const char* filename);
-
-	protected:
-		//boost::scoped_ptr<MaterialRuntime> mtlr;
-		LightRsrcResourcePointer lightData;
-		Vec3 diffuseCol; ///< Diffuse color
-		Vec3 specularCol; ///< Specular color
-		bool castsShadowFlag; ///< Casts shadow
-
-	private:
-		LightType type;
+public:
+	enum LightType
+	{
+		LT_POINT,
+		LT_SPOT
+	};
+
+	/// @name Constructors
+	/// @{
+	Light(LightType t,
+		const char* name, Scene* scene,
+		uint movableFlags, Movable* movParent,
+		CollisionShape* cs,
+		const char* modelFname)
+		: SceneNode(name, scene), Movable(movableFlags, movParent),
+			Spartial(cs), type(t)
+	{
+		//smoModel
+	}
+	/// @}
+
+	virtual ~Light();
+
+	/// @name Accessors
+	/// @{
+	LightType getLightType() const
+	{
+		return type;
+	}
+	/// @}
+
+	/// @name Virtuals
+	/// @{
+	Movable* getMovable()
+	{
+		return this;
+	}
+
+	Renderable* getRenderable()
+	{
+		return this;
+	}
+
+	Spartial* getSpartial()
+	{
+		return this;
+	}
+
+	const Vao& getVao(const PassLevelKey&)
+	{
+		//mesh.
+	}
+
+	MaterialRuntime& getMaterialRuntime()
+	{
+		return *mtlr;
+	}
+
+	const Transform& getWorldTransform(const PassLevelKey&)
+	{
+		return getWorldTransform();
+	}
+
+	const Transform& getPreviousWorldTransform(const PassLevelKey&)
+	{
+		return getPreviousWorldTransform();
+	}
+	/// @}
+
+private:
+	LightType type;
+	boost::scoped_ptr<MaterialRuntime> mtlr;
+	ModelResourcePointer smoModel; ///< Model for SMO pases
+};
+
+
+/// Point light
+class PointLight: public Light
+{
+public:
+
+private:
+};
+
+
+/// Spot light
+class SpotLight: public Light, public Frustumable
+{
+public:
+
+private:
 };
 
 

+ 0 - 83
anki/scene/OrthographicCamera.cpp

@@ -1,83 +0,0 @@
-#include "anki/scene/OrthographicCamera.h"
-
-
-namespace anki {
-
-
-//==============================================================================
-// setAll                                                                      =
-//==============================================================================
-void OrthographicCamera::setAll(float left_, float right_, float top_,
-	float bottom_, float zNear_, float zFar_)
-{
-	left = left_;
-	right = right_;
-	top = top_;
-	bottom = bottom_;
-	zNear = zNear_;
-	zFar = zFar_;
-	calcProjectionMatrix();
-	calcLSpaceFrustumPlanes();
-}
-
-
-//==============================================================================
-// calcLSpaceFrustumPlanes                                                     =
-//==============================================================================
-void OrthographicCamera::calcLSpaceFrustumPlanes()
-{
-	lspaceFrustumPlanes[FP_LEFT] = Plane(Vec3(1.0, 0.0, 0.0), left);
-	lspaceFrustumPlanes[FP_RIGHT] = Plane(Vec3(-1.0, 0.0, 0.0), -right);
-	lspaceFrustumPlanes[FP_NEAR] = Plane(Vec3(0.0, 0.0, -1.0), zNear);
-	lspaceFrustumPlanes[FP_FAR] = Plane(Vec3(0.0, 0.0, 1.0), -zFar);
-	lspaceFrustumPlanes[FP_TOP] = Plane(Vec3(0.0, -1.0, 0.0), -top);
-	lspaceFrustumPlanes[FP_BOTTOM] = Plane(Vec3(0.0, 1.0, 0.0), bottom);
-}
-
-
-//==============================================================================
-// ortho                                                                       =
-//==============================================================================
-Mat4 OrthographicCamera::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;
-	Mat4 m;
-
-	m(0, 0) = 2.0 / difx;
-	m(0, 1) = 0.0;
-	m(0, 2) = 0.0;
-	m(0, 3) = tx;
-	m(1, 0) = 0.0;
-	m(1, 1) = 2.0 / dify;
-	m(1, 2) = 0.0;
-	m(1, 3) = ty;
-	m(2, 0) = 0.0;
-	m(2, 1) = 0.0;
-	m(2, 2) = -2.0 / difz;
-	m(2, 3) = tz;
-	m(3, 0) = 0.0;
-	m(3, 1) = 0.0;
-	m(3, 2) = 0.0;
-	m(3, 3) = 1.0;
-
-	return m;
-}
-
-
-//==============================================================================
-// calcProjectionMatrix                                                        =
-//==============================================================================
-void OrthographicCamera::calcProjectionMatrix()
-{
-	projectionMat = ortho(left, right, bottom, top, zNear, zFar);
-	invProjectionMat = projectionMat.getInverse();
-}
-
-
-} // end namespace

+ 0 - 119
anki/scene/OrthographicCamera.h

@@ -1,119 +0,0 @@
-#ifndef ANKI_SCENE_ORTHOGRAPHIC_CAMERA_H
-#define ANKI_SCENE_ORTHOGRAPHIC_CAMERA_H
-
-#include "anki/scene/Camera.h"
-
-
-namespace anki {
-
-
-/// Orthographic camera defined by pairs of parallel planes
-class OrthographicCamera: public Camera
-{
-	public:
-		OrthographicCamera(Scene& scene, ulong flags, SceneNode* parent);
-
-		void init(const char*) {}
-
-		/// @name Accessors
-		/// @{
-		float getLeft() const
-		{
-			return left;
-		}
-		void setLeft(float f);
-
-		float getRight() const
-		{
-			return right;
-		}
-		void setRight(float f);
-
-		float getTop() const
-		{
-			return top;
-		}
-		void setTop(float f);
-
-		float getBottom() const
-		{
-			return bottom;
-		}
-		void setBottom(float f);
-		/// @}
-
-		void setAll(float left, float right, float top, float bottom,
-			float znear, float zfar);
-
-		/// It returns an orthographic projection matrix
-		/// @param left left vertical clipping plane
-		/// @param right right vertical clipping plane
-		/// @param bottom bottom horizontal clipping plane
-		/// @param top top horizontal clipping plane
-		/// @param near nearer distance of depth clipping plane
-		/// @param far farther distance of depth clipping plane
-		/// @return A 4x4 projection matrix
-		static Mat4 ortho(float left, float right, float bottom, float top,
-			float near, float far);
-
-	private:
-		/// @name Data
-		/// @{
-		float left;
-		float right;
-		float top;
-		float bottom;
-		/// @}
-
-		/// Implements Camera::calcLSpaceFrustumPlanes
-		void calcLSpaceFrustumPlanes();
-
-		/// Implements Camera::calcProjectionMatrix
-		void calcProjectionMatrix();
-};
-
-
-inline OrthographicCamera::OrthographicCamera(Scene& scene, ulong flags,
-	SceneNode* parent)
-:	Camera(CT_ORTHOGRAPHIC, scene, flags, parent)
-{
-	name = "OrthographicCamera:" + name;
-}
-
-
-inline void OrthographicCamera::setLeft(float f)
-{
-	left = f;
-	calcProjectionMatrix();
-	calcLSpaceFrustumPlanes();
-}
-
-
-inline void OrthographicCamera::setRight(float f)
-{
-	right = f;
-	calcProjectionMatrix();
-	calcLSpaceFrustumPlanes();
-}
-
-
-inline void OrthographicCamera::setTop(float f)
-{
-	top = f;
-	calcProjectionMatrix();
-	calcLSpaceFrustumPlanes();
-}
-
-
-inline void OrthographicCamera::setBottom(float f)
-{
-	bottom = f;
-	calcProjectionMatrix();
-	calcLSpaceFrustumPlanes();
-}
-
-
-} // end namespace
-
-
-#endif

+ 0 - 76
anki/scene/PerspectiveCamera.cpp

@@ -1,76 +0,0 @@
-#include "anki/scene/PerspectiveCamera.h"
-
-
-namespace anki {
-
-
-//==============================================================================
-// setAll                                                                      =
-//==============================================================================
-void PerspectiveCamera::setAll(float fovx_, float fovy_, float znear_,
-	float zfar_)
-{
-	fovX = fovx_;
-	fovY = fovy_;
-	zNear = znear_;
-	zFar = zfar_;
-	calcProjectionMatrix();
-	calcLSpaceFrustumPlanes();
-}
-
-
-//==============================================================================
-// calcProjectionMatrix                                                        =
-//==============================================================================
-void PerspectiveCamera::calcProjectionMatrix()
-{
-	float f = 1.0 / tan(fovY * 0.5); // f = cot(fovY/2)
-
-	projectionMat(0, 0) = f * fovY / fovX; // = f/aspectRatio;
-	projectionMat(0, 1) = 0.0;
-	projectionMat(0, 2) = 0.0;
-	projectionMat(0, 3) = 0.0;
-	projectionMat(1, 0) = 0.0;
-	projectionMat(1, 1) = f;
-	projectionMat(1, 2) = 0.0;
-	projectionMat(1, 3) = 0.0;
-	projectionMat(2, 0) = 0.0;
-	projectionMat(2, 1) = 0.0;
-	projectionMat(2, 2) = (zFar + zNear) / ( zNear - zFar);
-	projectionMat(2, 3) = (2.0 * zFar * zNear) / (zNear - zFar);
-	projectionMat(3, 0) = 0.0;
-	projectionMat(3, 1) = 0.0;
-	projectionMat(3, 2) = -1.0;
-	projectionMat(3, 3) = 0.0;
-
-	invProjectionMat = projectionMat.getInverse();
-}
-
-
-//==============================================================================
-// calcLSpaceFrustumPlanes                                                     =
-//==============================================================================
-void PerspectiveCamera::calcLSpaceFrustumPlanes()
-{
-	float c, s; // cos & sine
-
-	Math::sinCos(Math::PI + fovX / 2, s, c);
-	// right
-	lspaceFrustumPlanes[FP_RIGHT] = Plane(Vec3(c, 0.0, s), 0.0);
-	// left
-	lspaceFrustumPlanes[FP_LEFT] = Plane(Vec3(-c, 0.0, s), 0.0);
-
-	Math::sinCos((3 * Math::PI - fovY) * 0.5, s, c);
-	// top
-	lspaceFrustumPlanes[FP_TOP] = Plane(Vec3(0.0, s, c), 0.0);
-	// bottom
-	lspaceFrustumPlanes[FP_BOTTOM] = Plane(Vec3(0.0, -s, c), 0.0);
-
-	// near
-	lspaceFrustumPlanes[FP_NEAR] = Plane(Vec3(0.0, 0.0, -1.0), zNear);
-	// far
-	lspaceFrustumPlanes[FP_FAR] = Plane(Vec3(0.0, 0.0, 1.0), -zFar);
-}
-
-
-} // end namespace

+ 0 - 109
anki/scene/PerspectiveCamera.h

@@ -1,109 +0,0 @@
-#ifndef ANKI_SCENE_PERSPECTIVE_CAMERA_H
-#define ANKI_SCENE_PERSPECTIVE_CAMERA_H
-
-#include "anki/scene/Camera.h"
-#include "anki/collision/Collision.h"
-
-
-namespace anki {
-
-
-/// @todo
-class PerspectiveCamera: public Camera
-{
-	public:
-		PerspectiveCamera(Scene& scene, ulong flags, SceneNode* parent);
-
-		/// @name Accessors
-		/// @{
-		float getFovX() const
-		{
-			return fovX;
-		}
-		void setFovX(float fovx);
-
-		float getFovY() const
-		{
-			return fovY;
-		}
-		void setFovY(float fovy);
-		/// @}
-
-		void moveUpdate()
-		{
-			Camera::moveUpdate();
-			wspaceCShape =
-				lspaceCShape.getTransformed(getWorldTransform());
-		}
-
-		/// @copydoc SceneNode::getVisibilityCollisionShapeWorldSpace
-		const CollisionShape* getVisibilityCollisionShapeWorldSpace() const
-		{
-			return &wspaceCShape;
-		}
-
-		void init(const char*)
-		{}
-
-		void setAll(float fovx, float fovy, float znear, float zfar);
-
-	private:
-		/// @name Data
-		/// @{
-		PerspectiveCameraShape lspaceCShape;
-		PerspectiveCameraShape wspaceCShape;
-
-		/// fovX is the angle in the y axis (imagine the cam positioned in
-		/// the default OGL pos) Note that fovX > fovY (most of the time) and
-		/// aspectRatio = fovX/fovY
-		float fovX;
-		float fovY; /// @see fovX
-		/// @}
-
-		/// Implements Camera::calcLSpaceFrustumPlanes
-		void calcLSpaceFrustumPlanes();
-
-		/// Implements Camera::calcProjectionMatrix
-		void calcProjectionMatrix();
-
-		/// Update:
-		/// - The projection matrix
-		/// - The planes
-		/// - The collision shape
-		void updateLocals()
-		{
-			calcProjectionMatrix();
-			calcLSpaceFrustumPlanes();
-			lspaceCShape.setAll(fovX, fovY, zNear, zFar,
-				Transform::getIdentity());
-		}
-};
-
-
-inline PerspectiveCamera::PerspectiveCamera(Scene& scene, ulong flags,
-	SceneNode* parent)
-:	Camera(CT_PERSPECTIVE, scene, flags, parent)
-{
-	name = "PerspectiveCamera:" + name;
-}
-
-
-inline void PerspectiveCamera::setFovX(float fovx_)
-{
-	fovX = fovx_;
-	updateLocals();
-}
-
-
-inline void PerspectiveCamera::setFovY(float fovy_)
-{
-	fovY = fovy_;
-	calcProjectionMatrix();
-	calcLSpaceFrustumPlanes();
-}
-
-
-} // end namespace
-
-
-#endif

+ 1 - 0
anki/scene/Scene.h

@@ -3,6 +3,7 @@
 
 #include "anki/scene/SceneNode.h"
 #include <boost/range/iterator_range.hpp>
+#include <vector>
 
 
 namespace anki {

+ 2 - 2
anki/scene/Spartial.h

@@ -18,8 +18,8 @@ class Spartial
 {
 public:
 	/// Pass the collision shape here so we can avoid the virtuals
-	Spartial(CollisionShape* x)
-		: cs(fr)
+	Spartial(CollisionShape* cs_)
+		: cs(cs_)
 	{}
 
 	const CollisionShape& getCollisionShape() const