Panagiotis Christopoulos Charitos 15 anos atrás
pai
commit
507c7e2b6d

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
build/debug/Makefile


+ 2 - 2
src/Scene/ModelNode.h

@@ -22,8 +22,8 @@ class ModelNode: public SceneNode
 		/// @name Accessors
 		/// @{
 		const Model& getModel() const {return *model;}
-		GETTER_R(Vec<ModelPatchNode*>, patches, getModelPatchNodes)
-		GETTER_R(Sphere, boundingShapeWSpace, getBoundingShapeWSpace)
+		const Vec<ModelPatchNode*>& getModelPatchNodes() const {return patches;}
+		const Sphere& getBoundingShapeWSpace() const {return boundingShapeWSpace;}
 		/// @}
 
 		/// Initialize the node

+ 1 - 37
src/Scene/ModelPatchNode.cpp

@@ -11,8 +11,7 @@
 // Constructor                                                                                                         =
 //======================================================================================================================
 ModelPatchNode::ModelPatchNode(const ModelPatch& modelPatch_, ModelNode* parent):
-	RenderableNode(modelPatch_.getMesh().getBoundingShape(), parent),
-	rsrc(modelPatch_)
+	PatchNode(modelPatch_, parent)
 {
 	boost::array<const Vbo*, Mesh::VBOS_NUM> vboArr;
 
@@ -24,38 +23,3 @@ ModelPatchNode::ModelPatchNode(const ModelPatch& modelPatch_, ModelNode* parent)
 	createVao(rsrc.getCpMtl(), vboArr, cpVao);
 	createVao(rsrc.getDpMtl(), vboArr, dpVao);
 }
-
-
-//======================================================================================================================
-// createVao                                                                                                           =
-//======================================================================================================================
-void ModelPatchNode::createVao(const Material& mtl, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao)
-{
-	vao.create();
-
-	if(mtl.getStdAttribVar(Material::SAV_POSITION) != NULL)
-	{
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_POSITIONS], *mtl.getStdAttribVar(Material::SAV_POSITION),
-		                         3, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	if(mtl.getStdAttribVar(Material::SAV_NORMAL) != NULL)
-	{
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_NORMALS], *mtl.getStdAttribVar(Material::SAV_NORMAL),
-		                         3, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	if(mtl.getStdAttribVar(Material::SAV_TANGENT) != NULL)
-	{
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_TANGENTS], *mtl.getStdAttribVar(Material::SAV_TANGENT),
-		                         4, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	if(mtl.getStdAttribVar(Material::SAV_TEX_COORDS) != NULL)
-	{
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_TEX_COORDS], *mtl.getStdAttribVar(Material::SAV_TEX_COORDS),
-		                         2, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	vao.attachElementArrayBufferVbo(*vbos[Mesh::VBO_VERT_INDECES]);
-}

+ 2 - 29
src/Scene/ModelPatchNode.h

@@ -1,44 +1,17 @@
 #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"
+#include "PatchNode.h"
 
 
-class Material;
 class ModelNode;
 
 
 /// A fragment of the ModelNode
-class ModelPatchNode: public RenderableNode
+class ModelPatchNode: public PatchNode
 {
 	public:
 		ModelPatchNode(const ModelPatch& modelPatch, ModelNode* parent);
-
-		/// Do nothing
-		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);
 };
 
 

+ 37 - 0
src/Scene/PatchNode.cpp

@@ -0,0 +1,37 @@
+#include "PatchNode.h"
+#include "Material.h"
+
+
+//======================================================================================================================
+// createVao                                                                                                           =
+//======================================================================================================================
+void PatchNode::createVao(const Material& mtl, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao)
+{
+	vao.create();
+
+	if(mtl.getStdAttribVar(Material::SAV_POSITION) != NULL)
+	{
+		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_POSITIONS], *mtl.getStdAttribVar(Material::SAV_POSITION),
+		                         3, GL_FLOAT, GL_FALSE, 0, NULL);
+	}
+
+	if(mtl.getStdAttribVar(Material::SAV_NORMAL) != NULL)
+	{
+		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_NORMALS], *mtl.getStdAttribVar(Material::SAV_NORMAL),
+		                         3, GL_FLOAT, GL_FALSE, 0, NULL);
+	}
+
+	if(mtl.getStdAttribVar(Material::SAV_TANGENT) != NULL)
+	{
+		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_TANGENTS], *mtl.getStdAttribVar(Material::SAV_TANGENT),
+		                         4, GL_FLOAT, GL_FALSE, 0, NULL);
+	}
+
+	if(mtl.getStdAttribVar(Material::SAV_TEX_COORDS) != NULL)
+	{
+		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_TEX_COORDS], *mtl.getStdAttribVar(Material::SAV_TEX_COORDS),
+		                         2, GL_FLOAT, GL_FALSE, 0, NULL);
+	}
+
+	vao.attachElementArrayBufferVbo(*vbos[Mesh::VBO_VERT_INDECES]);
+}

+ 52 - 0
src/Scene/PatchNode.h

@@ -0,0 +1,52 @@
+#ifndef PATCH_NODE_H
+#define PATCH_NODE_H
+
+
+#include "Vao.h"
+#include "Vbo.h"
+#include "Mesh.h" // For the Vbos enum
+#include "RsrcPtr.h"
+#include "ModelPatch.h"
+#include "RenderableNode.h"
+
+
+class Material;
+
+
+/// Inherited by ModelPatchNode and SkinPatchNode. It contains common code, the derived classes are responsible to
+/// initialize the VAOs
+class PatchNode: public RenderableNode
+{
+	public:
+		PatchNode(const ModelPatch& modelPatch, SceneNode* parent);
+
+		/// Do nothing
+		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;}
+		const Vao& getCpVao() const {return cpVao;}
+		const Vao& getDpVao() const {return dpVao;}
+		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
+
+		/// Create a VAO given a material and an array of VBOs
+		static void createVao(const Material& material, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao);
+};
+
+
+inline PatchNode::PatchNode(const ModelPatch& modelPatch, SceneNode* parent):
+	RenderableNode(modelPatch.getMesh().getBoundingShape(), parent),
+	rsrc(modelPatch)
+{}
+
+
+#endif

+ 12 - 4
src/Scene/Scene.cpp

@@ -1,13 +1,15 @@
 #include <algorithm>
 #include "Exception.h"
 #include "Scene.h"
+#include "VisibilityTester.h"
+
 #include "Camera.h"
 #include "Light.h"
 #include "Controller.h"
 #include "Material.h"
 #include "ParticleEmitter.h"
 #include "ModelNode.h"
-#include "VisibilityTester.h"
+#include "SkinNode.h"
 
 
 //======================================================================================================================
@@ -15,7 +17,7 @@
 //======================================================================================================================
 Scene::Scene()
 {
-	ambientCol = Vec3(0.1, 0.05, 0.05)*4;
+	ambientCol = Vec3(0.1, 0.05, 0.05) * 4;
 	//sunPos = Vec3(0.0, 1.0, -1.0) * 50.0;
 
 	physics.reset(new Physics);
@@ -45,8 +47,11 @@ void Scene::registerNode(SceneNode* node)
 		case SceneNode::SNT_MODEL:
 			putBackNode(modelNodes, static_cast<ModelNode*>(node));
 			break;
+		case SceneNode::SNT_SKIN:
+			putBackNode(skinNodes, static_cast<SkinNode*>(node));
+			break;
 		case SceneNode::SNT_RENDERABLE:
-			putBackNode(renderableNodes, static_cast<RenderableNode*>(node));
+		case SceneNode::SNT_GHOST:
 			break;
 	};
 }
@@ -73,8 +78,11 @@ void Scene::unregisterNode(SceneNode* node)
 		case SceneNode::SNT_MODEL:
 			eraseNode(modelNodes, static_cast<ModelNode*>(node));
 			break;
+		case SceneNode::SNT_SKIN:
+			eraseNode(skinNodes, static_cast<SkinNode*>(node));
+			break;
 		case SceneNode::SNT_RENDERABLE:
-			eraseNode(renderableNodes, static_cast<RenderableNode*>(node));
+		case SceneNode::SNT_GHOST:
 			break;
 	};
 }

+ 3 - 3
src/Scene/Scene.h

@@ -15,7 +15,7 @@ class Camera;
 class Controller;
 class ParticleEmitter;
 class ModelNode;
-class RenderableNode;
+class SkinNode;
 
 
 /// The Scene contains all the dynamic entities
@@ -56,7 +56,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<SkinNode>::Container, skinNodes, getSkinNodes)
 		GETTER_RW(Types<Controller>::Container, controllers, getControllers)
 		/// @}
 
@@ -68,7 +68,7 @@ class Scene
 		Types<Camera>::Container cameras;
 		Types<ParticleEmitter>::Container particleEmitters;
 		Types<ModelNode>::Container modelNodes;
-		Types<RenderableNode>::Container renderableNodes;
+		Types<SkinNode>::Container skinNodes;
 		Types<Controller>::Container controllers;
 		/// @}
 

+ 3 - 4
src/Scene/SkinNode.h

@@ -1,10 +1,9 @@
 #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"
+#include "Vec.h"
 
 
 class Skin;
@@ -19,8 +18,8 @@ class SkinNode: public SceneNode
 		void init(const char* filename);
 
 	private:
-		RsrcPtr<Skin> skin;
-		//boost::ptr_vector<SkinNodePatch> patches;
+		RsrcPtr<Skin> skin; ///< The resource
+		Vec<SkinPatchNode*> patches;
 };
 
 

+ 47 - 0
src/Scene/SkinPatchNode.cpp

@@ -0,0 +1,47 @@
+#include "SkinPatchNode.h"
+#include "SkinNode.h"
+
+
+//======================================================================================================================
+// Constructor                                                                                                         =
+//======================================================================================================================
+SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent):
+	PatchNode(modelPatch, parent)
+{
+	boost::array<const Vbo*, Mesh::VBOS_NUM> vboArr;
+
+	for(uint i = 0; i < Mesh::VBOS_NUM; i++)
+	{
+		vboArr[i] = &rsrc.getMesh().getVbo((Mesh::Vbos)i);
+	}
+
+	const Mesh& mesh = rsrc.getMesh();
+
+
+	if(mesh.getVbo(Mesh::VBO_VERT_POSITIONS).isCreated())
+	{
+		tfVbos[TFV_POSITIONS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_POSITIONS).getSizeInBytes(),
+	                               NULL, GL_STATIC_DRAW);
+		vboArr[Mesh::VBO_VERT_POSITIONS] = &tfVbos[TFV_POSITIONS];
+	}
+
+	if(mesh.getVbo(Mesh::VBO_VERT_NORMALS).isCreated())
+	{
+		tfVbos[TFV_NORMALS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_NORMALS).getSizeInBytes(),
+	                               NULL, GL_STATIC_DRAW);
+
+		vboArr[Mesh::VBO_VERT_NORMALS] = &tfVbos[TFV_NORMALS];
+	}
+
+	if(mesh.getVbo(Mesh::VBO_VERT_TANGENTS).isCreated())
+	{
+		tfVbos[TFV_TANGENTS].create(GL_ARRAY_BUFFER, mesh.getVbo(Mesh::VBO_VERT_TANGENTS).getSizeInBytes(),
+	                               NULL, GL_STATIC_DRAW);
+
+		vboArr[Mesh::VBO_VERT_TANGENTS] = &tfVbos[TFV_TANGENTS];
+	}
+
+
+	createVao(rsrc.getCpMtl(), vboArr, cpVao);
+	createVao(rsrc.getDpMtl(), vboArr, dpVao);
+}

+ 16 - 23
src/Scene/SkinPatchNode.h

@@ -1,36 +1,29 @@
 #ifndef SKIN_PATCH_NODE_H
 #define SKIN_PATCH_NODE_H
 
-#include "Vao.h"
+#include <boost/array.hpp>
+#include "PatchNode.h"
 #include "Vbo.h"
-#include "Mesh.h" // For the Vbos enum
-#include "RsrcPtr.h"
-#include "Properties.h"
-#include "RenderableNode.h"
 
 
-class Material;
+class SkinNode;
 
 
 /// A fragment of the SkinNode
-class SkinPatchNode: public RenderableNode
+class SkinPatchNode: public PatchNode
 {
-	/*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;*/
+	public:
+		enum TransformFeedbackVbo
+		{
+			TFV_POSITIONS,
+			TFV_NORMALS,
+			TFV_TANGENTS
+		};
+
+		SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent);
+
+	public:
+		boost::array<Vbo, 3> tfVbos; ///< VBOs that contain the deformed vertex attributes
 };
 
 

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff