Panagiotis Christopoulos Charitos пре 15 година
родитељ
комит
5f0882c21f
4 измењених фајлова са 59 додато и 6 уклоњено
  1. 2 2
      src/Resources/Model.h
  2. 40 0
      src/Resources/ModelPatch.h
  3. 15 2
      src/Scene/ModelNodePatch.cpp
  4. 2 2
      src/Scene/ModelNodePatch.h

+ 2 - 2
src/Resources/Model.h

@@ -46,10 +46,10 @@ class Model: public Resource
 {
 	public:
 		/// This is basically a container around mesh and materials. It also has the VAOs.
-		class SubModel: public Object
+		class SubModel
 		{
 			public:
-				SubModel(): Object(NULL) {}
+				SubModel(){}
 
 				/// Load the resources
 				void load(const char* meshFName, const char* mtlFName, const char* dpMtlFName);

+ 40 - 0
src/Resources/ModelPatch.h

@@ -0,0 +1,40 @@
+#ifndef MODEL_PATCH_H
+#define MODEL_PATCH_H
+
+#include ""
+
+
+/// A part of the Model
+class ModelPatch
+{
+	public:
+		/// Load the resources
+		void load(const char* meshFName, const char* mtlFName, const char* dpMtlFName);
+
+		/// Creates a VAO for an individual ModelPatch
+		/// @param[in] material Needed for the shader program uniform variables
+		/// @param[in] mesh For providing the VBOs
+		/// @param[in,out] subModel For setting a parent to the vao
+		/// @param[out] vao The output
+		static void createVao(const Material& material, const Mesh& mesh, Vao& vao);
+
+		/// @name Accessors
+		/// @{
+		const Mesh& getMesh() const {return *mesh;}
+		const Material& getMaterial() const {return *material;}
+		const Material& getDpMaterial() const {return *dpMaterial;}
+		const Vao& getVao() const {return vao;}
+		const Vao& getDpVao() const {return dpVao;}
+		/// @}
+
+		bool hasHwSkinning() const;
+
+	private:
+		RsrcPtr<Mesh> mesh; ///< The geometry
+		RsrcPtr<Material> material; ///< Material for MS and BS
+		RsrcPtr<Material> dpMaterial; ///< Material for depth passes
+		Vao vao; ///< Normal VAO for MS and BS
+		Vao dpVao; ///< Depth pass VAO for SM and EarlyZ
+};
+
+#endif

+ 15 - 2
src/Scene/ModelNodePatch.cpp

@@ -12,14 +12,27 @@
 ModelNodePatch::ModelNodePatch(const Model::SubModel& modelPatch_, bool isSkinPatch):
 	modelPatch(modelPatch_)
 {
-	//if()
+	if(!isSkinPatch)
+	{
+		for(uint i = 0; i < Mesh::VBOS_NUM; i++)
+		{
+			vbos[i] = &modelPatch.getMesh().getVbo((Mesh::Vbos)i);
+		}
+
+		createVao(modelPatch.getMaterial(), vbos, mainVao);
+		createVao(modelPatch.getDpMaterial(), vbos, dpVao);
+	}
+	else
+	{
+
+	}
 }
 
 
 //======================================================================================================================
 // createVao                                                                                                           =
 //======================================================================================================================
-void ModelNodePatch::createVao(const Material& mtl, const boost::array<Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao)
+void ModelNodePatch::createVao(const Material& mtl, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao)
 {
 	vao.create();
 

+ 2 - 2
src/Scene/ModelNodePatch.h

@@ -31,12 +31,12 @@ class ModelNodePatch
 	private:
 		const Model::SubModel& modelPatch;
 		boost::array<Vbo, TF_VBOS_NUM> tfVbos;
-		boost::array<Vbo*, Mesh::VBOS_NUM> vbos;
+		boost::array<const Vbo*, Mesh::VBOS_NUM> vbos;
 		Vao mainVao; ///< VAO for MS and BS
 		Vao dpVao; ///< VAO for depth passes
 		Vao tfVao; ///< VAO for transform feedback
 
-		static void createVao(const Material& material, const boost::array<Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao);
+		static void createVao(const Material& material, const boost::array<const Vbo*, Mesh::VBOS_NUM>& vbos, Vao& vao);
 };