Panagiotis Christopoulos Charitos преди 14 години
родител
ревизия
02ad48cd16
променени са 4 файла, в които са добавени 50 реда и са изтрити 34 реда
  1. 5 5
      anki/scene/Camera.h
  2. 33 21
      anki/scene/Light.h
  3. 7 3
      anki/scene/SceneNode.h
  4. 5 5
      anki/scene/Spatial.h

+ 5 - 5
anki/scene/Camera.h

@@ -2,7 +2,7 @@
 #define ANKI_SCENE_CAMERA_H
 #define ANKI_SCENE_CAMERA_H
 
 
 #include "anki/scene/SceneNode.h"
 #include "anki/scene/SceneNode.h"
-#include "anki/scene/Spartial.h"
+#include "anki/scene/Spatial.h"
 #include "anki/scene/Movable.h"
 #include "anki/scene/Movable.h"
 #include "anki/scene/Frustumable.h"
 #include "anki/scene/Frustumable.h"
 
 
@@ -14,7 +14,7 @@ namespace anki {
 /// @{
 /// @{
 
 
 /// Camera SceneNode interface class
 /// Camera SceneNode interface class
-class Camera: public SceneNode, public Movable, public Spartial,
+class Camera: public SceneNode, public Movable, public Spatial,
 	public Frustumable
 	public Frustumable
 {
 {
 public:
 public:
@@ -34,7 +34,7 @@ public:
 		CollisionShape* spartCs,
 		CollisionShape* spartCs,
 		Frustum* frustum)
 		Frustum* frustum)
 		: SceneNode(name, scene), Movable(movableFlags, movParent),
 		: SceneNode(name, scene), Movable(movableFlags, movParent),
-			Spartial(spartCs), Frustumable(frustum), type(type_)
+			Spatial(spartCs), Frustumable(frustum), type(type_)
 	{}
 	{}
 	/// @}
 	/// @}
 
 
@@ -78,8 +78,8 @@ public:
 		return this;
 		return this;
 	}
 	}
 
 
-	/// Re-implements SceneNode::getSpartial()
-	virtual Spartial* getSpartial()
+	/// Re-implements SceneNode::getSpatial()
+	virtual Spatial* getSpatial()
 	{
 	{
 		return this;
 		return this;
 	}
 	}

+ 33 - 21
anki/scene/Light.h

@@ -5,7 +5,8 @@
 #include "anki/scene/Movable.h"
 #include "anki/scene/Movable.h"
 #include "anki/scene/Renderable.h"
 #include "anki/scene/Renderable.h"
 #include "anki/scene/Frustumable.h"
 #include "anki/scene/Frustumable.h"
-#include "anki/scene/Spartial.h"
+#include "anki/scene/Spatial.h"
+#include "anki/gl/Vao.h"
 
 
 
 
 namespace anki {
 namespace anki {
@@ -28,7 +29,7 @@ namespace anki {
 /// Specular intensity of material: Sm
 /// Specular intensity of material: Sm
 /// @endcode
 /// @endcode
 class Light: public SceneNode, public Movable, public Renderable,
 class Light: public SceneNode, public Movable, public Renderable,
-	public Spartial
+	public Spatial
 {
 {
 public:
 public:
 	enum LightType
 	enum LightType
@@ -40,14 +41,19 @@ public:
 	/// @name Constructors
 	/// @name Constructors
 	/// @{
 	/// @{
 	Light(LightType t,
 	Light(LightType t,
-		const char* name, Scene* scene,
-		uint movableFlags, Movable* movParent,
-		CollisionShape* cs,
-		const char* modelFname)
+		const char* name, Scene* scene, // Scene
+		uint movableFlags, Movable* movParent, // Movable
+		CollisionShape* cs, // Spatial
+		const char* smoMeshFname) // SMO mesh
 		: SceneNode(name, scene), Movable(movableFlags, movParent),
 		: SceneNode(name, scene), Movable(movableFlags, movParent),
-			Spartial(cs), type(t)
+			Spatial(cs), type(t)
 	{
 	{
-		//smoModel
+		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));
 	}
 	}
 	/// @}
 	/// @}
 
 
@@ -73,36 +79,36 @@ public:
 		return this;
 		return this;
 	}
 	}
 
 
-	Spartial* getSpartial()
+	Spatial* getSpatial()
 	{
 	{
 		return this;
 		return this;
 	}
 	}
 
 
-	const Vao& getVao(const PassLevelKey&)
+	const Vao& getVao(const PassLevelKey& k)
 	{
 	{
-		//mesh.
+		ANKI_ASSERT(k.pass == 1 && "Call only in SMO");
+		(void)k; // No warnings please
+		return vao;
 	}
 	}
 
 
-	MaterialRuntime& getMaterialRuntime()
+	uint getVertexIdsNum(const PassLevelKey& k)
 	{
 	{
-		return *mtlr;
+		ANKI_ASSERT(k.pass == 1 && "Call only in SMO");
+		(void)k; // No warnings please
+		return smoMesh->getVertIdsNum();
 	}
 	}
 
 
-	const Transform& getWorldTransform(const PassLevelKey&)
-	{
-		return getWorldTransform();
-	}
-
-	const Transform& getPreviousWorldTransform(const PassLevelKey&)
+	MaterialRuntime& getMaterialRuntime()
 	{
 	{
-		return getPreviousWorldTransform();
+		return *mtlr;
 	}
 	}
 	/// @}
 	/// @}
 
 
 private:
 private:
 	LightType type;
 	LightType type;
 	boost::scoped_ptr<MaterialRuntime> mtlr;
 	boost::scoped_ptr<MaterialRuntime> mtlr;
-	ModelResourcePointer smoModel; ///< Model for SMO pases
+	MeshResourcePointer smoMesh; ///< Model for SMO pases
+	Vao smoVao;
 };
 };
 
 
 
 
@@ -110,8 +116,14 @@ private:
 class PointLight: public Light
 class PointLight: public Light
 {
 {
 public:
 public:
+	PointLight(const char* name, Scene* scene, uint movableFlags,
+		Movable* movParent)
+		: Light(LT_POINT, name, scene, movableFlags, movParent, &frustum,
+			"sadf")
+	{}
 
 
 private:
 private:
+	PerspectiveFrustum frustum;
 };
 };
 
 
 
 

+ 7 - 3
anki/scene/SceneNode.h

@@ -12,22 +12,26 @@ class Scene; // Don't include
 class Movable;
 class Movable;
 class Renderable;
 class Renderable;
 class Frustumable;
 class Frustumable;
-class Spartial;
+class Spatial;
 
 
 
 
-/// @addtogroup scene
+/// @addtogroup Scene
 /// @{
 /// @{
 
 
 /// Interface class backbone of scene
 /// Interface class backbone of scene
 class SceneNode
 class SceneNode
 {
 {
 public:
 public:
+	/// @name Constructors
+	/// @{
+
 	/// The one and only constructor
 	/// The one and only constructor
 	/// @param name The unique name of the node
 	/// @param name The unique name of the node
 	/// @param scene The scene that will register it
 	/// @param scene The scene that will register it
 	explicit SceneNode(
 	explicit SceneNode(
 		const char* name,
 		const char* name,
 		Scene* scene);
 		Scene* scene);
+	/// @}
 
 
 	/// Unregister node
 	/// Unregister node
 	virtual ~SceneNode();
 	virtual ~SceneNode();
@@ -49,7 +53,7 @@ public:
 		return NULL;
 		return NULL;
 	}
 	}
 
 
-	virtual Spartial* getSpartial()
+	virtual Spatial* getSpatial()
 	{
 	{
 		return NULL;
 		return NULL;
 	}
 	}

+ 5 - 5
anki/scene/Spartial.h → anki/scene/Spatial.h

@@ -1,5 +1,5 @@
-#ifndef ANKI_SCENE_SPARTIAL_H
-#define ANKI_SCENE_SPARTIAL_H
+#ifndef ANKI_SCENE_SPATIAL_H
+#define ANKI_SCENE_SPATIAL_H
 
 
 #include "anki/collision/Collision.h"
 #include "anki/collision/Collision.h"
 
 
@@ -10,15 +10,15 @@ namespace anki {
 /// @addtogroup Scene
 /// @addtogroup Scene
 /// @{
 /// @{
 
 
-/// Spartial "interface" for scene nodes
+/// Spatial "interface" for scene nodes
 ///
 ///
 /// It indicates scene nodes that need to be placed in the scene's octree and
 /// It indicates scene nodes that need to be placed in the scene's octree and
 /// they participate in the visibility tests
 /// they participate in the visibility tests
-class Spartial
+class Spatial
 {
 {
 public:
 public:
 	/// Pass the collision shape here so we can avoid the virtuals
 	/// Pass the collision shape here so we can avoid the virtuals
-	Spartial(CollisionShape* cs_)
+	Spatial(CollisionShape* cs_)
 		: cs(cs_)
 		: cs(cs_)
 	{}
 	{}