Panagiotis Christopoulos Charitos 15 years ago
parent
commit
1ecd88f684
4 changed files with 32 additions and 9 deletions
  1. 1 1
      src/Resources/Mesh.cpp
  2. 2 1
      src/Resources/Mesh.h
  3. 8 7
      src/Resources/Model.cpp
  4. 21 0
      src/Scene/ModelNode.h

+ 1 - 1
src/Resources/Mesh.cpp

@@ -13,7 +13,7 @@ Mesh::Mesh():
 	Resource(RT_MESH),
 	Object(NULL)
 {
-	memset(vbos, NULL, sizeof(vbos));
+	memset(&vbos[0], NULL, sizeof(vbos));
 }
 
 

+ 2 - 1
src/Resources/Mesh.h

@@ -1,6 +1,7 @@
 #ifndef MESH_H
 #define MESH_H
 
+#include <boost/array.hpp>
 #include "Math.h"
 #include "Resource.h"
 #include "RsrcPtr.h"
@@ -48,7 +49,7 @@ class Mesh: public Resource, public Object
 		bool hasVertWeights() const {return vbos[VBO_VERT_WEIGHTS] != NULL;}
 
 	private:
-		Vbo* vbos[VBOS_NUM]; ///< The vertex buffer objects
+		boost::array<Vbo*, VBOS_NUM> vbos; ///< The vertex buffer objects
 
 		/// Create the VBOs
 		void createVbos(const MeshData& meshData);

+ 8 - 7
src/Resources/Model.cpp

@@ -30,6 +30,14 @@ void Model::load(const char* filename)
 
   	const ptree& pt = pt_.get_child("model");
 
+  	// skeleton
+  	// NOTE: Always read that first
+  	boost::optional<std::string> skelName = pt.get_optional<std::string>("skeleton");
+  	if(skelName)
+  	{
+  		skeleton.loadRsrc(skelName.get().c_str());
+  	}
+
   	// subModels
   	BOOST_FOREACH(const ptree::value_type& v, pt.get_child("subModels"))
   	{
@@ -42,13 +50,6 @@ void Model::load(const char* filename)
   		sub->load(mesh.c_str(), material.c_str(), dpMaterial.c_str());
   	}
 
-  	// skeleton
-  	boost::optional<std::string> skelName = pt.get_optional<std::string>("skeleton");
-  	if(skelName)
-  	{
-  		skeleton.loadRsrc(skelName.get().c_str());
-  	}
-
   	// Anims
   	boost::optional<const ptree&> skelAnimsTree = pt.get_child_optional("skelAnims");
   	if(skelAnimsTree)

+ 21 - 0
src/Scene/ModelNode.h

@@ -1,6 +1,7 @@
 #ifndef MODEL_NODE_H
 #define MODEL_NODE_H
 
+#include <boost/array.hpp>
 #include "SceneNode.h"
 #include "RsrcPtr.h"
 #include "Properties.h"
@@ -8,6 +9,26 @@
 
 class Model;
 class SkelAnimModelNodeCtrl;
+class Vbo;
+
+
+/// @todo
+class Skin
+{
+	public:
+		enum Vbos
+		{
+			VBO_POSITIONS,
+			VBO_NORMALS,
+			VBO_TANGENTS,
+			VBOS_NUM
+		};
+
+		Vbo& getVbo(Vbos i) {return *vbos[i];}
+
+	private:
+		boost::array<Vbo*, VBOS_NUM> vbos;
+};
 
 
 /// The model scene node