Selaa lähdekoodia

Changing the Frustum a bit

Panagiotis Christopoulos Charitos 13 vuotta sitten
vanhempi
sitoutus
771749152b

+ 2 - 3
.cproject

@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 4.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
 	<storageModule moduleId="org.eclipse.cdt.core.settings">
 		<cconfiguration id="cdt.managedbuild.config.gnu.exe.debug.1191103617">
 			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.debug.1191103617" moduleId="org.eclipse.cdt.core.settings" name="Debug">
@@ -143,4 +141,5 @@
 	<storageModule moduleId="refreshScope" versionNumber="1">
 		<resource resourceType="PROJECT" workspacePath="/anki"/>
 	</storageModule>
+	<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
 </cproject>

+ 73 - 40
include/anki/collision/Frustum.h

@@ -12,10 +12,8 @@ namespace anki {
 /// @addtogroup Collision
 /// @{
 
-/// Frustum collision shape
-///
-/// This shape consists from 6 planes. The planes are being used to find shapes
-/// that are inside the frustum
+/// Frustum collision shape. This shape consists from 6 planes. The planes are
+/// being used to find shapes that are inside the frustum
 class Frustum: public CollisionShape
 {
 public:
@@ -59,29 +57,32 @@ public:
 	{
 		return zNear;
 	}
+	float& getNear()
+	{
+		return zNear;
+	}
 	void setNear(const float x)
 	{
 		zNear = x;
-		recalculate();
 	}
 
 	float getFar() const
 	{
 		return zFar;
 	}
+	float& getFar()
+	{
+		return zFar;
+	}
 	void setFar(const float x)
 	{
 		zFar = x;
-		recalculate();
 	}
 	/// @}
 
 	/// Copy
 	Frustum& operator=(const Frustum& b);
 
-	/// Implements CollisionShape::transform. Ignores scale
-	void transform(const Transform& trf);
-
 	/// Implements CollisionShape::accept
 	void accept(MutableVisitor& v)
 	{
@@ -100,18 +101,28 @@ public:
 	virtual Mat4 calculateProjectionMatrix() const = 0;
 
 protected:
-	/// Used to check against the frustum
-	std::array<Plane, FP_COUNT> planes;
-
 	/// @name Viewing variables
 	/// @{
 	float zNear;
 	float zFar;
 	/// @}
 
-	/// Called when a viewing variable changes. It recalculates the planes and
-	/// the other variables
-	virtual void recalculate() = 0;
+	Transform trf;
+
+	/// Used to check against the frustum
+	mutable std::array<Plane, FP_COUNT> planes;
+
+	/// It recalculates the planes in local space
+	virtual void recalculatePlanes() const = 0;
+
+	/// Self explanatory
+	void transformPlanes() const
+	{
+		for(Plane& p : planes)
+		{
+			p.transform(trf);
+		}
+	}
 
 private:
 	FrustumType type;
@@ -150,20 +161,26 @@ public:
 	{
 		return fovX;
 	}
+	float& getFovX()
+	{
+		return fovX;
+	}
 	void setFovX(float ang)
 	{
 		fovX = ang;
-		recalculate();
 	}
 
 	float getFovY() const
 	{
 		return fovY;
 	}
+	float& getFovY()
+	{
+		return fovY;
+	}
 	void setFovY(float ang)
 	{
 		fovY = ang;
-		recalculate();
 	}
 
 	/// Set all the parameters and recalculate the planes and shape
@@ -173,7 +190,6 @@ public:
 		fovY = fovY_,
 		zNear = zNear_;
 		zFar = zFar_;
-		recalculate();
 	}
 	/// @}
 
@@ -183,6 +199,9 @@ public:
 	/// Implements CollisionShape::testPlane
 	float testPlane(const Plane& p) const;
 
+	/// Implements CollisionShape::transform
+	virtual void transform(const Transform& trf);
+
 	/// Calculate and get transformed
 	PerspectiveFrustum getTransformed(const Transform& trf) const
 	{
@@ -191,9 +210,6 @@ public:
 		return o;
 	}
 
-	/// Re-implements Frustum::transform
-	void transform(const Transform& trf);
-
 	/// Implements Frustum::calculateProjectionMatrix
 	Mat4 calculateProjectionMatrix() const;
 
@@ -203,8 +219,8 @@ public:
 private:
 	/// @name Shape
 	/// @{
-	Vec3 eye; ///< The eye point
-	std::array<Vec3, 4> dirs; ///< Directions
+	mutable Vec3 eye; ///< The eye point
+	mutable std::array<Vec3, 4> dirs; ///< Directions
 	/// @}
 
 	/// @name Viewing variables
@@ -213,9 +229,14 @@ private:
 	float fovY;
 	/// @}
 
-	/// Implements CollisionShape::recalculate. Recalculate @a planes, @a eye
-	/// and @a dirs
-	void recalculate();
+	/// Implements CollisionShape::recalculatePlanes
+	void recalculatePlanes() const;
+
+	/// Recalculate @a eye and @a dirs
+	void recalculateShape() const;
+
+	/// Transform @a eye and @a dirs
+	void transformShape() const;
 };
 
 /// Frustum shape for orthographic cameras
@@ -252,40 +273,52 @@ public:
 	{
 		return left;
 	}
+	float& getLeft()
+	{
+		return left;
+	}
 	void setLeft(float f)
 	{
 		left = f;
-		recalculate();
 	}
 
 	float getRight() const
 	{
 		return right;
 	}
+	float& getRight()
+	{
+		return right;
+	}
 	void setRight(float f)
 	{
 		right = f;
-		recalculate();
 	}
 
 	float getTop() const
 	{
 		return top;
 	}
+	float& getTop()
+	{
+		return top;
+	}
 	void setTop(float f)
 	{
 		top = f;
-		recalculate();
 	}
 
 	float getBottom() const
 	{
 		return bottom;
 	}
+	float& getBottom()
+	{
+		return bottom;
+	}
 	void setBottom(float f)
 	{
 		bottom = f;
-		recalculate();
 	}
 
 	/// Set all
@@ -298,12 +331,6 @@ public:
 		zFar = zFar_;
 		top = top_;
 		bottom = bottom_;
-		recalculate();
-	}
-
-	const Obb& getObb() const
-	{
-		return obb;
 	}
 	/// @}
 
@@ -325,7 +352,7 @@ public:
 private:
 	/// @name Shape
 	/// @{
-	Obb obb; ///< Including shape
+	mutable Obb obb; ///< Including shape
 	/// @}
 
 	/// @name Viewing variables
@@ -333,9 +360,15 @@ private:
 	float left, right, top, bottom;
 	/// @}
 
-	/// Implements CollisionShape::recalculate. Recalculate @a planes and
-	/// @a obb
-	void recalculate();
+	/// Implements Frustum::recalculatePlanes
+	void recalculatePlanes() const;
+
+	void recalculateShape() const;
+
+	void transformShape() const
+	{
+		obb.transform(trf);
+	}
 };
 /// @}
 

+ 0 - 10
include/anki/math/Math.inl.h

@@ -1,9 +1,7 @@
 #include "anki/math/MathCommonSrc.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 inline float Math::sqrt(const float f)
 {
@@ -18,42 +16,36 @@ inline float Math::sqrt(const float f)
 #endif
 }
 
-
 //==============================================================================
 inline float Math::toRad(const float degrees)
 {
 	return degrees * (Math::PI / 180.0);
 }
 
-
 //==============================================================================
 inline float Math::toDegrees(const float rad)
 {
 	return rad * (180.0 / Math::PI);
 }
 
-
 //==============================================================================
 inline float Math::sin(const float rad)
 {
 	return ::sin(rad);
 }
 
-
 //==============================================================================
 inline float Math::cos(const float rad)
 {
 	return ::cos(rad);
 }
 
-
 //==============================================================================
 inline bool Math::isZero(const float f)
 {
 	return fabs(f) < EPSILON;
 }
 
-
 //==============================================================================
 inline void Math::combineTransformations(
 	const Vec3& t0, const Mat3& r0, const float s0,
@@ -65,7 +57,6 @@ inline void Math::combineTransformations(
 	sf = s0 * s1;
 }
 
-
 //==============================================================================
 inline void Math::combineTransformations(
 	const Vec3& t0, const Mat3& r0,
@@ -76,5 +67,4 @@ inline void Math::combineTransformations(
 	rf = r0 * r1;
 }
 
-
 } // end namespace

+ 1 - 0
include/anki/math/Transform.h

@@ -55,6 +55,7 @@ public:
 	/// Get the inverse transformation. Its faster that inverting a Mat4
 	Transform getInverse() const;
 	void invert();
+	void transform(const Transform& b);
 	/// @}
 
 	/// @name Friends

+ 8 - 0
include/anki/math/Transform.inl.h

@@ -150,6 +150,14 @@ inline void Transform::invert()
 	*this = getInverse();
 }
 
+// transform
+inline void Transform::transform(const Transform& b)
+{
+	origin = b.origin.getTransformed(origin, rotation, scale);
+	rotation = rotation * b.rotation;
+	scale *= b.scale;
+}
+
 //==============================================================================
 // Friends                                                                     =
 //==============================================================================

+ 0 - 4
include/anki/scene/Frustumable.h

@@ -4,10 +4,8 @@
 #include "anki/collision/Frustum.h"
 #include "anki/scene/Spatial.h"
 
-
 namespace anki {
 
-
 /// @addtogroup Scene
 /// @{
 
@@ -69,8 +67,6 @@ protected:
 	Frustum* frustum;
 };
 
-
 } // namespace anki
 
-
 #endif

+ 6 - 14
include/anki/scene/Light.h

@@ -8,10 +8,8 @@
 #include "anki/resource/Material.h"
 #include "anki/resource/Resource.h"
 
-
 namespace anki {
 
-
 /// Light scene node. It can be spot or point
 ///
 /// Explaining the lighting model:
@@ -40,9 +38,9 @@ public:
 
 	/// @name Constructors
 	/// @{
-	Light(LightType t, const char* mtl, // Light
+	Light(LightType t, // Light
 		const char* name, Scene* scene, // Scene
-		uint movableFlags, Movable* movParent, // Movable
+		uint32_t movableFlags, Movable* movParent, // Movable
 		CollisionShape* cs); // Spatial
 	/// @}
 
@@ -127,16 +125,14 @@ private:
 	bool shadow;
 };
 
-
 /// Point light
 class PointLight: public Light
 {
 public:
 	/// @name Constructors/Destructor
 	/// @{
-	PointLight(const char* fmtl,
-		const char* name, Scene* scene,
-		uint movableFlags, Movable* movParent);
+	PointLight(const char* name, Scene* scene,
+		uint32_t movableFlags, Movable* movParent);
 	/// @}
 
 	/// @name Accessors
@@ -172,7 +168,6 @@ public:
 	Sphere sphereL;
 };
 
-
 /// Spot light
 class SpotLight: public Light, public Frustumable
 {
@@ -181,9 +176,8 @@ public:
 
 	/// @name Constructors/Destructor
 	/// @{
-	SpotLight(const char* fmtl,
-		const char* name, Scene* scene,
-		uint movableFlags, Movable* movParent);
+	SpotLight(const char* name, Scene* scene,
+		uint32_t movableFlags, Movable* movParent);
 	/// @}
 
 	/// @name Accessors
@@ -278,8 +272,6 @@ private:
 	ANKI_SLOT(updateFov, const float&)
 };
 
-
 } // end namespace
 
-
 #endif

+ 39 - 27
src/collision/Frustum.cpp

@@ -11,15 +11,20 @@ namespace anki {
 //==============================================================================
 Frustum& Frustum::operator=(const Frustum& b)
 {
-	planes = b.planes;
+	ANKI_ASSERT(type == b.type);
 	zNear = b.zNear;
 	zFar = b.zFar;
+	trf = b.trf;
+	planes = b.planes;
 	return *this;
 }
 
 //==============================================================================
 bool Frustum::insideFrustum(const CollisionShape& b) const
 {
+	recalculatePlanes();
+	transformPlanes();
+
 	for(const Plane& plane : planes)
 	{
 		if(b.testPlane(plane) < 0.0)
@@ -31,16 +36,6 @@ bool Frustum::insideFrustum(const CollisionShape& b) const
 	return true;
 }
 
-//==============================================================================
-void Frustum::transform(const Transform& trf)
-{
-	// Planes
-	for(Plane& p : planes)
-	{
-		p.transform(trf);
-	}
-}
-
 //==============================================================================
 // PerspectiveFrustum                                                          =
 //==============================================================================
@@ -59,6 +54,9 @@ PerspectiveFrustum& PerspectiveFrustum::operator=(const PerspectiveFrustum& b)
 //==============================================================================
 float PerspectiveFrustum::testPlane(const Plane& p) const
 {
+	recalculateShape();
+	transformShape();
+
 	float o = 0.0;
 
 	for(const Vec3& dir : dirs)
@@ -66,7 +64,7 @@ float PerspectiveFrustum::testPlane(const Plane& p) const
 		LineSegment ls(eye, dir);
 		float t = ls.testPlane(p);
 
-		if(t == 0)
+		if(t == 0.0)
 		{
 			return 0.0;
 		}
@@ -84,10 +82,16 @@ float PerspectiveFrustum::testPlane(const Plane& p) const
 }
 
 //==============================================================================
-void PerspectiveFrustum::transform(const Transform& trf)
+void PerspectiveFrustum::transform(const Transform& trf_)
 {
-	Frustum::transform(trf);
+	trf.transform(trf_);
+	transformPlanes();
+	transformShape();
+}
 
+//==============================================================================
+void PerspectiveFrustum::transformShape() const
+{
 	eye.transform(trf);
 
 	for(Vec3& dir : dirs)
@@ -99,16 +103,17 @@ void PerspectiveFrustum::transform(const Transform& trf)
 //==============================================================================
 void PerspectiveFrustum::getAabb(Aabb& aabb) const
 {
+	recalculateShape();
+	transformShape();
+
 	aabb.set(dirs);
 	aabb.getMin() += eye;
 	aabb.getMax() += eye;
 }
 
 //==============================================================================
-void PerspectiveFrustum::recalculate()
+void PerspectiveFrustum::recalculatePlanes() const
 {
-	// Planes
-	//
 	float c, s; // cos & sine
 
 	Math::sinCos(Math::PI + fovX / 2, s, c);
@@ -127,9 +132,11 @@ void PerspectiveFrustum::recalculate()
 	planes[FP_NEAR] = Plane(Vec3(0.0, 0.0, -1.0), zNear);
 	// far
 	planes[FP_FAR] = Plane(Vec3(0.0, 0.0, 1.0), -zFar);
+}
 
-	// Rest
-	//
+//==============================================================================
+void PerspectiveFrustum::recalculateShape() const
+{
 	eye = Vec3(0.0, 0.0, -zNear);
 
 	float x = zFar / tan((Math::PI - fovX) / 2.0);
@@ -190,19 +197,24 @@ OrthographicFrustum& OrthographicFrustum::operator=(
 //==============================================================================
 float OrthographicFrustum::testPlane(const Plane& p) const
 {
+	recalculateShape();
+	transformShape();
 	return obb.testPlane(p);
 }
 
 //==============================================================================
-void OrthographicFrustum::transform(const Transform& trf)
+void OrthographicFrustum::transform(const Transform& trf_)
 {
-	Frustum::transform(trf);
-	obb.transform(trf);
+	trf.transform(trf_);
+	transformPlanes();
+	transformShape();
 }
 
 //==============================================================================
 void OrthographicFrustum::getAabb(Aabb& aabb) const
 {
+	recalculateShape();
+	transformShape();
 	obb.getAabb(aabb);
 }
 
@@ -238,19 +250,19 @@ Mat4 OrthographicFrustum::calculateProjectionMatrix() const
 }
 
 //==============================================================================
-void OrthographicFrustum::recalculate()
+void OrthographicFrustum::recalculatePlanes() const
 {
-	// Planes
-	//
 	planes[FP_LEFT] = Plane(Vec3(1.0, 0.0, 0.0), left);
 	planes[FP_RIGHT] = Plane(Vec3(-1.0, 0.0, 0.0), -right);
 	planes[FP_NEAR] = Plane(Vec3(0.0, 0.0, -1.0), zNear);
 	planes[FP_FAR] = Plane(Vec3(0.0, 0.0, 1.0), -zFar);
 	planes[FP_TOP] = Plane(Vec3(0.0, -1.0, 0.0), -top);
 	planes[FP_BOTTOM] = Plane(Vec3(0.0, 1.0, 0.0), bottom);
+}
 
-	// OBB
-	//
+//==============================================================================
+void OrthographicFrustum::recalculateShape() const
+{
 	Vec3 c((right + left) * 0.5, (top + bottom) * 0.5, - (zFar + zNear) * 0.5);
 	Vec3 e = Vec3(right, top, -zFar) - c;
 	obb = Obb(c, Mat3::getIdentity(), e);

+ 8 - 16
src/scene/Light.cpp

@@ -1,18 +1,16 @@
 #include "anki/scene/Light.h"
 #include "anki/resource/LightRsrc.h"
 
-
 namespace anki {
 
-
 //==============================================================================
 // Light                                                                       =
 //==============================================================================
 
 //==============================================================================
-Light::Light(LightType t, const char* fmtl, // Light
+Light::Light(LightType t, // Light
 	const char* name, Scene* scene, // Scene
-	uint movableFlags, Movable* movParent, // Movable
+	uint32_t movableFlags, Movable* movParent, // Movable
 	CollisionShape* cs) // Spatial
 	: SceneNode(name, scene),
 		Movable(movableFlags, movParent, *this),
@@ -26,21 +24,18 @@ Light::Light(LightType t, const char* fmtl, // Light
 	addNewProperty(new ReadWritePointerProperty<bool>("shadow", &shadow));
 }
 
-
 //==============================================================================
 Light::~Light()
 {}
 
-
 //==============================================================================
 // PointLight                                                                  =
 //==============================================================================
 
 //==============================================================================
-PointLight::PointLight(const char* fmtl,
-	const char* name, Scene* scene,
-	uint movableFlags, Movable* movParent)
-	: Light(LT_POINT, fmtl, name, scene, movableFlags, movParent, &sphereW)
+PointLight::PointLight(const char* name, Scene* scene,
+	uint32_t movableFlags, Movable* movParent)
+	: Light(LT_POINT, name, scene, movableFlags, movParent, &sphereW)
 {
 	sphereL.setCenter(Vec3(0.0));
 	sphereL.setRadius(1.0);
@@ -49,16 +44,14 @@ PointLight::PointLight(const char* fmtl,
 	addNewProperty(new ReadWritePointerProperty<float>("radius", &r));
 }
 
-
 //==============================================================================
 // SpotLight                                                                   =
 //==============================================================================
 
 //==============================================================================
-SpotLight::SpotLight(const char* fmtl,
-	const char* name, Scene* scene,
-	uint movableFlags, Movable* movParent)
-	: Light(LT_SPOT, fmtl, name, scene, movableFlags, movParent, &frustum),
+SpotLight::SpotLight(const char* name, Scene* scene,
+	uint32_t movableFlags, Movable* movParent)
+	: Light(LT_SPOT, name, scene, movableFlags, movParent, &frustum),
 		Frustumable(&frustum)
 {
 	// Fov
@@ -80,5 +73,4 @@ SpotLight::SpotLight(const char* fmtl,
 	frustum.setAll(ang, ang, 0.1, dist);
 }
 
-
 } // end namespace

+ 9 - 95
testapp/Main.cpp

@@ -39,83 +39,10 @@
 #include "anki/resource/Material.h"
 #include "anki/core/ParallelManager.h"
 
-
 using namespace anki;
 
-
-// map (hard coded)
-ModelNode* floor__,* sarge,* horse,* crate,* pentagram;
-SkinNode* imp;
-//SkelModelNode* imp;
-PointLight* point_lights[10];
-SpotLight* spot_lights[2];
-//ParticleEmitter* partEmitter;
-Character* character;
-
 UiPainter* painter;
 
-
-// Physics
-std::vector<btRigidBody*> boxes;
-
-#define ARRAY_SIZE_X 5
-#define ARRAY_SIZE_Y 5
-#define ARRAY_SIZE_Z 5
-
-#define MAX_PROXIES (ARRAY_SIZE_X*ARRAY_SIZE_Y*ARRAY_SIZE_Z + 1024)
-
-#define SCALING 1.
-#define START_POS_X -5
-#define START_POS_Y -5
-#define START_POS_Z -3
-
-
-void initPhysics()
-{
-	btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
-
-	Transform groundTransform;
-	groundTransform.setIdentity();
-	groundTransform.setOrigin(Vec3(0,-50, 0));
-
-	RigidBody::Initializer init;
-	init.mass = 0.0;
-	init.shape = groundShape;
-	init.startTrf = groundTransform;
-
-	new RigidBody(SceneSingleton::get().getPhysWorld(), init);
-
-
-	/*{
-		btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
-
-		float start_x = START_POS_X - ARRAY_SIZE_X/2;
-		float start_y = START_POS_Y;
-		float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
-
-		for (int k=0;k<ARRAY_SIZE_Y;k++)
-		{
-			for (int i=0;i<ARRAY_SIZE_X;i++)
-			{
-				for(int j = 0;j<ARRAY_SIZE_Z;j++)
-				{
-					//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
-					MeshNode* crate = new MeshNode;
-					crate->init("models/crate0/crate0.mesh");
-					crate->getLocalTransform().setScale(1.11);
-
-					Transform trf(SCALING*Vec3(2.0*i + start_x, 20+2.0*k + start_y, 2.0*j + start_z), Mat3::getIdentity(), 1.0);
-					new RigidBody(1.0, trf, colShape, crate, Physics::CG_MAP, Physics::CG_ALL);
-				}
-			}
-		}
-	}*/
-}
-
-
-
-//==============================================================================
-// init                                                                        =
 //==============================================================================
 void init()
 {
@@ -123,38 +50,25 @@ void init()
 
 	Scene& scene = SceneSingleton::get();
 
-	/*Material mtl;
-	mtl.load("lala.mtl");*/
-
-	srand(unsigned(time(NULL)));
-
 	painter = new UiPainter(Vec2(AppSingleton::get().getWindowWidth(),
 		AppSingleton::get().getWindowHeight()));
 	painter->setFont("engine-rsrc/ModernAntiqua.ttf", 25, 25);
 
 	// camera
-	PerspectiveCamera* cam = new PerspectiveCamera(scene, SceneNode::SNF_NONE, NULL);
-	//cam->setAll(toRad(100.0), toRad(100.0) / r::MainRendererSingleton::get().getAspectRatio(), 0.5, 200.0);
-	ANKI_LOGI(MainRendererSingleton::get().getAspectRatio());
-	cam->setAll(MainRendererSingleton::get().getAspectRatio()*Math::toRad(70.0), Math::toRad(70.0), 0.5, 200.0);
+	PerspectiveCamera* cam = new PerspectiveCamera("main-camera", &scene,
+		Movable::MF_NONE, nullptr);
+	const float ang = 70.0;
+	cam->setAll(
+		MainRendererSingleton::get().getAspectRatio() * Math::toRad(ang),
+		Math::toRad(ang), 0.5, 200.0);
 	cam->moveLocalY(3.0);
 	cam->moveLocalZ(5.7);
 	cam->moveLocalX(-0.3);
-	AppSingleton::get().setActiveCam(cam);
-	ANKI_LOGI(cam->getSceneNodeName());
-
-	OrthographicCamera* ocam = new OrthographicCamera(scene, SceneNode::SNF_NONE, NULL);
-	ocam->setAll(-1, 1, 1.0, -1.0, 0.1, 10.0);
+	scene.setActiveCamera(cam);
 
 	// lights
-	point_lights[0] = new PointLight(scene, SceneNode::SNF_NONE, NULL);
-	point_lights[0]->init("maps/temple/light0.light");
-	point_lights[0]->setLocalTransform(Transform(Vec3(-1.0, 2.4, 1.0), Mat3::getIdentity(), 1.0));
-	point_lights[1] = new PointLight(scene, SceneNode::SNF_NONE, NULL);
-	point_lights[1]->init("maps/temple/light1.light");
-	point_lights[1]->setLocalTransform(Transform(Vec3(2.5, 1.4, 1.0), Mat3::getIdentity(), 1.0));
-
-	spot_lights[0] = new SpotLight(scene, SceneNode::SNF_NONE, NULL);
+
+	SpotLight* spot = new SpotLight("spot0", &scene, Movable::MF_NONE, nullptr);
 	spot_lights[0]->init("maps/temple/light2.light");
 	spot_lights[0]->setLocalTransform(Transform(Vec3(1.3, 4.3, 3.0), Mat3(Euler(Math::toRad(-20), Math::toRad(20), 0.0)), 1.0));
 	spot_lights[1] = new SpotLight(scene, SceneNode::SNF_NONE, NULL);