فهرست منبع

New scene organisation

Panagiotis Christopoulos Charitos 15 سال پیش
والد
کامیت
74d425c05e

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
build/debug/Makefile


+ 1 - 1
src/Main.cpp

@@ -118,7 +118,7 @@ void init()
 	//Ui::init();
 
 	// camera
-	Camera* cam = new Camera(MainRendererSingleton::getInstance().getAspectRatio()*toRad(60.0), toRad(60.0), 0.5, 200.0);
+	Camera* cam = new Camera(MainRendererSingleton::getInstance().getAspectRatio()*toRad(60.0), toRad(60.0), 0.5, 200.0, false, NULL);
 	cam->moveLocalY(3.0);
 	cam->moveLocalZ(5.7);
 	cam->moveLocalX(-0.3);

+ 2 - 0
src/Math/Mat3.inl.h

@@ -71,7 +71,9 @@ inline Mat3::Mat3(float m00, float m01, float m02, float m10, float m11, float m
 inline Mat3::Mat3(const Mat3& b)
 {
 	for(int i = 0; i < 9; i++)
+	{
 		SELF[i] = b[i];
+	}
 }
 
 // Quat

+ 78 - 81
src/Renderer/Dbg.cpp

@@ -1,3 +1,4 @@
+#include <boost/foreach.hpp>
 #include "Dbg.h"
 #include "Renderer.h"
 #include "App.h"
@@ -88,78 +89,67 @@ void Dbg::renderGrid()
 //======================================================================================================================
 void Dbg::drawSphere(float radius, int complexity)
 {
-	const float twopi  = M::PI * 2;
-	const float pidiv2 = M::PI / 2;
+	Vec<Vec3>* sphereLines;
 
-	float theta1 = 0.0;
-	float theta2 = 0.0;
-	float theta3 = 0.0;
+	//
+	// Pre-calculate the sphere points5
+	//
+	std::map<uint, Vec<Vec3> >::iterator it = complexityToPreCalculatedSphere.find(complexity);
 
-	float ex = 0.0;
-	float ey = 0.0;
-	float ez = 0.0;
+	if(it != complexityToPreCalculatedSphere.end()) // Found
+	{
+		sphereLines = &(it->second);
+	}
+	else // Not found
+	{
+		complexityToPreCalculatedSphere[complexity] = Vec<Vec3>();
+		sphereLines = &complexityToPreCalculatedSphere[complexity];
 
-	float px = 0.0;
-	float py = 0.0;
-	float pz = 0.0;
+		float fi = M::PI / complexity;
 
-	begin();
+		Vec3 prev(1.0, 0.0, 0.0);
+		for(float th = fi; th < M::PI * 2.0 + fi; th += fi)
+		{
+			Vec3 p = Mat3(Euler(0.0, th, 0.0)) * Vec3(1.0, 0.0, 0.0);
 
-	for(int i = 0; i < complexity/2; ++i)
-	{
-		theta1 = i * twopi / complexity - pidiv2;
-		theta2 = (i + 1) * twopi / complexity - pidiv2;
+			for(float th2 = 0.0; th2 < M::PI; th2 += fi)
+			{
+				Mat3 rot(Euler(th2, 0.0, 0.0));
 
-		for(int j = complexity; j >= 0; --j)
-		{
-			theta3 = j * twopi / complexity;
-
-			float sintheta1, costheta1;
-			sinCos(theta1, sintheta1, costheta1);
-			float sintheta2, costheta2;
-			sinCos(theta2, sintheta2, costheta2);
-			float sintheta3, costheta3;
-			sinCos(theta3, sintheta3, costheta3);
-
-
-			ex = costheta2 * costheta3;
-			ey = sintheta2;
-			ez = costheta2 * sintheta3;
-			px = radius * ex;
-			py = radius * ey;
-			pz = radius * ez;
-
-			pushBackVertex(Vec3(px, py, pz));
-			//positions.push_back(Vec3(px, py, pz));
-			//normals.push_back(Vec3(ex, ey, ez));
-			//texCoodrs.push_back(Vec2(-(j/(float)complexity), 2*(i+1)/(float)complexity));
-
-			ex = costheta1 * costheta3;
-			ey = sintheta1;
-			ez = costheta1 * sintheta3;
-			px = radius * ex;
-			py = radius * ey;
-			pz = radius * ez;
-
-			pushBackVertex(Vec3(px, py, pz));
-			//positions.push_back(Vec3(px, py, pz));
-			//normals.push_back(Vec3(ex, ey, ez));
-			//texCoodrs.push_back(Vec2(-(j/(float)complexity), 2*i/(float)complexity));
+				Vec3 rotPrev = rot * prev;
+				Vec3 rotP = rot * p;
+
+				sphereLines->push_back(rotPrev);
+				sphereLines->push_back(rotP);
+
+				Mat3 rot2(Euler(0.0, 0.0, M::PI / 2));
+
+				sphereLines->push_back(rot2 * rotPrev);
+				sphereLines->push_back(rot2 * rotP);
+			}
+
+			prev = p;
 		}
 	}
 
-	positionsVbo.write(&positions[0], 0, sizeof(Vec3) * pointIndex);
-	colorsVbo.write(&colors[0], 0, sizeof(Vec3) * pointIndex);
 
-	Mat4 pmv = r.getViewProjectionMat() * modelMat;
-	sProg->findUniVar("modelViewProjectionMat")->setMat4(&pmv);
+	//
+	// Render
+	//
+	modelMat = modelMat * Mat4(Vec3(0.0), Mat3::getIdentity(), radius);
 
-	vao.bind();
-	glDrawArrays(GL_LINE_STRIP, 0, pointIndex);
-	vao.unbind();
+	begin();
+	BOOST_FOREACH(const Vec3& p, *sphereLines)
+	{
+		if(pointIndex >= MAX_POINTS_PER_DRAW)
+		{
+			end();
+			begin();
+		}
 
-	// Cleanup
-	pointIndex = 0;
+		pushBackVertex(p);
+	}
+	end();
 }
 
 
@@ -248,6 +238,34 @@ void Dbg::init(const RendererInitializer& initializer)
 }
 
 
+/*Sphere Dbg::getCommonSphere(const Sphere& a, const Sphere& b)
+{
+	Vec3 bridge = b.getCenter() - a.getCenter();
+	float blen = bridge.getLength();
+
+	if(blen + b.getRadius() < a.getRadius())
+	{
+		return a;
+	}
+	else if(blen + a.getRadius() < b.getRadius())
+	{
+		return b;
+	}
+
+	Vec3 bnorm = bridge / blen;
+
+	Vec3 ca = (-bnorm) * a.getRadius() + a.getCenter();
+	Vec3 cb = (bnorm) * b.getRadius() + b.getCenter();
+
+	setColor(Vec4(1.0));
+	setModelMat(Mat4(ca));
+	drawSphere(0.01);
+	setModelMat(Mat4(cb));
+	drawSphere(0.01);
+
+	return Sphere((ca + cb) / 2.0, (ca - cb).getLength() / 2.0);
+}*/
+
 //======================================================================================================================
 // runStage                                                                                                            =
 //======================================================================================================================
@@ -289,27 +307,6 @@ void Dbg::run()
 				break;
 		}
 	}
-	/*for(uint i=0; i<app->getScene().nodes.size(); i++)
-	{
-		SceneNode* node = app->getScene().nodes[i];
-
-		if
-		(
-			(node->type == SceneNode::SNT_LIGHT && showLightsEnabled) ||
-			(node->type == SceneNode::SNT_CAMERA && showCamerasEnabled) ||
-			node->type == SceneNode::SNT_PARTICLE_EMITTER
-		)
-		{
-			node->render();
-		}
-		else if(app->getScene().nodes[i]->type == SceneNode::SNT_SKELETON && showSkeletonsEnabled)
-		{
-			SkelNode* skelNode = static_cast<SkelNode*>(node);
-			glDisable(GL_DEPTH_TEST);
-			skelNode->render();
-			glEnable(GL_DEPTH_TEST);
-		}
-	}*/
 
 	// Physics
 	/*glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

+ 6 - 2
src/Renderer/Dbg.h

@@ -2,6 +2,7 @@
 #define DBG_H
 
 #include <boost/array.hpp>
+#include <map>
 #include "RenderingPass.h"
 #include "Fbo.h"
 #include "ShaderProg.h"
@@ -22,7 +23,7 @@ class Dbg: public RenderingPass
 		void run();
 
 		void renderGrid();
-		void drawSphere(float radius, int complexity = 8);
+		void drawSphere(float radius, int complexity = 4);
 		void drawCube(float size = 1.0);
 		void drawLine(const Vec3& from, const Vec3& to, const Vec4& color);
 
@@ -51,7 +52,7 @@ class Dbg: public RenderingPass
 		bool showCamerasEnabled;
 		Fbo fbo;
 		RsrcPtr<ShaderProg> sProg;
-		static const uint MAX_POINTS_PER_DRAW = 250;
+		static const uint MAX_POINTS_PER_DRAW = 256;
 		boost::array<Vec3, MAX_POINTS_PER_DRAW> positions;
 		boost::array<Vec3, MAX_POINTS_PER_DRAW> colors;
 		Mat4 modelMat;
@@ -61,6 +62,9 @@ class Dbg: public RenderingPass
 		Vbo colorsVbo;
 		Vao vao;
 		SceneDbgDrawer sceneDbgDrawer;
+		/// This is a container of some precalculated spheres. Its a map that from sphere complexity it returns a vector
+		/// of lines (Vec3s in pairs)
+		std::map<uint, Vec<Vec3> > complexityToPreCalculatedSphere;
 };
 
 

+ 3 - 3
src/Renderer/SceneDrawer.cpp

@@ -1,7 +1,7 @@
 #include "SceneDrawer.h"
 #include "Math.h"
 #include "Material.h"
-#include "SceneRenderable.h"
+#include "RenderableNode.h"
 #include "Camera.h"
 #include "Renderer.h"
 #include "App.h"
@@ -226,9 +226,9 @@ void SceneDrawer::setupShaderProg(const Material& mtl, const Transform& nodeWorl
 
 
 //======================================================================================================================
-// renderSceneRenderable                                                                                                =
+// renderRenderableNode                                                                                                =
 //======================================================================================================================
-void SceneDrawer::renderSceneRenderable(const SceneRenderable& renderable, const Camera& cam, RenderingPassType rtype)
+void SceneDrawer::renderRenderableNode(const RenderableNode& renderable, const Camera& cam, RenderingPassType rtype)
 {
 	const Material* mtl;
 	const Vao* vao;

+ 3 - 3
src/Renderer/SceneDrawer.h

@@ -4,13 +4,13 @@
 #include "Math.h"
 
 
-class SceneRenderable;
+class RenderableNode;
 class Renderer;
 class Camera;
 class Material;
 
 
-/// It includes all the functions to render a SceneRenderable
+/// It includes all the functions to render a RenderableNode
 class SceneDrawer
 {
 	public:
@@ -23,7 +23,7 @@ class SceneDrawer
 		/// The one and only contructor
 		SceneDrawer(const Renderer& r_): r(r_) {}
 
-		void renderSceneRenderable(const SceneRenderable& renderable, const Camera& cam, RenderingPassType rtype);
+		void renderRenderableNode(const RenderableNode& renderable, const Camera& cam, RenderingPassType rtype);
 
 	private:
 		const Renderer& r; ///< Keep it here cause the class wants a few stuff from it

+ 4 - 5
src/Scene/Camera.h

@@ -1,7 +1,6 @@
 #ifndef CAMERA_H
 #define CAMERA_H
 
-#include <fstream>
 #include "Collision.h"
 #include "SceneNode.h"
 
@@ -22,8 +21,8 @@ class Camera: public SceneNode
 
 	public:
 		// constructors and destuctors
-		Camera(float fovx_, float fovy_, float znear_, float zfar_, SceneNode* parent = NULL);
-		Camera(SceneNode* parent = NULL): SceneNode(SNT_CAMERA, parent) {}
+		Camera(float fovx_, float fovy_, float znear_, float zfar_, bool compoundFlag, SceneNode* parent = NULL);
+		Camera(bool compoundFlag, SceneNode* parent): SceneNode(SNT_CAMERA, compoundFlag, parent) {}
 		~Camera() {}
 
 		/// @name Accessors
@@ -92,8 +91,8 @@ class Camera: public SceneNode
 };
 
 
-inline Camera::Camera(float fovx_, float fovy_, float znear_, float zfar_, SceneNode* parent):
-	SceneNode(SNT_CAMERA, parent),
+inline Camera::Camera(float fovx_, float fovy_, float znear_, float zfar_, bool compoundFlag, SceneNode* parent):
+	SceneNode(SNT_CAMERA, compoundFlag, parent),
 	fovX(fovx_),
 	fovY(fovy_),
 	zNear(znear_),

+ 1 - 1
src/Scene/GhostNode.h

@@ -9,7 +9,7 @@
 class GhostNode: public SceneNode
 {
 	public:
-		GhostNode(): SceneNode(SNT_GHOST) {}
+		GhostNode(): SceneNode(SNT_GHOST, false, NULL) {}
 		~GhostNode() {}
 		void init(const char*) {}
 };

+ 3 - 3
src/Scene/Light.h

@@ -46,14 +46,14 @@ class Light: public SceneNode
 	public:
 		RsrcPtr<LightData> lightData;
 	
-		Light(LightType type, SceneNode* parent = NULL);
+		Light(LightType type, bool compoundFlag, SceneNode* parent = NULL);
 		~Light() {}
 		void init(const char* filename);
 };
 
 
-inline Light::Light(LightType type_, SceneNode* parent):
-	SceneNode(SNT_LIGHT, parent),
+inline Light::Light(LightType type_, bool compoundFlag, SceneNode* parent):
+	SceneNode(SNT_LIGHT, compoundFlag, parent),
 	type(type_)
 {}
 

+ 1 - 1
src/Scene/ModelNode.cpp

@@ -12,6 +12,6 @@ void ModelNode::init(const char* filename)
 
 	for(uint i = 0; i < model->getModelPatches().size(); i++)
 	{
-		patches.push_back(new ModelNodePatch(*this, model->getModelPatches()[i]));
+		patches.push_back(new ModelPatchNode(*this, model->getModelPatches()[i], this));
 	}
 }

+ 5 - 5
src/Scene/ModelNode.h

@@ -2,11 +2,11 @@
 #define MODEL_NODE_H
 
 #include <boost/array.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
 #include "SceneNode.h"
 #include "RsrcPtr.h"
 #include "Properties.h"
-#include "ModelNodePatch.h"
+#include "ModelPatchNode.h"
+#include "Vec.h"
 
 
 class Model;
@@ -16,7 +16,7 @@ class Model;
 class ModelNode: public SceneNode
 {
 	public:
-		ModelNode(): SceneNode(SNT_MODEL) {}
+		ModelNode(): SceneNode(SNT_MODEL, true, NULL) {}
 
 		/// @name Accessors
 		/// @{
@@ -29,12 +29,12 @@ class ModelNode: public SceneNode
 
 		/// @name Accessors
 		/// @{
-		const boost::ptr_vector<ModelNodePatch>& getModelNodePatches() const {return patches;}
+		const Vec<ModelPatchNode*>& getModelPatchNodees() const {return patches;}
 		/// @}
 
 	private:
 		RsrcPtr<Model> model;
-		boost::ptr_vector<ModelNodePatch> patches;
+		Vec<ModelPatchNode*> patches;
 };
 
 

+ 0 - 46
src/Scene/ModelNodePatch.h

@@ -1,46 +0,0 @@
-#ifndef MODEL_NODE_PATCH_H
-#define MODEL_NODE_PATCH_H
-
-#include "Vao.h"
-#include "Vbo.h"
-#include "Mesh.h" // For the Vbos enum
-#include "RsrcPtr.h"
-#include "ModelPatch.h"
-#include "Properties.h"
-#include "SceneRenderable.h"
-
-
-class Material;
-class ModelNode;
-
-
-/// A fragment of the ModelNode
-class ModelNodePatch: public SceneRenderable
-{
-	/// VAO for MS and BS. All VBOs could be attached except for the vert weights
-	PROPERTY_R(Vao, cpVao, getCpVao)
-
-	/// VAO for depth passes. All VBOs could be attached except for the vert weights
-	PROPERTY_R(Vao, dpVao, getDpVao)
-
-	public:
-		ModelNodePatch(const ModelNode& modelNode, const ModelPatch& modelPatch);
-
-		/// @name Accessors
-		/// @{
-		const Material& getCpMtl() const {return modelPatchRsrc.getCpMtl();}
-		const Material& getDpMtl() const {return modelPatchRsrc.getDpMtl();}
-		const Transform& getWorldTransform() const;
-		const ModelPatch& getModelPatchRsrc() const {return modelPatchRsrc;}
-		uint getVertIdsNum() const {return modelPatchRsrc.getMesh().getVertIdsNum();}
-		/// @}
-
-	protected:
-		const ModelNode& node; ///< Know your father
-		const ModelPatch& modelPatchRsrc;
-
-		static void createVao(const Material& material, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao);
-};
-
-
-#endif

+ 4 - 12
src/Scene/ModelNodePatch.cpp → src/Scene/ModelPatchNode.cpp

@@ -1,5 +1,5 @@
 #include <boost/array.hpp>
-#include "ModelNodePatch.h"
+#include "ModelPatchNode.h"
 #include "Material.h"
 #include "MeshData.h"
 #include "ModelPatch.h"
@@ -10,8 +10,8 @@
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-ModelNodePatch::ModelNodePatch(const ModelNode& modelNode, const ModelPatch& modelPatch_):
-	node(modelNode),
+ModelPatchNode::ModelPatchNode(const ModelNode& modelNode, const ModelPatch& modelPatch_, ModelNode* parent):
+	RenderableNode(parent),
 	modelPatchRsrc(modelPatch_)
 {
 	boost::array<const Vbo*, Mesh::VBOS_NUM> vboArr;
@@ -26,18 +26,10 @@ ModelNodePatch::ModelNodePatch(const ModelNode& modelNode, const ModelPatch& mod
 }
 
 
-//======================================================================================================================
-// getWorldTransform                                                                                                   =
-//======================================================================================================================
-const Transform& ModelNodePatch::getWorldTransform() const
-{
-	return node.getWorldTransform();
-}
-
 //======================================================================================================================
 // createVao                                                                                                           =
 //======================================================================================================================
-void ModelNodePatch::createVao(const Material& mtl, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao)
+void ModelPatchNode::createVao(const Material& mtl, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao)
 {
 	vao.create();
 

+ 44 - 0
src/Scene/ModelPatchNode.h

@@ -0,0 +1,44 @@
+#ifndef MODEL_PATCH_NODE_H
+#define MODEL_PATCH_NODE_H
+
+#include "Vao.h"
+#include "Vbo.h"
+#include "Mesh.h" // For the Vbos enum
+#include "RsrcPtr.h"
+#include "ModelPatch.h"
+#include "Properties.h"
+#include "RenderableNode.h"
+
+
+class Material;
+class ModelNode;
+
+
+/// A fragment of the ModelNode
+class ModelPatchNode: public RenderableNode
+{
+	public:
+		ModelPatchNode(const ModelNode& modelNode, const ModelPatch& modelPatch, ModelNode* parent);
+
+		void init(const char*) {}
+
+		/// @name Accessors
+		/// @{
+		const Material& getCpMtl() const {return rsrc.getCpMtl();}
+		const Material& getDpMtl() const {return rsrc.getDpMtl();}
+		const ModelPatch& getModelPatchRsrc() const {return rsrc;}
+		GETTER_R(Vao, cpVao, getCpVao)
+		GETTER_R(Vao, dpVao, getDpVao)
+		uint getVertIdsNum() const {return rsrc.getMesh().getVertIdsNum();}
+		/// @}
+
+	protected:
+		const ModelPatch& rsrc;
+		Vao dpVao; /// VAO for depth passes. All VBOs could be attached except for the vert weights
+		Vao cpVao; /// VAO for MS and BS. All VBOs could be attached except for the vert weights
+
+		static void createVao(const Material& material, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao);
+};
+
+
+#endif

+ 1 - 1
src/Scene/ParticleEmitter.h

@@ -51,7 +51,7 @@ inline ParticleEmitter::Particle::Particle():
 
 
 inline ParticleEmitter::ParticleEmitter():
-	SceneNode(SNT_PARTICLE_EMITTER)
+	SceneNode(SNT_PARTICLE_EMITTER, false, NULL)
 {}
 
 

+ 6 - 5
src/Scene/SceneRenderable.h → src/Scene/RenderableNode.h

@@ -1,7 +1,7 @@
-#ifndef SCENE_RENDERABLE_H
-#define SCENE_RENDERABLE_H
+#ifndef RENDERABLE_NODE_H
+#define RENDERABLE_NODE_H
 
-#include "Math.h"
+#include "SceneNode.h"
 
 
 class Vao;
@@ -9,15 +9,16 @@ class Material;
 
 
 /// Abstract class that acts as an interface for the renderable objects of the scene
-class SceneRenderable
+class RenderableNode: public SceneNode
 {
 	public:
+		RenderableNode(SceneNode* parent): SceneNode(SNT_RENDERABLE, false, parent) {}
+
 		virtual const Vao& getCpVao() const = 0; ///< Get color pass VAO
 		virtual const Vao& getDpVao() const = 0; ///< Get depth pass VAO
 		virtual uint getVertIdsNum() const = 0;  ///< Get vert ids number for rendering
 		virtual const Material& getCpMtl() const = 0;  ///< Get color pass material
 		virtual const Material& getDpMtl() const = 0;  ///< Get depth pass material
-		virtual const Transform& getWorldTransform() const = 0; ///< Get the world transformation
 };
 
 

+ 6 - 0
src/Scene/Scene.cpp

@@ -42,6 +42,9 @@ void Scene::registerNode(SceneNode* node)
 		case SceneNode::SNT_MODEL:
 			putBackNode(modelNodes, static_cast<ModelNode*>(node));
 			break;
+		case SceneNode::SNT_RENDERABLE:
+			putBackNode(renderableNodes, static_cast<RenderableNode*>(node));
+			break;
 	};
 }
 
@@ -67,6 +70,9 @@ void Scene::unregisterNode(SceneNode* node)
 		case SceneNode::SNT_MODEL:
 			eraseNode(modelNodes, static_cast<ModelNode*>(node));
 			break;
+		case SceneNode::SNT_RENDERABLE:
+			eraseNode(renderableNodes, static_cast<RenderableNode*>(node));
+			break;
 	};
 }
 

+ 3 - 0
src/Scene/Scene.h

@@ -14,6 +14,7 @@ class Camera;
 class Controller;
 class ParticleEmitter;
 class ModelNode;
+class RenderableNode;
 
 
 /// The Scene contains all the dynamic entities
@@ -52,6 +53,7 @@ class Scene
 		GETTER_RW(Types<Camera>::Container, cameras, getCameras)
 		GETTER_RW(Types<ParticleEmitter>::Container, particleEmitters, getParticleEmitters)
 		GETTER_RW(Types<ModelNode>::Container, modelNodes, getModelNodes)
+		GETTER_RW(Types<RenderableNode>::Container, renderableNodes, getRenderableNodes)
 		GETTER_RW(Types<Controller>::Container, controllers, getControllers)
 		/// @}
 
@@ -63,6 +65,7 @@ class Scene
 		Types<Camera>::Container cameras;
 		Types<ParticleEmitter>::Container particleEmitters;
 		Types<ModelNode>::Container modelNodes;
+		Types<RenderableNode>::Container renderableNodes;
 		Types<Controller>::Container controllers;
 		/// @}
 

+ 12 - 3
src/Scene/SceneNode.cpp

@@ -6,9 +6,10 @@
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-SceneNode::SceneNode(SceneNodeType type_, SceneNode* parent):
+SceneNode::SceneNode(SceneNodeType type_, bool compoundFlag_, SceneNode* parent):
 	Object(parent),
-	type(type_)
+	type(type_),
+	compoundFlag(compoundFlag_)
 {
 	getWorldTransform().setIdentity();
 	getLocalTransform().setIdentity();
@@ -33,7 +34,15 @@ void SceneNode::updateWorldTransform()
 	if(getObjParent())
 	{
 		const SceneNode* parent = static_cast<const SceneNode*>(getObjParent());
-		worldTransform = Transform::combineTransformations(parent->getWorldTransform(), localTransform);
+
+		if(compoundFlag)
+		{
+			worldTransform = parent->getWorldTransform();
+		}
+		else
+		{
+			worldTransform = Transform::combineTransformations(parent->getWorldTransform(), localTransform);
+		}
 	}
 	else // else copy
 	{

+ 7 - 5
src/Scene/SceneNode.h

@@ -23,12 +23,14 @@ class SceneNode: private Object
 			SNT_LIGHT,
 			SNT_CAMERA,
 			SNT_PARTICLE_EMITTER,
-			SNT_MODEL
+			SNT_MODEL,
+			SNT_SKIN,
+			SNT_RENDERABLE
 		};
 		
-		SceneNode(SceneNodeType type_, SceneNode* parent = NULL);
+		explicit SceneNode(SceneNodeType type_, bool compoundFlag, SceneNode* parent);
 		virtual ~SceneNode();
-		virtual void init(const char*) = 0; ///< init using a script
+		virtual void init(const char*) = 0; ///< init using a script file
 
 		/// @name Accessors
 		/// @{
@@ -38,7 +40,7 @@ class SceneNode: private Object
 		/// @}
 
 		/// @name Updates
-		/// Two separate updates happen every loop. The update happens anyway and the updateTrf only when the node is being
+		/// Two separate updates for the main loop. The update happens anyway and the updateTrf only when the node is being
 		/// moved
 		/// @{
 		virtual void update() {}
@@ -59,8 +61,8 @@ class SceneNode: private Object
 		Transform localTransform; ///< The transformation in local space
 		Transform worldTransform; ///< The transformation in world space (local combined with parent's transformation)
 		SceneNodeType type;
+		bool compoundFlag; ///< This means that the children will inherit the world transform of this node
 
-		void commonConstructorCode(); ///< Cause we cannot call constructor from other constructor
 		void updateWorldTransform(); ///< This update happens only when the object gets moved
 };
 

+ 10 - 0
src/Scene/SkinNode.cpp

@@ -0,0 +1,10 @@
+#include "SkinNode.h"
+
+
+//======================================================================================================================
+// init                                                                                                                =
+//======================================================================================================================
+void SkinNode::init(const char* filename)
+{
+	skin.loadRsrc(filename);
+}

+ 27 - 0
src/Scene/SkinNode.h

@@ -0,0 +1,27 @@
+#ifndef SKIN_NODE_H
+#define SKIN_NODE_H
+
+#include <boost/array.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+#include "SceneNode.h"
+#include "SkinPatchNode.h"
+
+
+class Skin;
+
+
+/// A skin scene node
+class SkinNode: public SceneNode
+{
+	public:
+		SkinNode(): SceneNode(SNT_SKIN, true, NULL) {}
+
+		void init(const char* filename);
+
+	private:
+		RsrcPtr<Skin> skin;
+		//boost::ptr_vector<SkinNodePatch> patches;
+};
+
+
+#endif

+ 37 - 0
src/Scene/SkinPatchNode.h

@@ -0,0 +1,37 @@
+#ifndef SKIN_PATCH_NODE_H
+#define SKIN_PATCH_NODE_H
+
+#include "Vao.h"
+#include "Vbo.h"
+#include "Mesh.h" // For the Vbos enum
+#include "RsrcPtr.h"
+#include "Properties.h"
+#include "RenderableNode.h"
+
+
+class Material;
+
+
+/// A fragment of the SkinNode
+class SkinPatchNode: public RenderableNode
+{
+	/*public:
+		SkinPatchNode(const ModelNode& modelNode, const ModelPatch& modelPatch);
+
+		/// @name Accessors
+		/// @{
+		const Material& getCpMtl() const {return modelPatchRsrc.getCpMtl();}
+		const Material& getDpMtl() const {return modelPatchRsrc.getDpMtl();}
+		const ModelPatch& getModelPatchRsrc() const {return modelPatchRsrc;}
+		uint getVertIdsNum() const {return rsrc.getMesh().getVertIdsNum();}
+		/// @}
+
+	protected:
+		const SkinNode& node; ///< Know your father
+		const ModelPatch& rsrc;
+		Vao dpVao;
+		Vao cpVao;*/
+};
+
+
+#endif

+ 1 - 1
src/Scene/SpotLight.cpp

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

+ 5 - 5
src/Scene/VisibilityTester.cpp

@@ -1,7 +1,7 @@
 #include "VisibilityTester.h"
 #include "Scene.h"
 #include "ModelNode.h"
-#include "ModelNodePatch.h"
+#include "ModelPatchNode.h"
 #include "Material.h"
 #include "Sphere.h"
 #include "PointLight.h"
@@ -11,7 +11,7 @@
 //======================================================================================================================
 // CmpLength::operator()                                                                                               =
 //======================================================================================================================
-inline bool VisibilityTester::CmpLength::operator()(const SceneRenderable* a, const SceneRenderable* b) const
+inline bool VisibilityTester::CmpLength::operator()(const RenderableNode* a, const RenderableNode* b) const
 {
 	return (a->getWorldTransform().origin - o).getLengthSquared() < (b->getWorldTransform().origin - o).getLengthSquared();
 }
@@ -82,10 +82,10 @@ void VisibilityTester::test(const Camera& cam)
 	Scene::Types<ModelNode>::ConstIterator it = scene.getModelNodes().begin();
 	for(; it != scene.getModelNodes().end(); it++)
 	{
-		boost::ptr_vector<ModelNodePatch>::const_iterator it2 = (*it)->getModelNodePatches().begin();
-		for(; it2 != (*it)->getModelNodePatches().end(); it2++)
+		boost::ptr_vector<ModelPatchNode>::const_iterator it2 = (*it)->getModelPatchNodees().begin();
+		for(; it2 != (*it)->getModelPatchNodees().end(); it2++)
 		{
-			const ModelNodePatch& modelNodePatch = *it2;
+			const ModelPatchNode& modelNodePatch = *it2;
 
 			// First check if its rendered by a light
 			Types<VisibleLight<SpotLight> >::Iterator itsl = spotLights.begin();

+ 9 - 9
src/Scene/VisibilityTester.h

@@ -8,7 +8,7 @@
 
 class Camera;
 class Scene;
-class SceneRenderable;
+class RenderableNode;
 class SpotLight;
 class PointLight;
 
@@ -38,11 +38,11 @@ class VisibilityTester
 
 			public:
 				const LightType& getLight() const {return *light;}
-				GETTER_R(Types<const SceneRenderable*>::Container, renderables, getRenderables)
+				GETTER_R(Types<const RenderableNode*>::Container, renderables, getRenderables)
 
 			private:
 				const LightType* light;
-				Types<const SceneRenderable*>::Container renderables; ///< The visible nodes by that light
+				Types<const RenderableNode*>::Container renderables; ///< The visible nodes by that light
 		};
 
 		/// Constructor
@@ -50,8 +50,8 @@ class VisibilityTester
 
 		/// @name Accessors
 		/// @{
-		GETTER_R(Types<const SceneRenderable*>::Container, msRenderables, getMsRenderables)
-		GETTER_R(Types<const SceneRenderable*>::Container, bsRenderables, getBsRenderables)
+		GETTER_R(Types<const RenderableNode*>::Container, msRenderables, getMsRenderables)
+		GETTER_R(Types<const RenderableNode*>::Container, bsRenderables, getBsRenderables)
 		GETTER_R(Types<VisibleLight<PointLight> >::Container, pointLights, getPointLights)
 		GETTER_R(Types<VisibleLight<SpotLight> >::Container, spotLights, getSpotLights)
 		/// @}
@@ -67,18 +67,18 @@ class VisibilityTester
 		{
 			Vec3 o; ///< The camera origin
 			CmpLength(Vec3 o_): o(o_) {}
-			bool operator()(const SceneRenderable* a, const SceneRenderable* b) const;
+			bool operator()(const RenderableNode* a, const RenderableNode* b) const;
 		};
 
 		const Scene& scene; ///< Know your father
 
-		Types<const SceneRenderable*>::Container msRenderables;
-		Types<const SceneRenderable*>::Container bsRenderables;
+		Types<const RenderableNode*>::Container msRenderables;
+		Types<const RenderableNode*>::Container bsRenderables;
 		Types<VisibleLight<PointLight> >::Container pointLights;
 		Types<VisibleLight<SpotLight> >::Container spotLights;
 
 		/// @todo write some real code
-		static bool test(const SceneRenderable& /*renderable*/, const Camera& /*cam*/) {return true;}
+		static bool test(const RenderableNode& /*renderable*/, const Camera& /*cam*/) {return true;}
 };
 
 

+ 1 - 0
src/Scripting/BoostPythonInterfaces.cpp

@@ -25,4 +25,5 @@ BOOST_PYTHON_MODULE(Anki)
 	CALL_WRAP(MainRendererSingleton);
 
 	CALL_WRAP(App);
+	CALL_WRAP(AppSingleton);
 }

+ 3 - 0
src/Scripting/Core/App.bpi.cpp

@@ -8,3 +8,6 @@ WRAP(App)
 		.def("quit", &App::quit)
 	;
 }
+
+
+WRAP_SINGLETON(AppSingleton)

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است