Panagiotis Christopoulos Charitos 15 years ago
parent
commit
d8f4a21406

File diff suppressed because it is too large
+ 0 - 1
build/debug/Makefile


+ 2 - 2
src/Renderer/Dbg.cpp

@@ -275,11 +275,11 @@ void Dbg::run()
 				sceneDbgDrawer.drawParticleEmitter(static_cast<const ParticleEmitter&>(*node));
 				break;
 			case SceneNode::SNT_RENDERABLE:
-				if(showVisibilityBoundingShapesFlag)
+				/*if(showVisibilityBoundingShapesFlag)
 				{
 					const RenderableNode& rnode = static_cast<const RenderableNode&>(*node);
 					collisionDbgDrawer.draw(rnode.getVisibilityShapeWSpace());
-				}
+				}*/
 				break;
 			default:
 				break;

+ 6 - 6
src/Renderer/Is.cpp

@@ -223,8 +223,8 @@ void Is::pointLightPass(const PointLight& light)
 	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
 	shader.findUniVar("lightPos")->setVec3(&lightPosEyeSpace);
 	shader.findUniVar("lightRadius")->setFloat(light.getRadius());
-	shader.findUniVar("lightDiffuseCol")->setVec3(&light.lightData->getDiffuseCol());
-	shader.findUniVar("lightSpecularCol")->setVec3(&light.lightData->getSpecularCol());
+	shader.findUniVar("lightDiffuseCol")->setVec3(&light.getDiffuseCol());
+	shader.findUniVar("lightSpecularCol")->setVec3(&light.getSpecularCol());
 
 	// render quad
 	drawLightPassQuad();
@@ -257,7 +257,7 @@ void Is::spotLightPass(const SpotLight& light)
 	smo.run(light);
 
 	// set the texture
-	light.lightData->getTexture().setRepeat(false);
+	light.getTexture().setRepeat(false);
 
 	// shader prog
 	const ShaderProg* shdr;
@@ -286,9 +286,9 @@ void Is::spotLightPass(const SpotLight& light)
 	Vec3 lightPosEyeSpace = light.getWorldTransform().getOrigin().getTransformed(cam.getViewMatrix());
 	shdr->findUniVar("lightPos")->setVec3(&lightPosEyeSpace);
 	shdr->findUniVar("lightRadius")->setFloat(light.getDistance());
-	shdr->findUniVar("lightDiffuseCol")->setVec3(&light.lightData->getDiffuseCol());
-	shdr->findUniVar("lightSpecularCol")->setVec3(&light.lightData->getSpecularCol());
-	shdr->findUniVar("lightTex")->setTexture(light.lightData->getTexture(), 4);
+	shdr->findUniVar("lightDiffuseCol")->setVec3(&light.getDiffuseCol());
+	shdr->findUniVar("lightSpecularCol")->setVec3(&light.getSpecularCol());
+	shdr->findUniVar("lightTex")->setTexture(light.getTexture(), 4);
 
 	// set texture matrix for texture & shadowmap projection
 	// Bias * P_light * V_light * inv(V_cam)

+ 45 - 3
src/Renderer/SkinsDeformer.cpp

@@ -1,5 +1,7 @@
 #include "SkinsDeformer.h"
 #include "ShaderProg.h"
+#include "SkinPatchNode.h"
+#include "SkinNode.h"
 
 
 //======================================================================================================================
@@ -18,16 +20,56 @@ void SkinsDeformer::init()
 	                                                 "",
 	                                                 "p");
 
-
 	tfHwSkinningAllSProg.loadRsrc(all.c_str());
 	tfHwSkinningPosSProg.loadRsrc(p.c_str());
+
+	const char* vars[] = {"vPosition", "vNormal", "vTangent"};
+
+	// All
+	tfHwSkinningAllSProg->bind();
+	glTransformFeedbackVaryings(tfHwSkinningAllSProg->getGlId(), 1, vars, GL_SEPARATE_ATTRIBS);
+	tfHwSkinningAllSProg->relink();
+
+	// Pos
+	tfHwSkinningPosSProg->bind();
+	glTransformFeedbackVaryings(tfHwSkinningAllSProg->getGlId(), 3, vars, GL_SEPARATE_ATTRIBS);
+	tfHwSkinningPosSProg->relink();
 }
 
 
 //======================================================================================================================
-// run                                                                                                                 =
+// deform                                                                                                              =
 //======================================================================================================================
-void SkinsDeformer::run()
+void SkinsDeformer::deform(SkinPatchNode& node)
 {
+	ASSERT(node.getParent() == NULL);
+	ASSERT(static_cast<SceneNode*>(node.getParent())->getSceneNodeType() == SceneNode::SNT_SKIN);
+
+	SkinNode* skinNode = static_cast<SkinNode*>(node.getParent());
+
+	glEnable(GL_RASTERIZER_DISCARD);
+
+	tfHwSkinningAllSProg->bind();
+
+	// Uniforms
+	tfHwSkinningAllSProg->findUniVar("skinningRotations")->setMat3(&skinNode->getBoneRotations()[0],
+	                                                               skinNode->getBoneRotations().size());
+
+	tfHwSkinningAllSProg->findUniVar("skinningTranslations")->setVec3(&skinNode->getBoneTranslations()[0],
+	                                                                  skinNode->getBoneTranslations().size());
+
+	// TF
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, node.getTfVbo(SkinPatchNode::TFV_POSITIONS).getGlId());
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 1, node.getTfVbo(SkinPatchNode::TFV_NORMALS).getGlId());
+	glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 2, node.getTfVbo(SkinPatchNode::TFV_TANGENTS).getGlId());
+
+	node.getTfVao().bind();
+
+	//glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, this->Query);
+	glBeginTransformFeedback(GL_TRIANGLES);
+		glDrawElements(GL_TRIANGLES, node.getVertIdsNum(), GL_UNSIGNED_SHORT, 0);
+	glEndTransformFeedback();
+	//glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
 
+	glDisable(GL_RASTERIZER_DISCARD);
 }

+ 2 - 1
src/Renderer/SkinsDeformer.h

@@ -5,6 +5,7 @@
 
 
 class ShaderProg;
+class SkinPatchNode;
 
 
 ///
@@ -22,7 +23,7 @@ class SkinsDeformer
 		};
 
 		void init();
-		void run();
+		void deform(SkinPatchNode& node);
 
 	private:
 		RsrcPtr<ShaderProg> tfHwSkinningAllSProg;

+ 17 - 11
src/Resources/LightRsrc.h

@@ -10,14 +10,24 @@
 /// Properties common for all lights
 struct LightProps
 {
+	/// @name Common light properties
+	/// @{
 	Vec3 diffuseCol;
 	Vec3 specularCol;
-	bool castsShadowFlag;
-	float radius;
-	float distance;
+	bool castsShadowFlag; ///< Currently only for spot lights
+	/// @}
+
+	/// @name Point light properties
+	/// @{
+	float radius; ///< Sphere radius
+	/// @}
+
+	/// @name Spot light properties
+	/// @{
+	float distance; ///< AKA camera's zFar
 	float fovX;
 	float fovY;
-	RsrcPtr<Texture> texture;
+	/// @}
 };
 
 
@@ -39,12 +49,12 @@ class LightRsrc: private LightProps
 		/// @{
 		GETTER_R(Vec3, diffuseCol, getDiffuseCol)
 		GETTER_R(Vec3, specularCol, getSpecularCol)
-		GETTER_R_BY_VAL(bool, castsShadowFlag, castsShadow) ///< Currently only for spot lights
+		GETTER_R_BY_VAL(bool, castsShadowFlag, castsShadow)
 		GETTER_R_BY_VAL(LightType, type, getType)
 
-		GETTER_R_BY_VAL(float, radius, getRadius) ///< Sphere radius
+		GETTER_R_BY_VAL(float, radius, getRadius)
 
-		GETTER_R_BY_VAL(float, distance, getDistance) ///< AKA camera's zFar
+		GETTER_R_BY_VAL(float, distance, getDistance)
 		GETTER_R_BY_VAL(float, fovX, getFovX)
 		GETTER_R_BY_VAL(float, fovY, getFovY)
 		const Texture& getTexture() const;
@@ -54,11 +64,7 @@ class LightRsrc: private LightProps
 
 	private:
 		LightType type;
-
-		/// @name Spot light properties
-		/// @{
 		RsrcPtr<Texture> texture;
-		/// @}
 };
 
 

+ 1 - 1
src/Scene/Light.cpp

@@ -11,5 +11,5 @@ void Light::init(const char* filename)
 
 	diffuseCol = lightData->getDiffuseCol();
 	specularCol = lightData->getSpecularCol();
-	castsShadow_ = lightData->castsShadow();
+	castsShadowFlag = lightData->castsShadow();
 }

+ 17 - 14
src/Scene/Light.h

@@ -34,28 +34,31 @@ class Light: public SceneNode
 			LT_SPOT
 		};
 
-	PROPERTY_R(LightType, type, getType) ///< Light type
-
-	/// @name Copies of some of the resource properties. The others are camera properties or not changeable
-	/// @{
-	PROPERTY_RW(Vec3, diffuseCol, getDiffuseCol, setDiffuseCol) ///< Diffuse color
-	PROPERTY_RW(Vec3, specularCol, getSpecularCol, setSpecularCol) ///< Specular color
-	PROPERTY_RW(bool, castsShadow_, castsShadow, setCastsShadow) ///< Casts shadow
-	/// @}
-
-	public:
-		RsrcPtr<LightRsrc> lightData;
-	
 		Light(LightType type, bool compoundFlag, SceneNode* parent = NULL);
 		~Light() {}
+
+		/// @name Accessors
+		/// @{
+		GETTER_R(LightType, type, getType)
+
+		GETTER_SETTER(Vec3, diffuseCol, getDiffuseCol, setDiffuseCol)
+		GETTER_SETTER(Vec3, specularCol, getSpecularCol, setSpecularCol)
+		GETTER_SETTER_BY_VAL(bool, castsShadowFlag, castsShadow, setCastsShadow)
+		/// @}
+
 		void init(const char* filename);
 
 		void moveUpdate() {}
 		void frameUpdate() {}
 
-	private:
-		//LightType type;
+	protected:
+		RsrcPtr<LightRsrc> lightData;
+		Vec3 diffuseCol; ///< Diffuse color
+		Vec3 specularCol; ///< Specular color
+		bool castsShadowFlag; ///< Casts shadow
 
+	private:
+		LightType type; ///< Light type
 };
 
 

+ 11 - 1
src/Scene/ModelPatchNode.cpp

@@ -11,7 +11,8 @@
 // Constructor                                                                                                         =
 //======================================================================================================================
 ModelPatchNode::ModelPatchNode(const ModelPatch& modelPatch_, ModelNode* parent):
-	PatchNode(modelPatch_, parent)
+	PatchNode(modelPatch_, parent),
+	modelPatch(modelPatch_)
 {
 	boost::array<const Vbo*, Mesh::VBOS_NUM> vboArr;
 
@@ -23,3 +24,12 @@ ModelPatchNode::ModelPatchNode(const ModelPatch& modelPatch_, ModelNode* parent)
 	createVao(rsrc.getCpMtl(), vboArr, cpVao);
 	createVao(rsrc.getDpMtl(), vboArr, dpVao);
 }
+
+
+//======================================================================================================================
+// moveUpdate                                                                                                          =
+//======================================================================================================================
+void ModelPatchNode::moveUpdate()
+{
+	visibilityShapeWSpace = modelPatch.getMesh().getVisibilityShape().getTransformed(getWorldTransform());
+}

+ 10 - 0
src/Scene/ModelPatchNode.h

@@ -2,6 +2,7 @@
 #define MODEL_PATCH_NODE_H
 
 #include "PatchNode.h"
+#include "Obb.h"
 
 
 class ModelNode;
@@ -12,6 +13,15 @@ class ModelPatchNode: public PatchNode
 {
 	public:
 		ModelPatchNode(const ModelPatch& modelPatch, ModelNode* parent);
+
+		const Obb& getVisibilityShapeWSpace() const {return visibilityShapeWSpace;}
+
+		virtual void moveUpdate(); ///< Update the visibility shape
+		virtual void frameUpdate() {}
+
+	private:
+		const ModelPatch& modelPatch;
+		Obb visibilityShapeWSpace;
 };
 
 

+ 1 - 1
src/Scene/PatchNode.h

@@ -44,7 +44,7 @@ class PatchNode: public RenderableNode
 
 
 inline PatchNode::PatchNode(const ModelPatch& modelPatch, SceneNode* parent):
-	RenderableNode(modelPatch.getMesh().getVisibilityShape(), parent),
+	RenderableNode(parent),
 	rsrc(modelPatch)
 {}
 

+ 4 - 3
src/Scene/PointLight.h

@@ -7,11 +7,13 @@
 /// Point light. Defined by its radius
 class PointLight: public Light
 {
-	PROPERTY_RW(float, radius, getRadius, setRadius)
-
 	public:
 		PointLight(SceneNode* parent = NULL): Light(LT_POINT, parent) {}
+		GETTER_SETTER(float, radius, getRadius, setRadius)
 		void init(const char* filename);
+
+	private:
+		float radius;
 };
 
 
@@ -21,7 +23,6 @@ inline void PointLight::init(const char* filename)
 	if(lightData->getType() != LightRsrc::LT_POINT)
 	{
 		throw EXCEPTION("Light data is wrong type");
-		return;
 	}
 	radius = lightData->getRadius();
 }

+ 0 - 19
src/Scene/RenderableNode.cpp

@@ -1,19 +0,0 @@
-#include "RenderableNode.h"
-
-
-//======================================================================================================================
-// Constructor                                                                                                         =
-//======================================================================================================================
-RenderableNode::RenderableNode(const Obb& visibilityShapeLSpace_, SceneNode* parent):
-	SceneNode(SNT_RENDERABLE, false, parent),
-	visibilityShapeLSpace(visibilityShapeLSpace_)
-{}
-
-
-//======================================================================================================================
-// moveUpdate                                                                                                          =
-//======================================================================================================================
-void RenderableNode::moveUpdate()
-{
-	visibilityShapeWSpace = visibilityShapeLSpace.getTransformed(getWorldTransform());
-}

+ 5 - 10
src/Scene/RenderableNode.h

@@ -2,7 +2,6 @@
 #define RENDERABLE_NODE_H
 
 #include "SceneNode.h"
-#include "Obb.h"
 
 
 class Vao;
@@ -13,23 +12,19 @@ class Material;
 class RenderableNode: public SceneNode
 {
 	public:
-		RenderableNode(const Obb& visibilityShapeLSpace, SceneNode* parent);
+		RenderableNode(SceneNode* 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
-		const Obb& getVisibilityShapeWSpace() const {return visibilityShapeWSpace;}
+};
 
-		/// Update the bounding shape
-		virtual void moveUpdate();
-		void frameUpdate() {}
 
-	private:
-		Obb visibilityShapeLSpace;
-		Obb visibilityShapeWSpace;
-};
+inline RenderableNode::RenderableNode(SceneNode* parent):
+	SceneNode(SNT_RENDERABLE, false, parent)
+{}
 
 
 #endif

+ 2 - 2
src/Scene/SceneNode.h

@@ -54,8 +54,8 @@ class SceneNode: public Object
 		/// @}
 
 		/// @name Updates
-		/// Two separate updates for the main loop. The update happens anyway and the updateTrf only when the node is being
-		/// moved
+		/// Two separate updates for the main loop. The update happens anyway and the updateTrf only when the node is
+		/// being moved
 		/// @{
 
 		/// This is called every frame

+ 8 - 16
src/Scene/SkinNode.h

@@ -5,6 +5,7 @@
 #include "SkinPatchNode.h"
 #include "Vec.h"
 #include "Math.h"
+#include "Properties.h"
 
 
 class Skin;
@@ -21,27 +22,18 @@ class SkinNode: public SceneNode
 
 		/// @name Accessors
 		/// @{
-		const Vec<Vec3>& getHeads() const {return heads;}
-		Vec<Vec3>& getHeads() {return heads;}
-
-		const Vec<Vec3>& getTails() const {return tails;}
-		Vec<Vec3>& getTails() {return tails;}
-
-		const Vec<Mat3>& getBoneRotations() const {return boneRotations;}
-		Vec<Mat3>& getBoneRotations() {return boneRotations;}
-
-		const Vec<Vec3>& getBoneTranslations() const {return boneTranslations;}
-		Vec<Vec3>& getBoneTranslations() {return boneTranslations;}
-
+		GETTER_RW(Vec<Vec3>, heads, getHeads)
+		GETTER_RW(Vec<Vec3>, tails, getTails)
+		GETTER_RW(Vec<Mat3>, boneRotations, getBoneRotations)
+		GETTER_RW(Vec<Vec3>, boneTranslations, getBoneTranslations)
 		const Skin& getSkin() const {return *skin;}
-
-		const Obb& getVisibilityShapeWSpace() const {return visibilityShapeWSpace;}
+		GETTER_R(Obb, visibilityShapeWSpace, getVisibilityShapeWSpace)
 		/// @}
 
 		void init(const char* filename);
 
-		/// Update boundingShapeWSpace from bone tails (not bone and heads cause its faster that way). The tails come from
-		/// the previous frame
+		/// Update boundingShapeWSpace from bone tails (not bone and heads cause its faster that way). The tails come
+		/// from the previous frame
 		void moveUpdate();
 
 	private:

+ 5 - 4
src/Scene/SkinPatchNode.cpp

@@ -9,8 +9,8 @@
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
-SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent):
-	PatchNode(modelPatch, parent)
+SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch_, SkinNode* parent):
+	PatchNode(modelPatch_, parent)
 {
 	boost::array<const Vbo*, Mesh::VBOS_NUM> vboArr;
 
@@ -31,7 +31,8 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent):
 	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);
+		                             NULL, GL_STATIC_DRAW);
+
 		vboArr[Mesh::VBO_VERT_POSITIONS] = &tfVbos[TFV_POSITIONS];
 
 		tfVao.attachArrayBufferVbo(tfVbos[TFV_POSITIONS], SkinsDeformer::TFSPA_POSITION, 3, GL_FLOAT, false, 0, NULL);
@@ -52,7 +53,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent):
 	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);
+		                            NULL, GL_STATIC_DRAW);
 
 		vboArr[Mesh::VBO_VERT_TANGENTS] = &tfVbos[TFV_TANGENTS];
 

+ 10 - 1
src/Scene/SkinPatchNode.h

@@ -24,7 +24,16 @@ class SkinPatchNode: public PatchNode
 
 		SkinPatchNode(const ModelPatch& modelPatch, SkinNode* parent);
 
-	public:
+		/// @name Accessors
+		/// @{
+		GETTER_R(Vao, tfVao, getTfVao)
+		const Vbo& getTfVbo(uint i) const {return tfVbos[i];}
+		/// @}
+
+		virtual void moveUpdate() {}
+		virtual void frameUpdate() {}
+
+	private:
 		boost::array<Vbo, TFV_NUM> tfVbos; ///< VBOs that contain the deformed vertex attributes
 		Vao tfVao; ///< For TF passes
 };

Some files were not shown because too many files changed in this diff