瀏覽代碼

Same as before

Panagiotis Christopoulos Charitos 14 年之前
父節點
當前提交
6d97d7a19a
共有 3 個文件被更改,包括 112 次插入63 次删除
  1. 100 0
      anki/resource/Mesh.h
  2. 0 42
      anki/scene/PatchNode.cpp
  3. 12 21
      anki/scene/PatchNode.h

+ 100 - 0
anki/resource/Mesh.h

@@ -14,6 +14,106 @@ namespace anki {
 class MeshData;
 
 
+/// XXX
+class MeshBase
+{
+	public:
+		MeshBase()
+		{
+			pVbo = nVbo = tVbo = vwVbo = NULL;
+		}
+
+		virtual ~MeshBase()
+		{}
+
+		/// @name Accessors
+		/// @{
+		const Vbo& getPositionsVbo() const
+		{
+			ANKI_ASSERT(pVbo != NULL);
+			return *pVbo;
+		}
+
+		const Vbo& getNormalsVbo() const
+		{
+			ANKI_ASSERT(nVbo != NULL);
+			return *nVbo;
+		}
+
+		const Vbo& getTangentsVbo() const
+		{
+			ANKI_ASSERT(tVbo != NULL);
+			return *tVbo;
+		}
+
+		const Vbo& getTextureCoordsVbo(uint channel) const
+		{
+			ANKI_ASSERT(texVbo[channel] != NULL);
+			return *texVbo[channel];
+		}
+
+		const Vbo& getIndecesVbo(uint lod) const
+		{
+			ANKI_ASSERT(iVbo[lod] != NULL);
+			return *iVbo[lod];
+		}
+
+		const Vbo& getWeightsVbo() const
+		{
+			ANKI_ASSERT(wVbo != NULL);
+			return *wVbo;
+		}
+
+		uint getTextureChannelsNumber() const
+		{
+			return texVbo.size();
+		}
+
+		uint getLodsNumber() const
+		{
+			ANKI_ASSERT(iVbo.size() > 0);
+			return iVbo.size();
+		}
+
+		uint getIndicesNumber(uint lod) const
+		{
+			ANKI_ASSERT(idsNum[lod] != 0);
+			return idsNum[lod];
+		}
+
+		uint getVertexNumber(uint lod) const
+		{
+			ANKI_ASSERT(vertsNum[lod] != 0);
+			return vertsNum[lod];
+		}
+		/// @}
+
+		/// @name Ask for geometry properties
+		/// @{
+		bool hasTexCoords() const
+		{
+			return texVbo != NULL;
+		}
+
+		bool hasWeights() const
+		{
+			return vwVbo != NULL;
+		}
+		/// @}
+
+	protected:
+		Vbo* pVbo; ///< Mandatory
+		Vbo* nVbo; ///< Mandatory
+		Vbo* tVbo; ///< Mandatory
+		std::vector<Vbo*> texVbo; ///< Optional. Tex coords per channel
+		std::vector<Vbo*> iVbo; ///< Mandatory. Indices VBO per LOD
+		Vbo* vwVbo; ///< Optional
+
+		std::vector<uint> idsNum; ///< Indices count per LOD
+		std::vector<uint> vertsNum; ///< Vertex count per LOD
+};
+
+
 /// Mesh Resource. It contains the geometry packed in VBOs
 class Mesh
 {

+ 0 - 42
anki/scene/PatchNode.cpp

@@ -18,46 +18,4 @@ PatchNode::PatchNode(const ModelPatch& modelPatch, ulong flags,
 {}
 
 
-//==============================================================================
-// createVao                                                                   =
-//==============================================================================
-void PatchNode::createVao(const MaterialRuntime& mtl, const VboArray& vbos,
-	Vao& vao)
-{
-	vao.create();
-
-	if(mtl.variableExits("position"))
-	{
-		ANKI_ASSERT(vbos[Mesh::VBO_VERT_POSITIONS] != NULL);
-
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_POSITIONS],
-			0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	if(mtl.variableExits("normal"))
-	{
-		ANKI_ASSERT(vbos[Mesh::VBO_VERT_NORMALS] != NULL);
-
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_NORMALS],
-			1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	if(mtl.variableExits("tangent"))
-	{
-		ANKI_ASSERT(vbos[Mesh::VBO_VERT_TANGENTS] != NULL);
-
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_TANGENTS],
-			2, 4, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	if(mtl.variableExits("texCoords"))
-	{
-		vao.attachArrayBufferVbo(*vbos[Mesh::VBO_TEX_COORDS],
-			3, 2, GL_FLOAT, GL_FALSE, 0, NULL);
-	}
-
-	vao.attachElementArrayBufferVbo(*vbos[Mesh::VBO_VERT_INDECES]);
-}
-
-
 } // end namespace

+ 12 - 21
anki/scene/PatchNode.h

@@ -23,28 +23,29 @@ class Material;
 class PatchNode: public RenderableNode
 {
 	public:
-		typedef boost::array<const Vbo*, Mesh::VBOS_NUM> VboArray;
-
 		PatchNode(const ModelPatch& modelPatch, ulong flags,
 			SceneNode& parent);
 
 		/// @name Accessors
 		/// @{
 
-		/// Implements RenderableNode::getVao
-		const Vao& getVao(PassType p) const {return vaos[p];}
-
-		/// Implements RenderableNode::getVertIdsNum
-		uint getVertIdsNum() const {return rsrc.getMesh().getVertIdsNum();}
-
 		/// Implements RenderableNode::getMaterial
-		const Material& getMaterial() const {return rsrc.getMaterial();}
+		const Material& getMaterial() const
+		{
+			return rsrc.getMaterial();
+		}
 
 		/// Implements RenderableNode::getMaterialRuntime
-		MaterialRuntime& getMaterialRuntime() {return *mtlRun;}
+		MaterialRuntime& getMaterialRuntime()
+		{
+			return *mtlRun;
+		}
 
 		/// Implements RenderableNode::getMaterialRuntime
-		const MaterialRuntime& getMaterialRuntime() const {return *mtlRun;}
+		const MaterialRuntime& getMaterialRuntime() const
+		{
+			return *mtlRun;
+		}
 
 		const ModelPatch& getModelPatchRsrc() const {return rsrc;}
 		/// @}
@@ -53,17 +54,7 @@ class PatchNode: public RenderableNode
 		/// The sub-resource
 		const ModelPatch& rsrc;
 
-		/// The VAOs. All VBOs could be attached except for the vertex weights
-		boost::array<Vao, PASS_TYPES_NUM> vaos;
-
 		boost::scoped_ptr<MaterialRuntime> mtlRun; ///< Material runtime
-
-		/// Create a VAO given a material and an array of VBOs
-		/// The location of the uniform variables are hard coded. See
-		/// MaterialVertex.glsl
-		static void createVao(const MaterialRuntime& material,
-			const VboArray& vbos,
-			Vao& vao);
 };