Jelajahi Sumber

- Renaming MeshData to MeshLoader
- Refactoring Mesh* and Model*
- Light

Panagiotis Christopoulos Charitos 14 tahun lalu
induk
melakukan
16e915e21c

+ 19 - 12
anki/gl/Vao.h

@@ -5,6 +5,7 @@
 #include "anki/util/Assert.h"
 #include "anki/gl/GlException.h"
 #include <GL/glew.h>
+#include <boost/noncopyable.hpp>
 
 
 namespace anki {
@@ -14,24 +15,30 @@ class ShaderProgramAttributeVariable;
 class Vbo;
 
 
-/// Vertex array object
-class Vao
+/// Vertex array object. Non-copyable to avoid instantiating it in the stack
+class Vao: public boost::noncopyable
 {
 public:
-	/// Default constructor
+	/// @name Constructors
+	/// @{
+
+	/// Default
 	Vao()
 		: glId(0)
 	{}
+	/// @}
 
 	/// Destroy VAO from the OpenGL context
 	~Vao();
 
-	/// Accessor
+	/// @name Accessors
+	/// @{
 	uint getGlId() const
 	{
 		ANKI_ASSERT(isCreated());
 		return glId;
 	}
+	/// @}
 
 	/// Create
 	void create()
@@ -54,14 +61,14 @@ public:
 	/// @param vbo The VBO to attach
 	/// @param attribVar For the shader attribute location
 	/// @param size Specifies the number of components per generic vertex
-	/// attribute. Must be 1, 2, 3, 4
+	///        attribute. Must be 1, 2, 3, 4
 	/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
 	/// @param normalized Specifies whether fixed-point data values should
-	/// be normalized
+	///        be normalized
 	/// @param stride Specifies the byte offset between consecutive generic
-	/// vertex attributes
+	///        vertex attributes
 	/// @param pointer Specifies a offset of the first component of the
-	/// first generic vertex attribute in the array
+	///        first generic vertex attribute in the array
 	void attachArrayBufferVbo(
 		const Vbo& vbo,
 		const ShaderProgramAttributeVariable& attribVar,
@@ -77,14 +84,14 @@ public:
 	/// @param vbo The VBO to attach
 	/// @param attribVarLocation Shader attribute location
 	/// @param size Specifies the number of components per generic vertex
-	/// attribute. Must be 1, 2, 3, 4
+	///        attribute. Must be 1, 2, 3, 4
 	/// @param type GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT etc
 	/// @param normalized Specifies whether fixed-point data values should
-	/// be normalized
+	///        be normalized
 	/// @param stride Specifies the byte offset between consecutive generic
-	/// vertex attributes
+	///        vertex attributes
 	/// @param pointer Specifies a offset of the first component of the
-	/// first generic vertex attribute in the array
+	///        first generic vertex attribute in the array
 	void attachArrayBufferVbo(
 		const Vbo& vbo,
 		uint attribVarLocation,

+ 3 - 3
anki/resource/Mesh.cpp

@@ -1,6 +1,6 @@
 #include "anki/resource/Mesh.h"
 #include "anki/resource/Material.h"
-#include "anki/resource/MeshData.h"
+#include "anki/resource/MeshLoader.h"
 #include "anki/gl/Vbo.h"
 #include "anki/util/Util.h"
 #include <fstream>
@@ -13,7 +13,7 @@ namespace anki {
 //==============================================================================
 void Mesh::load(const char* filename)
 {
-	MeshData meshData(filename);
+	MeshLoader meshData(filename);
 
 	vertIdsNum = meshData.getVertIndeces().size();
 	vertsNum = meshData.getVertCoords().size();
@@ -42,7 +42,7 @@ void Mesh::load(const char* filename)
 
 
 //==============================================================================
-void Mesh::createVbos(const MeshData& meshData)
+void Mesh::createVbos(const MeshLoader& meshData)
 {
 	vbos[VBO_INDICES].create(
 		GL_ELEMENT_ARRAY_BUFFER,

+ 6 - 3
anki/resource/Mesh.h

@@ -10,7 +10,7 @@
 namespace anki {
 
 
-class MeshData;
+class MeshLoader;
 
 
 /// This is the interface class for meshes. Its interface because the skin
@@ -42,6 +42,8 @@ public:
 	virtual uint getLodsNumber() const = 0;
 	virtual uint getIndicesNumber(uint lod) const = 0;
 	virtual uint getVerticesNumber(uint lod) const = 0;
+
+	virtual const Obb& getBoundingShape() const = 0;
 	/// @}
 
 	/// @name Ask for geometry properties
@@ -121,7 +123,8 @@ public:
 		return vertsNum;
 	}
 
-	const Obb& getVisibilityShape() const
+	/// Implements MeshBase::getBoundingShape
+	const Obb& getBoundingShape() const
 	{
 		return visibilityShape;
 	}
@@ -137,7 +140,7 @@ private:
 	uint vertsNum;
 
 	/// Create the VBOs using the mesh data
-	void createVbos(const MeshData& meshData);
+	void createVbos(const MeshLoader& meshData);
 };
 
 

+ 7 - 7
anki/resource/MeshData.cpp → anki/resource/MeshLoader.cpp

@@ -3,7 +3,7 @@
 #include <boost/lexical_cast.hpp>
 #include <boost/foreach.hpp>
 
-#include "anki/resource/MeshData.h"
+#include "anki/resource/MeshLoader.h"
 #include "anki/util/BinaryStream.h"
 
 
@@ -11,7 +11,7 @@ namespace anki {
 
 
 //==============================================================================
-void MeshData::load(const char* filename)
+void MeshLoader::load(const char* filename)
 {
 	// Try
 	try
@@ -131,7 +131,7 @@ void MeshData::load(const char* filename)
 
 
 //==============================================================================
-void MeshData::doPostLoad()
+void MeshLoader::doPostLoad()
 {
 	// Sanity checks
 	if(vertCoords.size() < 1 || tris.size() < 1)
@@ -160,7 +160,7 @@ void MeshData::doPostLoad()
 
 
 //==============================================================================
-void MeshData::createVertIndeces()
+void MeshLoader::createVertIndeces()
 {
 	vertIndeces.resize(tris.size() * 3);
 	for(uint i = 0; i < tris.size(); i++)
@@ -173,7 +173,7 @@ void MeshData::createVertIndeces()
 
 
 //==============================================================================
-void MeshData::createFaceNormals()
+void MeshLoader::createFaceNormals()
 {
 	BOOST_FOREACH(Triangle& tri, tris)
 	{
@@ -194,7 +194,7 @@ void MeshData::createFaceNormals()
 
 
 //==============================================================================
-void MeshData::createVertNormals()
+void MeshLoader::createVertNormals()
 {
 	vertNormals.resize(vertCoords.size());
 
@@ -218,7 +218,7 @@ void MeshData::createVertNormals()
 
 
 //==============================================================================
-void MeshData::createVertTangents()
+void MeshLoader::createVertTangents()
 {
 	vertTangents.resize(vertCoords.size(), Vec4(0.0)); // alloc
 	std::vector<Vec3> bitagents(vertCoords.size(), Vec3(0.0));

+ 10 - 13
anki/resource/MeshData.h → anki/resource/MeshLoader.h

@@ -1,5 +1,5 @@
-#ifndef ANKI_RESOURCE_MESH_DATA_H
-#define ANKI_RESOURCE_MESH_DATA_H
+#ifndef ANKI_RESOURCE_MESH_LOADER_H
+#define ANKI_RESOURCE_MESH_LOADER_H
 
 #include "anki/math/Math.h"
 #include "anki/util/StdTypes.h"
@@ -43,7 +43,7 @@ namespace anki {
 ///       float: weight for vert 0 and weight 0, ...
 /// ...
 /// @endcode
-class MeshData
+class MeshLoader
 {
 public:
 	/// Vertex weight for skeletal animation
@@ -69,11 +69,11 @@ public:
 			Vec3 normal;
 	};
 
-	MeshData(const char* filename)
+	MeshLoader(const char* filename)
 	{
 		load(filename);
 	}
-	~MeshData()
+	~MeshLoader()
 	{}
 
 	/// @name Accessors
@@ -134,7 +134,11 @@ private:
 
 	void createFaceNormals();
 	void createVertNormals();
-	void createAllNormals();
+	void createAllNormals()
+	{
+		createFaceNormals();
+		createVertNormals();
+	}
 	void createVertTangents();
 	void createVertIndeces();
 
@@ -145,13 +149,6 @@ private:
 };
 
 
-inline void MeshData::createAllNormals()
-{
-	createFaceNormals();
-	createVertNormals();
-}
-
-
 } // end namespace
 
 

+ 47 - 54
anki/resource/Model.cpp

@@ -2,7 +2,7 @@
 #include "anki/resource/Material.h"
 #include "anki/resource/Mesh.h"
 #include "anki/resource/SkelAnim.h"
-#include "anki/resource/MeshData.h"
+#include "anki/resource/MeshLoader.h"
 #include "anki/resource/Skeleton.h"
 #include "anki/resource/ShaderProgram.h"
 #include <boost/foreach.hpp>
@@ -16,42 +16,12 @@ namespace anki {
 
 
 //==============================================================================
-// ModelPatch                                                                  =
-//==============================================================================
-
-//==============================================================================
-ModelPatch::ModelPatch(const char* meshFName, const char* mtlFName)
-{
-	// Load
-	mesh.load(meshFName);
-	mtl.load(mtlFName);
-
-	// Create VAOs
-	VboArray vboArr;
-	for(uint i = 0; i < Mesh::VBOS_NUM; i++)
-	{
-		vboArr[i] = &mesh->getVbo((Mesh::Vbos)i);
-	}
-
-	createVaos(*mtl, vboArr, vaos, vaosHashMap);
-}
-
-
+// ModelPatchBase                                                              =
 //==============================================================================
-ModelPatch::~ModelPatch()
-{}
-
-
-//==============================================================================
-bool ModelPatch::supportsHwSkinning() const
-{
-	return mesh->hasVertWeights();
-}
-
 
 //==============================================================================
-Vao* ModelPatch::createVao(const Material& mtl,
-	const VboArray& vbos,
+Vao* ModelPatchBase::createNewVao(const Material& mtl,
+	const MeshBase& meshb,
 	const PassLevelKey& key)
 {
 	Vao* vao = new Vao;
@@ -59,45 +29,47 @@ Vao* ModelPatch::createVao(const Material& mtl,
 
 	if(mtl.getShaderProgram(key).attributeVariableExists("position"))
 	{
-		ANKI_ASSERT(vbos[Mesh::VBO_VERT_POSITIONS] != NULL);
+		const Vbo* vbo = meshb.getVbo(Mesh::VBO_POSITIONS);
+		ANKI_ASSERT(vbo != NULL);
 
-		vao->attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_POSITIONS],
-			0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
+		vao->attachArrayBufferVbo(*vbo, 0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
 	}
 
 	if(mtl.getShaderProgram(key).attributeVariableExists("normal"))
 	{
-		ANKI_ASSERT(vbos[Mesh::VBO_VERT_NORMALS] != NULL);
+		const Vbo* vbo = meshb.getVbo(Mesh::VBO_NORMALS);
+		ANKI_ASSERT(vbo != NULL);
 
-		vao->attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_NORMALS],
-			1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
+		vao->attachArrayBufferVbo(*vbo, 1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
 	}
 
 	if(mtl.getShaderProgram(key).attributeVariableExists("tangent"))
 	{
-		ANKI_ASSERT(vbos[Mesh::VBO_VERT_TANGENTS] != NULL);
+		const Vbo* vbo = meshb.getVbo(Mesh::VBO_TANGENTS);
+		ANKI_ASSERT(vbo != NULL);
 
-		vao->attachArrayBufferVbo(*vbos[Mesh::VBO_VERT_TANGENTS],
-			2, 4, GL_FLOAT, GL_FALSE, 0, NULL);
+		vao->attachArrayBufferVbo(*vbo, 2, 4, GL_FLOAT, GL_FALSE, 0, NULL);
 	}
 
 	if(mtl.getShaderProgram(key).attributeVariableExists("texCoords"))
 	{
-		vao->attachArrayBufferVbo(*vbos[Mesh::VBO_TEX_COORDS],
-			3, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+		const Vbo* vbo = meshb.getVbo(Mesh::VBO_TEX_COORDS);
+		ANKI_ASSERT(vbo != NULL);
+
+		vao->attachArrayBufferVbo(*vbo, 3, 2, GL_FLOAT, GL_FALSE, 0, NULL);
 	}
 
-	vao->attachElementArrayBufferVbo(*vbos[Mesh::VBO_VERT_INDECES]);
+	vao->attachElementArrayBufferVbo(*meshb.getVbo(Mesh::VBO_INDICES));
 
 	return vao;
 }
 
 
 //==============================================================================
-void ModelPatch::createVaos(const Material& mtl,
-	const VboArray& vbos,
+void ModelPatchBase::createVaos(const Material& mtl,
+	const MeshBase& meshb,
 	VaosContainer& vaos,
-	PassLevelToVaoHashMap& vaosHashMap)
+	PassLevelToVaoMap& vaosMap)
 {
 	for(uint level = 0; level < mtl.getLevelsOfDetail(); ++level)
 	{
@@ -105,15 +77,36 @@ void ModelPatch::createVaos(const Material& mtl,
 		{
 			PassLevelKey key(pass, level);
 
-			Vao* vao = createVao(mtl, vbos, key);
+			Vao* vao = createNewVao(mtl, meshb, key);
 
 			vaos.push_back(vao);
-			vaosHashMap[key] = vao;
+			vaosMap[key] = vao;
 		}
 	}
 }
 
 
+//==============================================================================
+// ModelPatch                                                                  =
+//==============================================================================
+
+//==============================================================================
+ModelPatch::ModelPatch(const char* meshFName, const char* mtlFName)
+{
+	// Load
+	mesh.load(meshFName);
+	mtl.load(mtlFName);
+
+	/// Create VAOs
+	create();
+}
+
+
+//==============================================================================
+ModelPatch::~ModelPatch()
+{}
+
+
 //==============================================================================
 // Model                                                                       =
 //==============================================================================
@@ -148,19 +141,19 @@ void Model::load(const char* filename)
 		}
 
 		// Calculate compound bounding volume
-		visibilityShape = modelPatches[0].getMesh().getVisibilityShape();
+		visibilityShape = modelPatches[0].getMeshBase().getBoundingShape();
 
 		for(ModelPatchesContainer::const_iterator it = modelPatches.begin() + 1;
 			it != modelPatches.end();
 			++it)
 		{
 			visibilityShape = visibilityShape.getCompoundShape(
-				(*it).getMesh().getVisibilityShape());
+				(*it).getMeshBase().getBoundingShape());
 		}
 	}
 	catch(std::exception& e)
 	{
-		throw ANKI_EXCEPTION("Model \"" + filename + "\"") << e;
+		throw ANKI_EXCEPTION("Model loading failed: " + filename) << e;
 	}
 }
 

+ 53 - 26
anki/resource/Model.h

@@ -12,53 +12,80 @@
 namespace anki {
 
 
+/// XXX
+class ModelPatchBase
+{
+public:
+	/// For garbage collection
+	typedef boost::ptr_vector<Vao> VaosContainer;
+	/// Map to get the VAO given a PassLod key
+	typedef PassLevelHashMap<Vao*>::Type PassLevelToVaoMap;
+
+	virtual ~ModelPatchBase()
+	{}
+
+	virtual const MeshBase& getMeshBase() const = 0;
+	virtual const Material& getMaterial() const = 0;
+
+	const Vao& getVao(const PassLevelKey& key) const
+	{
+		return *vaosMap.at(key);
+	}
+
+protected:
+	VaosContainer vaos;
+	PassLevelToVaoMap vaosMap;
+
+	void create()
+	{
+		createVaos(getMaterial(), getMeshBase(), vaos, vaosMap);
+	}
+
+	/// Create VAOs using a material and a mesh. It writes a VaosContainer and
+	/// a hash map
+	static void createVaos(const Material& mtl,
+		const MeshBase& mesh,
+		VaosContainer& vaos,
+		PassLevelToVaoMap& vaosMap);
+
+	/// Called by @a createVaos multiple times to create and populate a single
+	/// VAO
+	static Vao* createNewVao(const Material& mtl,
+		const MeshBase& mesh,
+		const PassLevelKey& key);
+};
+
+
 /// Its a chunk of a model. Its very important class and it binds the material
 /// with the mesh
-class ModelPatch
+class ModelPatch: public ModelPatchBase
 {
 public:
-	typedef boost::ptr_vector<Vao> VaosContainer;
-	typedef PassLevelHashMap<Vao*>::Type PassLevelToVaoHashMap;
-	typedef boost::array<const Vbo*, Mesh::VBOS_NUM> VboArray;
+	/// Map to get the VAO given a PassLod key
+	typedef PassLevelHashMap<Vao>::Type PassLevelToVaoMap;
 
 	ModelPatch(const char* meshFName, const char* mtlFName);
 	~ModelPatch();
 
 	/// @name Accessors
 	/// @{
-	const Mesh& getMesh() const
+
+	/// Implements ModelPatchBase::getMeshBase
+	const MeshBase& getMeshBase() const
 	{
 		return *mesh;
 	}
 
+	/// Implements ModelPatchBase::getMaterial
 	const Material& getMaterial() const
 	{
 		return *mtl;
 	}
 	/// @}
 
-	bool supportsHwSkinning() const;
-
-	const Vao& getVao(const PassLevelKey& key) const
-	{
-		return *vaosHashMap.at(key);
-	}
-
-	static void createVaos(const Material& mtl,
-		const VboArray& vbos,
-		VaosContainer& vaos,
-		PassLevelToVaoHashMap& vaosHashMap);
-
 private:
 	MeshResourcePointer mesh; ///< The geometry
 	MaterialResourcePointer mtl; ///< Material
-
-	VaosContainer vaos;
-	PassLevelToVaoHashMap vaosHashMap;
-
-	static Vao* createVao(const Material& mtl,
-		const VboArray& vbos,
-		const PassLevelKey& key);
 };
 
 
@@ -88,8 +115,6 @@ class Model
 public:
 	typedef boost::ptr_vector<ModelPatch> ModelPatchesContainer;
 
-	void load(const char* filename);
-
 	/// @name Accessors
 	/// @{
 	const ModelPatchesContainer& getModelPatches() const
@@ -103,6 +128,8 @@ public:
 	}
 	/// @}
 
+	void load(const char* filename);
+
 private:
 	/// The vector of ModelPatch
 	ModelPatchesContainer modelPatches;

+ 7 - 11
anki/resource/ShaderProgram.cpp

@@ -457,18 +457,14 @@ std::ostream& operator<<(std::ostream& s, const ShaderProgram& x)
 {
 	s << "ShaderProgram (" << x.rsrcFilename << ")\n";
 	s << "Variables:\n";
-	BOOST_FOREACH(const ShaderProgramVariable& var, x.getVariables())
+	for(ShaderProgram::VariablesContainer::const_iterator it = x.vars.begin();
+		it != x.vars.end(); ++it)
 	{
-		s << var.getName() << " " << var.getLocation() << " ";
-		if(var.getType() == ShaderProgramVariable::T_ATTRIBUTE)
-		{
-			s << "[A]";
-		}
-		else
-		{
-			s << "[U]";
-		}
-		s << '\n';
+		const ShaderProgramVariable& var = *it;
+
+		s << var.getName() << " " << var.getLocation() << " " <<
+			(var.getType() == ShaderProgramVariable::T_ATTRIBUTE ? "[A]" :
+			"[U]") <<  '\n';
 	}
 	return s;
 }

+ 11 - 11
anki/resource/Skin.cpp

@@ -1,6 +1,3 @@
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
-#include <boost/foreach.hpp>
 #include "anki/resource/Skin.h"
 #include "anki/resource/Model.h"
 #include "anki/resource/Skeleton.h"
@@ -9,13 +6,14 @@
 #include "anki/resource/PassLevelKey.h"
 #include "anki/resource/Model.h"
 #include "anki/resource/Material.h"
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/xml_parser.hpp>
+#include <boost/foreach.hpp>
 
 
 namespace anki {
 
 
-//==============================================================================
-// Constructors & Destructors                                                  =
 //==============================================================================
 
 Skin::Skin()
@@ -26,8 +24,6 @@ Skin::~Skin()
 {}
 
 
-//==============================================================================
-// load                                                                        =
 //==============================================================================
 void Skin::load(const char* filename)
 {
@@ -85,17 +81,21 @@ void Skin::load(const char* filename)
 		}
 
 		// All meshes should have vert weights
-		BOOST_FOREACH(const ModelPatch& patch, model->getModelPatches())
+		for(Model::ModelPatchesContainer::const_iterator it =
+			model->getModelPatches().begin();
+			it != model->getModelPatches().end(); ++it)
 		{
-			if(!patch.supportsHwSkinning())
+			const ModelPatch& patch = *it;
+
+			if(!patch.getMeshBase().hasWeights())
 			{
 				throw ANKI_EXCEPTION("Mesh does not support HW skinning");
 			}
 		}
 	  }
-	catch(std::exception& e)
+	catch(const std::exception& e)
 	{
-		throw ANKI_EXCEPTION("Skin \"" + filename + "\"") << e;
+		throw ANKI_EXCEPTION("Skin loading failed: " + filename) << e;
 	}
 }
 

+ 17 - 29
anki/resource/Skin.h

@@ -27,6 +27,8 @@ class SkelAnim;
 class Skin
 {
 public:
+	typedef std::vector<SkelAnimResourcePointer> SkeletonAnimationsContainer;
+
 	Skin();
 	~Skin();
 
@@ -35,10 +37,20 @@ public:
 
 	/// @name Accessors
 	/// @{
-	const Model& getModel() const;
-	const boost::ptr_vector<ModelPatch>& getModelPatches() const;
-	const Skeleton& getSkeleton() const;
-	const std::vector<SkelAnimResourcePointer >& getSkelAnims() const;
+	const Model& getModel() const
+	{
+		return *model;
+	}
+
+	const Skeleton& getSkeleton() const
+	{
+		return *skeleton;
+	}
+
+	const SkeletonAnimationsContainer& getSkeletonAnimations() const
+	{
+		return skelAnims;
+	}
 	/// @}
 
 private:
@@ -47,35 +59,11 @@ private:
 	ModelResourcePointer model;
 	SkeletonResourcePointer skeleton; ///< The skeleton
 	/// The standard skeleton animations
-	std::vector<SkelAnimResourcePointer > skelAnims;
+	SkeletonAnimationsContainer skelAnims;
 	/// @}
 };
 
 
-inline const Model& Skin::getModel() const
-{
-	return *model;
-}
-
-
-inline const boost::ptr_vector<ModelPatch>& Skin::getModelPatches() const
-{
-	return model->getModelPatches();
-}
-
-
-inline const Skeleton& Skin::getSkeleton() const
-{
-	return *skeleton;
-}
-
-
-inline const std::vector<SkelAnimResourcePointer >& Skin::getSkelAnims() const
-{
-	return skelAnims;
-}
-
-
 } // end namespace
 
 

+ 22 - 25
anki/scene/Light.h

@@ -43,17 +43,11 @@ public:
 	Light(LightType t,
 		const char* name, Scene* scene, // Scene
 		uint movableFlags, Movable* movParent, // Movable
-		CollisionShape* cs, // Spatial
-		const char* smoMeshFname) // SMO mesh
+		CollisionShape* cs) // Spatial
 		: SceneNode(name, scene), Movable(movableFlags, movParent),
 			Spatial(cs), type(t)
 	{
-		smoMesh.load(smoMeshFname);
-		vao.create();
-		vao.attachArrayBufferVbo(smoMesh->getVbo(Mesh::VBO_VERT_POSITIONS),
-			0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-		vao.attachElementArrayBufferVbo(
-			smoMesh->getVbo(Mesh::VBO_VERT_INDECES));
+		/// XXX mtlr
 	}
 	/// @}
 
@@ -67,7 +61,7 @@ public:
 	}
 	/// @}
 
-	/// @name Virtuals
+	/// @name SceneNode virtuals
 	/// @{
 	Movable* getMovable()
 	{
@@ -83,32 +77,36 @@ public:
 	{
 		return this;
 	}
+	/// @}
 
-	const Vao& getVao(const PassLevelKey& k)
+	/// @name Renderable virtuals
+	/// @{
+	const ModelPatchBase* getModelPatchBase() const
 	{
-		ANKI_ASSERT(k.pass == 1 && "Call only in SMO");
-		(void)k; // No warnings please
-		return vao;
+		ANKI_ASSERT(0 && "Lights don't support it");
+		return NULL;
 	}
 
-	uint getVertexIdsNum(const PassLevelKey& k)
+	MaterialRuntime& getMaterialRuntime()
 	{
-		ANKI_ASSERT(k.pass == 1 && "Call only in SMO");
-		(void)k; // No warnings please
-		return smoMesh->getVertIdsNum();
+		return *mtlr;
 	}
 
-	MaterialRuntime& getMaterialRuntime()
+	const Transform* getWorldTransform(const PassLevelKey&)
 	{
-		return *mtlr;
+		return &getWorldTranform();
+	}
+
+	const Transform* getPreviousWorldTransform(
+		const PassLevelKey&)
+	{
+		return &getPreviousWorldTranform();
 	}
 	/// @}
 
 private:
 	LightType type;
 	boost::scoped_ptr<MaterialRuntime> mtlr;
-	MeshResourcePointer smoMesh; ///< Model for SMO pases
-	Vao smoVao;
 };
 
 
@@ -118,12 +116,11 @@ class PointLight: public Light
 public:
 	PointLight(const char* name, Scene* scene, uint movableFlags,
 		Movable* movParent)
-		: Light(LT_POINT, name, scene, movableFlags, movParent, &frustum,
-			"sadf")
+		: Light(LT_POINT, name, scene, movableFlags, movParent, &sphere)
 	{}
 
-private:
-	PerspectiveFrustum frustum;
+public:
+	Sphere sphere;
 };
 
 

+ 27 - 9
anki/scene/Renderable.h

@@ -7,7 +7,7 @@ namespace anki {
 
 class PassLevelKey;
 class MaterialRuntime;
-class Vao;
+class MeshBase;
 class Transform;
 
 
@@ -20,21 +20,39 @@ class Transform;
 class Renderable
 {
 public:
-	/// Get VAO depending the rendering pass
-	virtual const Vao& getVao(const PassLevelKey& k) = 0;
-
-	/// Get vert ids number for rendering
-	virtual uint getVertexIdsNum(const PassLevelKey& k) = 0;
+	/// Access to VAOs
+	virtual const ModelPatchBase* getModelPatchBase() const
+	{
+		return NULL;
+	}
 
 	/// Get the material runtime
 	virtual MaterialRuntime& getMaterialRuntime() = 0;
 
 	/// Get current transform
-	virtual const Transform& getWorldTransform(const PassLevelKey& k) = 0;
+	virtual const Transform* getWorldTransform(const PassLevelKey& k)
+	{
+		return NULL;
+	}
 
 	/// Get previous transform
-	virtual const Transform& getPreviousWorldTransform(
-		const PassLevelKey& k) = 0;
+	virtual const Transform* getPreviousWorldTransform(
+		const PassLevelKey& k)
+	{
+		return NULL;
+	}
+
+	/// Get projection matrix (for lights)
+	virtual const Mat4* getProjectionMatrix() const
+	{
+		return NULL;
+	}
+
+	/// Get view matrix (for lights)
+	virtual const Mat4* getViewMatrix() const
+	{
+		return NULL;
+	}
 };
 /// @}
 

+ 4 - 4
anki/scene/SkinNode.cpp

@@ -2,7 +2,7 @@
 #include "anki/resource/Skin.h"
 #include "anki/resource/Skeleton.h"
 #include "anki/resource/SkelAnim.h"
-#include "anki/resource/MeshData.h"
+#include "anki/resource/MeshLoader.h"
 #include <boost/foreach.hpp>
 
 
@@ -101,7 +101,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch* modelPatch_, SceneNode* parent)
 		1,
 		GL_FLOAT,
 		GL_FALSE,
-		sizeof(MeshData::VertexWeight),
+		sizeof(MeshLoader::VertexWeight),
 		BUFFER_OFFSET(0));
 
 	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS),
@@ -109,7 +109,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch* modelPatch_, SceneNode* parent)
 		4,
 		GL_FLOAT,
 		GL_FALSE,
-		sizeof(MeshData::VertexWeight),
+		sizeof(MeshLoader::VertexWeight),
 		BUFFER_OFFSET(4));
 
 	tfVao.attachArrayBufferVbo(mesh.getVbo(Mesh::VBO_VERT_WEIGHTS),
@@ -117,7 +117,7 @@ SkinPatchNode::SkinPatchNode(const ModelPatch* modelPatch_, SceneNode* parent)
 		4,
 		GL_FLOAT,
 		GL_FALSE,
-		sizeof(MeshData::VertexWeight),
+		sizeof(MeshLoader::VertexWeight),
 		BUFFER_OFFSET(20));