Browse Source

Scene. It compiles

Panagiotis Christopoulos Charitos 14 years ago
parent
commit
5e61847a80

+ 10 - 8
src/Main.cpp

@@ -127,6 +127,8 @@ void init()
 {
 	INFO("Other init...");
 
+	Scene& scene = SceneSingleton::get();
+
 	/*Material mtl;
 	mtl.load("lala.mtl");*/
 
@@ -137,7 +139,7 @@ void init()
 	painter->setFont("engine-rsrc/ModernAntiqua.ttf", 25, 25);
 
 	// camera
-	PerspectiveCamera* cam = new PerspectiveCamera(false, NULL);
+	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);
 	cam->setAll(MainRendererSingleton::get().getAspectRatio()*Math::toRad(60.0), Math::toRad(60.0), 0.5, 200.0);
 	cam->moveLocalY(3.0);
@@ -146,27 +148,27 @@ void init()
 	AppSingleton::get().setActiveCam(cam);
 	INFO(cam->getSceneNodeName());
 
-	OrthographicCamera* ocam = new OrthographicCamera(false, NULL);
+	OrthographicCamera* ocam = new OrthographicCamera(scene, SceneNode::SNF_NONE, NULL);
 	ocam->setAll(-1, 1, 1.0, -1.0, 0.1, 10.0);
 
 	// lights
-	point_lights[0] = new PointLight(false, NULL);
+	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(false, NULL);
+	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(false, NULL);
+	spot_lights[0] = new SpotLight(scene, SceneNode::SNF_NONE, NULL);
 	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(false, NULL);
+	spot_lights[1] = new SpotLight(scene, SceneNode::SNF_NONE, NULL);
 	spot_lights[1]->init("maps/temple/light3.light");
 	spot_lights[1]->setLocalTransform(Transform(Vec3(-2.3, 6.3, 2.9), Mat3(Euler(Math::toRad(-70), Math::toRad(-20), 0.0)), 1.0));
 
 
 	// horse
-	horse = new ModelNode(false, NULL);
+	horse = new ModelNode(scene, SceneNode::SNF_NONE, NULL);
 	horse->init("meshes/horse/horse.mdl");
 	horse->setLocalTransform(Transform(Vec3(-2, 0, 0), Mat3::getIdentity(), 1.0));
 
@@ -176,7 +178,7 @@ void init()
 	pentagram->setLocalTransform(Transform(Vec3(2, 0, 0), Mat3::getIdentity(), 1.0));*/
 
 	// Sponza
-	ModelNode* sponza = new ModelNode(false, NULL);
+	ModelNode* sponza = new ModelNode(scene, SceneNode::SNF_NONE, NULL);
 	//sponza->init("maps/sponza/sponza.mdl");
 	sponza->init("maps/sponza-crytek/sponza_crytek.mdl");
 	sponza->setLocalTransform(Transform(Vec3(0.0), Mat3::getIdentity(), 0.05));

+ 3 - 3
src/r/Dbg.cpp

@@ -287,11 +287,11 @@ void Dbg::run()
 			case SceneNode::SNT_LIGHT:
 				sceneDbgDrawer.drawLight(static_cast<const Light&>(*node));
 				break;
-			case SceneNode::SNT_PARTICLE_EMITTER:
+			case SceneNode::SNT_PARTICLE_EMITTER_NODE:
 				sceneDbgDrawer.drawParticleEmitter(
 					static_cast<const ParticleEmitterNode&>(*node));
 				break;
-			case SceneNode::SNT_RENDERABLE:
+			case SceneNode::SNT_RENDERABLE_NODE:
 				/*if(showVisibilityBoundingShapesFlag)
 				{
 					const RenderableNode& rnode =
@@ -299,7 +299,7 @@ void Dbg::run()
 					collisionDbgDrawer.draw(rnode. getVisibilityShapeWSpace());
 				}*/
 				break;
-			case SceneNode::SNT_SKIN:
+			case SceneNode::SNT_SKIN_NODE:
 			{
 				const SkinNode& node_ = static_cast<const SkinNode&>(*node);
 				sceneDbgDrawer.drawSkinNodeSkeleton(node_);

+ 2 - 2
src/r/Deformer.cpp

@@ -40,8 +40,8 @@ void Deformer::init()
 void Deformer::deform(SkinPatchNode& node) const
 {
 	ASSERT(node.getParent() != NULL); // The SkinPatchNodes always have parent
-	ASSERT(static_cast<SceneNode*>(node.getParent())->getSceneNodeType() ==
-		SceneNode::SNT_SKIN); // And their parent must be SkinNode
+	ASSERT(node.getParent()->getSceneNodeType() ==
+		SceneNode::SNT_SKIN_NODE); // And their parent must be SkinNode
 	ASSERT(node.isFlagEnabled(SceneNode::SNF_VISIBLE)); // And it should be
 	                                                    // visible
 

+ 8 - 8
src/r/Is.cpp

@@ -190,11 +190,11 @@ void Is::pointLightPass(const PointLight& light)
 	const Vec3& origin = light.getWorldTransform().getOrigin();
 	Vec3 lightPosEyeSpace = origin.getTransformed(cam.getViewMatrix());
 	shader.getUniformVariableByName("lightPos").set(&lightPosEyeSpace);
-	shader.getUniformVariableByName("lightRadius").set(&light.getRadius());
+	shader.getUniformVariableByName("lightRadius").set(light.getRadius());
 	shader.getUniformVariableByName("lightDiffuseCol").set(
-		&light.getDiffuseCol());
+		&light.getDiffuseColor());
 	shader.getUniformVariableByName("lightSpecularCol").set(
-		&light.getSpecularCol());
+		&light.getSpecularColor());
 
 	// render quad
 	r.drawQuad();
@@ -209,7 +209,7 @@ void Is::spotLightPass(const SpotLight& light)
 	const Camera& cam = r.getCamera();
 
 	// shadow mapping
-	if(light.castsShadow() && sm.isEnabled())
+	if(light.getCastShadow() && sm.isEnabled())
 	{
 		Vec3 zAxis = light.getWorldTransform().getRotation().getColumn(2);
 		LineSegment seg(light.getWorldTransform().getOrigin(),
@@ -242,7 +242,7 @@ void Is::spotLightPass(const SpotLight& light)
 	// shader prog
 	const ShaderProgram* shdr;
 
-	if(light.castsShadow() && sm.isEnabled())
+	if(light.getCastShadow() && sm.isEnabled())
 	{
 		shdr = spotLightShadowSProg.get();
 	}
@@ -279,9 +279,9 @@ void Is::spotLightPass(const SpotLight& light)
 	float tmp = light.getDistance();
 	shdr->getUniformVariableByName("lightRadius").set(&tmp);
 	shdr->getUniformVariableByName("lightDiffuseCol").set(
-		&light.getDiffuseCol());
+		&light.getDiffuseColor());
 	shdr->getUniformVariableByName("lightSpecularCol").set(
-		&light.getSpecularCol());
+		&light.getSpecularColor());
 	shdr->getUniformVariableByName("lightTex").set(light.getTexture(), 4);
 
 	// set texture matrix for texture & shadowmap projection
@@ -295,7 +295,7 @@ void Is::spotLightPass(const SpotLight& light)
 	shdr->getUniformVariableByName("texProjectionMat").set(&texProjectionMat);
 
 	// the shadowmap
-	if(light.castsShadow() && sm.isEnabled())
+	if(light.getCastShadow() && sm.isEnabled())
 	{
 		shdr->getUniformVariableByName("shadowMap").set(sm.getShadowMap(), 5);
 		float smSize = sm.getShadowMap().getWidth();

+ 1 - 1
src/r/Renderer.cpp

@@ -86,7 +86,7 @@ void Renderer::render(Camera& cam_)
 	//
 	calcPlanes(Vec2(cam->getZNear(), cam->getZFar()), planes);
 
-	ASSERT(cam->getType() == Camera::CT_PERSPECTIVE);
+	ASSERT(cam->getCameraType() == Camera::CT_PERSPECTIVE);
 	const PerspectiveCamera& pcam = static_cast<const PerspectiveCamera&>(*cam);
 	calcLimitsOfNearPlane(pcam, limitsOfNearPlane);
 	limitsOfNearPlane2 = limitsOfNearPlane * 2.0;

+ 2 - 2
src/r/SceneDbgDrawer.cpp

@@ -13,7 +13,7 @@
 //==============================================================================
 void SceneDbgDrawer::drawCamera(const Camera& cam) const
 {
-	switch(cam.getType())
+	switch(cam.getCameraType())
 	{
 		case Camera::CT_PERSPECTIVE:
 		{
@@ -116,7 +116,7 @@ void SceneDbgDrawer::drawOrthographicCamera(
 //==============================================================================
 void SceneDbgDrawer::drawLight(const Light& light) const
 {
-	dbg.setColor(light.getDiffuseCol());
+	dbg.setColor(light.getDiffuseColor());
 	dbg.setModelMat(Mat4(light.getWorldTransform()));
 	dbg.drawSphere(0.1);
 }

+ 1 - 1
src/r/Sm.cpp

@@ -143,7 +143,7 @@ void Sm::run(const Light& light, float distance)
 	BOOST_FOREACH(const RenderableNode* node,
 		light.getVisibleMsRenderableNodes())
 	{
-		switch(light.getType())
+		switch(light.getLightType())
 		{
 			case Light::LT_SPOT:
 			{

+ 2 - 2
src/r/Smo.cpp

@@ -173,9 +173,9 @@ void Smo::run(const SpotLight& light)
 
 	// Calc the camera shape scale matrix
 	Mat4 localMat(Mat4::getIdentity());
-	const Geom& cg = camGeom[lcam.getType()];
+	const Geom& cg = camGeom[lcam.getCameraType()];
 
-	switch(lcam.getType())
+	switch(lcam.getCameraType())
 	{
 		case Camera::CT_PERSPECTIVE:
 		{

+ 8 - 0
src/rsrc/ShaderProgramUniformVariable.cpp

@@ -21,6 +21,14 @@ void ShaderProgramUniformVariable::doSanityChecks() const
 // set uniforms                                                                =
 //==============================================================================
 
+void ShaderProgramUniformVariable::set(const float f) const
+{
+	doSanityChecks();
+	ASSERT(getGlDataType() == GL_FLOAT);
+
+	glUniform1f(getLoc(), f);
+}
+
 void ShaderProgramUniformVariable::set(const float f[], uint size) const
 {
 	doSanityChecks();

+ 1 - 0
src/rsrc/ShaderProgramUniformVariable.h

@@ -20,6 +20,7 @@ class ShaderProgramUniformVariable: public ShaderProgramVariable
 
 		/// @name Set the var
 		/// @{
+		void set(const float f) const;
 		void set(const float f[], uint size = 1) const;
 		void set(const Vec2 v2[], uint size = 1) const;
 		void set(const Vec3 v3[], uint size = 1) const;

+ 18 - 14
src/scene/Camera.h

@@ -21,6 +21,13 @@ class PointLight;
 class Camera: public SceneNode, public VisibilityInfo
 {
 	public:
+		enum CameraType
+		{
+			CT_ORTHOGRAPHIC,
+			CT_PERSPECTIVE,
+			CT_NUM
+		};
+
 		enum FrustrumPlanes
 		{
 			FP_LEFT = 0,
@@ -32,14 +39,14 @@ class Camera: public SceneNode, public VisibilityInfo
 			FP_NUM
 		};
 
-		Camera(ClassId cid, Scene& scene, ulong flags, SceneNode* parent);
+		Camera(CameraType type, Scene& scene, ulong flags, SceneNode* parent);
 
 		virtual ~Camera();
 
-		static bool classof(const SceneNode* x);
-
 		/// @name Accessors
 		/// @{
+		CameraType getCameraType() const {return type;}
+
 		float getZNear() const {return zNear;}
 		float& getZNear() {return zNear;}
 		void setZNear(float znear);
@@ -49,6 +56,7 @@ class Camera: public SceneNode, public VisibilityInfo
 		void setZFar(float zfar);
 
 		const Mat4& getProjectionMatrix() const {return projectionMat;}
+
 		const Mat4& getViewMatrix() const {return viewMat;}
 
 		/// See the declaration of invProjectionMat for info
@@ -108,27 +116,23 @@ class Camera: public SceneNode, public VisibilityInfo
 		/// Get the edge points of the camera
 		virtual void getExtremePoints(Vec3* pointsArr,
 			uint& pointsNum) const = 0;
+
+	private:
+		CameraType type;
 };
 /// @}
 
 
 
-inline Camera::Camera(ClassId cid, Scene& scene, ulong flags,
-			SceneNode* parent)
-:	SceneNode(cid, scene, flags, parent)
+inline Camera::Camera(CameraType t, Scene& scene, ulong flags,
+	SceneNode* parent)
+:	SceneNode(SNT_CAMERA, scene, flags, parent),
+ 	type(t)
 {
 	name = "Camera:" + name;
 }
 
 
-inline bool Camera::classof(const SceneNode* x)
-{
-	return x->getClassId() == CID_CAMERA ||
-		x->getClassId() == CID_PERSPECTIVE_CAMERA ||
-		x->getClassId() == CID_ORTHOGRAPHIC_CAMERA;
-}
-
-
 inline const Plane& Camera::getWSpaceFrustumPlane(FrustrumPlanes id) const
 {
 	return wspaceFrustumPlanes[id];

+ 15 - 13
src/scene/Light.h

@@ -27,12 +27,20 @@
 class Light: public SceneNode, public VisibilityInfo
 {
 	public:
-		virtual ~Light();
+		enum LightType
+		{
+			LT_POINT,
+			LT_SPOT
+		};
+
+		Light(LightType type, Scene& scene, ulong flags, SceneNode* parent);
 
-		static bool classof(const SceneNode* x);
+		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;}
@@ -54,21 +62,15 @@ class Light: public SceneNode, public VisibilityInfo
 		Vec3 specularCol; ///< Specular color
 		bool castsShadowFlag; ///< Casts shadow
 
-		Light(ClassId cid, Scene& scene, ulong flags, SceneNode* parent);
+	private:
+		LightType type;
 };
 
 
-inline Light::Light(ClassId cid, Scene& scene, ulong flags, SceneNode* parent)
-:	SceneNode(cid, scene, flags, parent)
+inline Light::Light(LightType t, Scene& scene, ulong flags, SceneNode* parent)
+:	SceneNode(SNT_LIGHT, scene, flags, parent),
+ 	type(t)
 {}
 
 
-inline bool Light::classof(const SceneNode* x)
-{
-	return x->getClassId() == CID_LIGHT ||
-		x->getClassId() == CID_POINT_LIGHT ||
-		x->getClassId() == CID_SPOT_LIGHT;
-}
-
-
 #endif

+ 2 - 7
src/scene/ModelNode.cpp

@@ -9,12 +9,7 @@
 //==============================================================================
 
 ModelNode::ModelNode(Scene& scene, ulong flags, SceneNode* parent)
-:	SceneNode(CID_MODEL_NODE, scene, flags, parent)
-{}
-
-
-ModelNode::ModelNode(ClassId cid, Scene& scene, ulong flags, SceneNode* parent)
-:	SceneNode(cid, scene, flags, parent)
+:	SceneNode(SNT_MODEL_NODE, scene, flags, parent)
 {}
 
 
@@ -31,7 +26,7 @@ void ModelNode::init(const char* filename)
 
 	BOOST_FOREACH(const ModelPatch& patch, model->getModelPatches())
 	{
-		patches.push_back(new ModelPatchNode(patch, this));
+		patches.push_back(new ModelPatchNode(patch, *this));
 	}
 }
 

+ 6 - 15
src/scene/ModelNode.h

@@ -20,13 +20,15 @@ class ModelNode: public SceneNode
 		ModelNode(Scene& scene, ulong flags, SceneNode* parent);
 		virtual ~ModelNode();
 
-		static bool classof(const SceneNode* x);
-
 		/// @name Accessors
 		/// @{
-		GETTER_RW(Vec<ModelPatchNode*>, patches, getModelPatchNodes)
+		const Vec<ModelPatchNode*>& getModelPatchNodes() const {return patches;}
+		Vec<ModelPatchNode*>& getModelPatchNodes() {return patches;}
+
 		const Model& getModel() const {return *model;}
-		GETTER_R(Obb, visibilityShapeWSpace, getVisibilityShapeWSpace)
+
+		const Obb& getVisibilityShapeWSpace() const
+			{return visibilityShapeWSpace;}
 		/// @}
 
 		/// Initialize the node
@@ -36,10 +38,6 @@ class ModelNode: public SceneNode
 		/// Update the bounding shape
 		void moveUpdate();
 
-	protected:
-		/// Constructor for class derivatives
-		ModelNode(ClassId cid, Scene& scene, ulong flags, SceneNode* parent);
-
 	private:
 		RsrcPtr<Model> model;
 		Vec<ModelPatchNode*> patches;
@@ -47,11 +45,4 @@ class ModelNode: public SceneNode
 };
 
 
-inline bool ModelNode::classof(const SceneNode* x)
-{
-	return x->getClassId() == CID_MODEL_NODE ||
-		x->getClassId() == CID_PARTICLE;
-}
-
-
 #endif

+ 1 - 1
src/scene/ModelPatchNode.cpp

@@ -11,7 +11,7 @@
 // Constructor                                                                 =
 //==============================================================================
 ModelPatchNode::ModelPatchNode(const ModelPatch& modelPatch, ModelNode& parent)
-:	PatchNode(CID_MODEL_PATCH_NODE, modelPatch, SNF_NONE, parent)
+:	PatchNode(modelPatch, SNF_NONE, parent)
 {
 	VboArray vboArr;
 

+ 3 - 8
src/scene/ModelPatchNode.h

@@ -14,9 +14,10 @@ class ModelPatchNode: public PatchNode
 	public:
 		ModelPatchNode(const ModelPatch& modelPatch, ModelNode& parent);
 
-		static bool classof(const SceneNode* x);
+		const Obb& getVisibilityShapeWSpace() const
+			{return visibilityShapeWSpace;}
 
-		GETTER_R(Obb, visibilityShapeWSpace, getVisibilityShapeWSpace)
+		void init(const char*) {}
 
 		virtual void moveUpdate(); ///< Update the visibility shape
 
@@ -25,10 +26,4 @@ class ModelPatchNode: public PatchNode
 };
 
 
-inline bool ModelPatchNode::classof(const SceneNode* x)
-{
-	return x->getClassId() == CID_MODEL_PATCH_NODE;
-}
-
-
 #endif

+ 3 - 1
src/scene/OrthographicCamera.h

@@ -10,6 +10,8 @@ class OrthographicCamera: public Camera
 	public:
 		OrthographicCamera(Scene& scene, ulong flags, SceneNode* parent);
 
+		void init(const char*) {}
+
 		/// @name Accessors
 		/// @{
 		float getLeft() const {return left;}
@@ -61,7 +63,7 @@ class OrthographicCamera: public Camera
 
 inline OrthographicCamera::OrthographicCamera(Scene& scene, ulong flags,
 	SceneNode* parent)
-:	Camera(CID_ORTHOGRAPHIC_CAMERA, scene, flags, parent)
+:	Camera(CT_ORTHOGRAPHIC, scene, flags, parent)
 {
 	name = "OrthographicCamera:" + name;
 }

+ 1 - 1
src/scene/Particle.cpp

@@ -7,7 +7,7 @@
 //==============================================================================
 Particle::Particle(float timeOfDeath_, Scene& scene, ulong flags,
 	SceneNode* parent):
-	ModelNode(CID_PARTICLE, scene, flags, parent),
+	ModelNode(scene, flags, parent),
 	timeOfDeath(timeOfDeath_)
 {}
 

+ 1 - 1
src/scene/ParticleEmitterNode.h

@@ -39,7 +39,7 @@ class ParticleEmitterNode: public SceneNode, public ParticleEmitterRsrc
 
 inline ParticleEmitterNode::ParticleEmitterNode(Scene& scene, ulong flags,
 	SceneNode* parent)
-:	SceneNode(CID_PARTICLE_EMITTER_NODE, scene, flags, parent)
+:	SceneNode(SNT_PARTICLE_EMITTER_NODE, scene, flags, parent)
 {}
 
 

+ 2 - 2
src/scene/PatchNode.cpp

@@ -6,9 +6,9 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-PatchNode::PatchNode(ClassId cid, const ModelPatch& modelPatch, ulong flags,
+PatchNode::PatchNode(const ModelPatch& modelPatch, ulong flags,
 	SceneNode& parent)
-:	RenderableNode(cid, parent.getScene(), flags | SNF_INHERIT_PARENT_TRANSFORM,
+:	RenderableNode(parent.getScene(), flags | SNF_INHERIT_PARENT_TRANSFORM,
 		&parent),
 	rsrc(modelPatch),
 	mtlRun(new MaterialRuntime(rsrc.getMaterial()))

+ 2 - 12
src/scene/PatchNode.h

@@ -22,7 +22,8 @@ class PatchNode: public RenderableNode
 	public:
 		typedef boost::array<const Vbo*, Mesh::VBOS_NUM> VboArray;
 
-		static bool classof(const SceneNode* x);
+		PatchNode(const ModelPatch& modelPatch, ulong flags,
+			SceneNode& parent);
 
 		/// @name Accessors
 		/// @{
@@ -54,9 +55,6 @@ class PatchNode: public RenderableNode
 
 		boost::scoped_ptr<MaterialRuntime> mtlRun; ///< Material runtime
 
-		PatchNode(ClassId cid, const ModelPatch& modelPatch, ulong flags,
-			SceneNode& parent);
-
 		/// Create a VAO given a material and an array of VBOs
 		/// The location of the uniform variables are hard coded. See
 		/// MaterialVertex.glsl
@@ -66,12 +64,4 @@ class PatchNode: public RenderableNode
 };
 
 
-inline bool PatchNode::classof(const SceneNode* x)
-{
-	return x->getClassId() == CID_PATCH_NODE ||
-		x->getClassId() == CID_MODEL_PATCH_NODE ||
-		x->getClassId() == CID_SKIN_PATCH_NODE;
-}
-
-
 #endif

+ 5 - 3
src/scene/PerspectiveCamera.h

@@ -8,7 +8,9 @@
 class PerspectiveCamera: public Camera
 {
 	public:
-		PerspectiveCamera(bool inheritParentTrfFlag, SceneNode* parent);
+		PerspectiveCamera(Scene& scene, ulong flags, SceneNode* parent);
+
+		void init(const char*) {}
 
 		/// @name Accessors
 		/// @{
@@ -43,9 +45,9 @@ class PerspectiveCamera: public Camera
 };
 
 
-inline PerspectiveCamera::PerspectiveCamera(bool inheritParentTrfFlag,
+inline PerspectiveCamera::PerspectiveCamera(Scene& scene, ulong flags,
 	SceneNode* parent)
-:	Camera(CT_PERSPECTIVE, inheritParentTrfFlag, parent)
+:	Camera(CT_PERSPECTIVE, scene, flags, parent)
 {
 	name = "PerspectiveCamera:" + name;
 }

+ 8 - 4
src/scene/PointLight.h

@@ -8,8 +8,12 @@
 class PointLight: public Light
 {
 	public:
-		PointLight(bool inheritParentTrfFlag, SceneNode* parent);
-		GETTER_SETTER(float, radius, getRadius, setRadius)
+		PointLight(Scene& scene, ulong flags, SceneNode* parent);
+
+		float getRadius() const {return radius;}
+		float& getRadius() {return radius;}
+		void setRadius(float x) {radius = x;}
+
 		void init(const char* filename);
 
 	private:
@@ -17,8 +21,8 @@ class PointLight: public Light
 };
 
 
-inline PointLight::PointLight(bool inheritParentTrfFlag, SceneNode* parent)
-:	Light(LT_POINT, inheritParentTrfFlag, parent)
+inline PointLight::PointLight(Scene& scene, ulong flags, SceneNode* parent)
+:	Light(LT_POINT, scene, flags, parent)
 {}
 
 

+ 2 - 3
src/scene/RenderableNode.cpp

@@ -1,9 +1,8 @@
 #include "RenderableNode.h"
 
 
-RenderableNode::RenderableNode(ClassId cid, Scene& scene, ulong flags,
-	SceneNode* parent)
-:	SceneNode(cid, scene, flags, parent)
+RenderableNode::RenderableNode(Scene& scene, ulong flags, SceneNode* parent)
+:	SceneNode(SNT_RENDERABLE_NODE, scene, flags, parent)
 {}
 
 

+ 1 - 13
src/scene/RenderableNode.h

@@ -15,12 +15,9 @@ class MaterialRuntime;
 class RenderableNode: public SceneNode
 {
 	public:
-		RenderableNode(ClassId cid, Scene& scene, ulong flags,
-			SceneNode* parent);
+		RenderableNode(Scene& scene, ulong flags, SceneNode* parent);
 		virtual ~RenderableNode();
 
-		static bool classof(const SceneNode* x);
-
 		/// Get VAO depending the rendering pass
 		virtual const Vao& getVao(PassType p) const = 0;
 
@@ -38,13 +35,4 @@ class RenderableNode: public SceneNode
 };
 
 
-inline bool RenderableNode::classof(const SceneNode* x)
-{
-	return x->getClassId() == CID_RENDERABLE_NODE ||
-		x->getClassId() == CID_PATCH_NODE ||
-		x->getClassId() == CID_MODEL_PATCH_NODE ||
-		x->getClassId() == CID_SKIN_PATCH_NODE;
-}
-
-
 #endif

+ 11 - 12
src/scene/Scene.cpp

@@ -46,18 +46,18 @@ void Scene::registerNode(SceneNode* node)
 		case SceneNode::SNT_CAMERA:
 			putBackNode(cameras, static_cast<Camera*>(node));
 			break;
-		case SceneNode::SNT_PARTICLE_EMITTER:
+		case SceneNode::SNT_PARTICLE_EMITTER_NODE:
 			putBackNode(particleEmitterNodes,
 				static_cast<ParticleEmitterNode*>(node));
 			break;
-		case SceneNode::SNT_MODEL:
+		case SceneNode::SNT_MODEL_NODE:
 			putBackNode(modelNodes, static_cast<ModelNode*>(node));
 			break;
-		case SceneNode::SNT_SKIN:
+		case SceneNode::SNT_SKIN_NODE:
 			putBackNode(skinNodes, static_cast<SkinNode*>(node));
 			break;
-		case SceneNode::SNT_RENDERABLE:
-		case SceneNode::SNT_GHOST:
+		case SceneNode::SNT_RENDERABLE_NODE:
+		case SceneNode::SNT_GHOST_NODE:
 			break;
 	};
 }
@@ -78,18 +78,18 @@ void Scene::unregisterNode(SceneNode* node)
 		case SceneNode::SNT_CAMERA:
 			eraseNode(cameras, static_cast<Camera*>(node));
 			break;
-		case SceneNode::SNT_PARTICLE_EMITTER:
+		case SceneNode::SNT_PARTICLE_EMITTER_NODE:
 			eraseNode(particleEmitterNodes,
 				static_cast<ParticleEmitterNode*>(node));
 			break;
-		case SceneNode::SNT_MODEL:
+		case SceneNode::SNT_MODEL_NODE:
 			eraseNode(modelNodes, static_cast<ModelNode*>(node));
 			break;
-		case SceneNode::SNT_SKIN:
+		case SceneNode::SNT_SKIN_NODE:
 			eraseNode(skinNodes, static_cast<SkinNode*>(node));
 			break;
-		case SceneNode::SNT_RENDERABLE:
-		case SceneNode::SNT_GHOST:
+		case SceneNode::SNT_RENDERABLE_NODE:
+		case SceneNode::SNT_GHOST_NODE:
 			break;
 	};
 }
@@ -144,9 +144,8 @@ void Scene::updateAllWorldStuff(float prevUpdateTime, float crntTime)
 		pnode->moveUpdate();
 		++num;
 
-		BOOST_FOREACH(Object* obj, pnode->getChildren())
+		BOOST_FOREACH(SceneNode* node, pnode->getChildren())
 		{
-			SceneNode* node = static_cast<SceneNode*>(obj);
 			queue[tail++] = node;
 		}
 	}

+ 2 - 2
src/scene/SceneNode.cpp

@@ -15,9 +15,9 @@ uint SceneNode::uid = 0;
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-SceneNode::SceneNode(ClassId cid_, Scene& scene_, ulong flags_,
+SceneNode::SceneNode(SceneNodeType type_, Scene& scene_, ulong flags_,
 	SceneNode* parent_)
-:	cid(cid_),
+:	type(type_),
  	flags(flags_),
  	parent(parent_),
  	scene(scene_)

+ 32 - 30
src/scene/SceneNode.h

@@ -2,7 +2,6 @@
 #define SCENE_NODE_H
 
 #include "m/Math.h"
-#include "core/Object.h"
 #include "cln/Obb.h"
 #include "util/Accessors.h"
 #include "util/Vec.h"
@@ -25,23 +24,15 @@ class SceneNode
 		typedef Obb VisibilityCollisionShape;
 		
 		/// Class ID for scene nodes
-		enum ClassId
+		enum SceneNodeType
 		{
-			CID_CAMERA,
-			CID_CHOST_NODE,
-			CID_MODEL_NODE,
-			CID_LIGHT,
-			CID_MODEL_PATCH_NODE,
-			CID_ORTHOGRAPHIC_CAMERA,
-			CID_PARTICLE,
-			CID_PARTICLE_EMITTER_NODE,
-			CID_PATCH_NODE,
-			CID_PERSPECTIVE_CAMERA,
-			CID_POINT_LIGHT,
-			CID_RENDERABLE_NODE,
-			CID_SKIN_NODE,
-			CID_SKIN_PATCH_NODE,
-			CID_SPOT_LIGHT
+			SNT_CAMERA,
+			SNT_GHOST_NODE,
+			SNT_MODEL_NODE,
+			SNT_LIGHT,
+			SNT_PARTICLE_EMITTER_NODE,
+			SNT_RENDERABLE_NODE,
+			SNT_SKIN_NODE
 		};
 
 		enum SceneNodeFlags
@@ -55,30 +46,42 @@ class SceneNode
 		};
 
 		/// The one and only constructor
-		/// @param cid The class ID
+		/// @param type The type of the scene node
 		/// @param scene The scene to register the node
 		/// @param flags The flags with the node properties
 		/// @param parent The nods's parent. Its nulptr only for the root node
-		explicit SceneNode(ClassId cid, Scene& scene, ulong flags,
+		explicit SceneNode(SceneNodeType type, Scene& scene, ulong flags,
 			SceneNode* parent);
 
 		virtual ~SceneNode();
 
-		static bool classof(const SceneNode*) {return true;}
-
 		virtual void init(const char*) = 0; ///< init using a script file
 
 		/// @name Accessors
 		/// @{
-		GETTER_R_BY_VAL(ClassId, cid, getClassId)
-		GETTER_RW(Scene, scene, getScene)
-		GETTER_SETTER(Transform, lTrf, getLocalTransform, setLocalTransform)
-		GETTER_SETTER(Transform, wTrf, getWorldTransform, setWorldTransform)
-		GETTER_R(Transform, prevWTrf, getPrevWorldTransform)
+		SceneNodeType getSceneNodeType() const {return type;}
+
+		const Scene& getScene() const {return scene;}
+		Scene& getScene() {return scene;}
+
+		const Transform& getLocalTransform() const {return lTrf;}
+		Transform& getLocalTransform() {return lTrf;}
+		void setLocalTransform(const Transform& x) {lTrf = x;}
+
+		const Transform& getWorldTransform() const {return wTrf;}
+		Transform& getWorldTransform() {return wTrf;}
+		void setWorldTransform(const Transform& x) {wTrf = x;}
+
+		const Transform& getPrevWorldTransform() const {return prevWTrf;}
+
 		const SceneNode* getParent() const {return parent;}
 		SceneNode* getParent() {return parent;}
-		GETTER_RW(Vec<SceneNode*>, children, getChildren)
-		GETTER_R(std::string, name, getSceneNodeName)
+
+		const std::string& getSceneNodeName() const {return name;}
+
+		ulong getFlags() const {return flags;}
+
+		const Vec<SceneNode*>& getChildren() const {return children;}
 		/// @}
 
 		/// @name Flag manipulation
@@ -86,7 +89,6 @@ class SceneNode
 		void enableFlag(SceneNodeFlags flag, bool enable = true);
 		void disableFlag(SceneNodeFlags flag) {enableFlag(flag, false);}
 		bool isFlagEnabled(SceneNodeFlags flag) const {return flags & flag;}
-		GETTER_R_BY_VAL(ulong, flags, getFlags)
 		/// @}
 
 		/// @name Updates
@@ -127,7 +129,7 @@ class SceneNode
 	private:
 		static uint uid; ///< Unique identifier
 
-		ClassId cid; ///< Class ID
+		SceneNodeType type; ///< Type
 
 		Transform lTrf; ///< The transformation in local space
 

+ 3 - 3
src/scene/SkinNode.cpp

@@ -9,8 +9,8 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-SkinNode::SkinNode(bool inheritParentTrfFlag, SceneNode* parent)
-:	SceneNode(SNT_SKIN, inheritParentTrfFlag, parent)
+SkinNode::SkinNode(Scene& scene, ulong flags, SceneNode* parent)
+:	SceneNode(SNT_SKIN_NODE, scene, flags, parent)
 {}
 
 
@@ -30,7 +30,7 @@ void SkinNode::init(const char* filename)
 
 	BOOST_FOREACH(const ModelPatch& patch, skin->getModelPatches())
 	{
-		patches.push_back(new SkinPatchNode(patch, this));
+		patches.push_back(new SkinPatchNode(patch, *this));
 	}
 
 	uint bonesNum = skin->getSkeleton().getBones().size();

+ 1 - 1
src/scene/SkinNode.h

@@ -18,7 +18,7 @@ class SkinNode: public SceneNode
 	public:
 		SkelAnimModelNodeCtrl* skelAnimModelNodeCtrl; ///< @todo fix this crap
 
-		SkinNode(bool inheritParentTrfFlag, SceneNode* parent);
+		SkinNode(Scene& scene, ulong flags, SceneNode* parent);
 		~SkinNode();
 
 		/// @name Accessors

+ 2 - 2
src/scene/SkinPatchNode.cpp

@@ -8,8 +8,8 @@
 //==============================================================================
 // Constructor                                                                 =
 //==============================================================================
-SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent)
-:	PatchNode(modelPatch_, parent)
+SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode& parent)
+:	PatchNode(modelPatch_, SNF_NONE, parent)
 {
 	VboArray vboArr;
 

+ 3 - 1
src/scene/SkinPatchNode.h

@@ -33,7 +33,9 @@ class SkinPatchNode: public PatchNode
 			VERT_WEIGHT_WEIGHTS_LOC
 		};
 
-		SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent);
+		SkinPatchNode(const ModelPatch& modelPatch, SkinNode& parent);
+
+		void init(const char*) {}
 
 		/// @name Accessors
 		/// @{

+ 1 - 1
src/scene/SpotLight.cpp

@@ -11,7 +11,7 @@ void SpotLight::init(const char* filename)
 	{
 		throw EXCEPTION("Light data is wrong type");
 	}
-	camera = new PerspectiveCamera(true, this);
+	camera = new PerspectiveCamera(getScene(), SNF_NONE, this);
 	camera->setAll(lightData->getFovX(), lightData->getFovY(), 0.02,
 		lightData->getDistance());
 }

+ 6 - 11
src/scene/SpotLight.h

@@ -2,7 +2,7 @@
 #define SPOT_LIGHT_H
 
 #include "Light.h"
-//#include "PerspectiveCamera.h"
+#include "PerspectiveCamera.h"
 
 
 /// Spot light
@@ -12,19 +12,21 @@ class SpotLight: public Light
 		SpotLight(Scene& scene, ulong flags, SceneNode* parent);
 		~SpotLight() {}
 
-		static bool classof(const SceneNode* x);
-
 		void init(const char* filename);
 
 		/// @name Accessors
 		/// @{
 		float getDistance() const {return camera->getZFar();}
 		void setDistance(float d) {camera->setZFar(d);}
+
 		float getFovX() const {return camera->getFovX();}
 		void setFovX(float f) {camera->setFovX(f);}
+
 		float getFovY() const {return camera->getFovY();}
 		void setFovY(float f) {camera->setFovY(f);}
+
 		const Texture& getTexture() const {return lightData->getTexture();}
+
 		const Camera& getCamera() const {return *camera;}
 		Camera& getCamera() {return *camera;}
 		/// @}
@@ -35,15 +37,8 @@ class SpotLight: public Light
 
 
 inline SpotLight::SpotLight(Scene& scene, ulong flags, SceneNode* parent)
-:	Light(CID_SPOT_LIGHT, scene, flags, parent)
+:	Light(LT_SPOT, scene, flags, parent)
 {}
 
 
-bool SpotLight::classof(const SceneNode* x)
-{
-	return x->getClassId() == CID_LIGHT &&
-		static_cast<const Light*>(x)->getClassId() == CID_SPOT_LIGHT;
-}
-
-
 #endif

+ 1 - 1
src/scene/VisibilityTester.cpp

@@ -64,7 +64,7 @@ void VisibilityTester::test(Camera& cam)
 			continue;
 		}
 
-		switch(light->getType())
+		switch(light->getLightType())
 		{
 			// Point
 			case Light::LT_POINT: