Panagiotis Christopoulos Charitos 15 年之前
父節點
當前提交
149c6b170f
共有 3 個文件被更改,包括 45 次插入5 次删除
  1. 35 0
      src/Scene/SceneNode.cpp
  2. 9 3
      src/Scene/SceneNode.h
  3. 1 2
      src/Util/Properties.h

+ 35 - 0
src/Scene/SceneNode.cpp

@@ -1,8 +1,16 @@
 #include <algorithm>
+#include <boost/lexical_cast.hpp>
 #include "SceneNode.h"
 #include "Scene.h"
 
 
+//======================================================================================================================
+// Statics                                                                                                             =
+//======================================================================================================================
+
+uint SceneNode::uid = 0;
+
+
 //======================================================================================================================
 // Constructor                                                                                                         =
 //======================================================================================================================
@@ -14,6 +22,33 @@ SceneNode::SceneNode(SceneNodeType type_, bool compoundFlag_, SceneNode* parent)
 	getWorldTransform().setIdentity();
 	getLocalTransform().setIdentity();
 	SceneSingleton::getInstance().registerNode(this);
+
+	switch(type)
+	{
+		case SNT_GHOST:
+			name = "GhostNode:" + boost::lexical_cast<std::string>(uid);
+			break;
+		case SNT_LIGHT:
+			name = "Light:" + boost::lexical_cast<std::string>(uid);
+			break;
+		case SNT_CAMERA:
+			name = "Camera:" + boost::lexical_cast<std::string>(uid);
+			break;
+		case SNT_PARTICLE_EMITTER:
+			name = "ParticleEmitter:" + boost::lexical_cast<std::string>(uid);
+			break;
+		case SNT_MODEL:
+			name = "ModelNode:" + boost::lexical_cast<std::string>(uid);
+			break;
+		case SNT_SKIN:
+			name = "SkinNode:" + boost::lexical_cast<std::string>(uid);
+			break;
+		case SNT_RENDERABLE:
+			name = "RenderableNode:" + boost::lexical_cast<std::string>(uid);
+			break;
+	}
+
+	++uid;
 }
 
 

+ 9 - 3
src/Scene/SceneNode.h

@@ -2,9 +2,11 @@
 #define SCENE_NODE_H
 
 #include <memory>
+#include <string>
 #include "Math.h"
 #include "Object.h"
 #include "Obb.h"
+#include "Properties.h"
 
 
 class Material;
@@ -42,15 +44,16 @@ class SceneNode: public Object
 		Transform& getWorldTransform() {return worldTransform;}
 		void setWorldTransform(const Transform& t) {worldTransform = t;}
 
-		SceneNodeType getSceneNodeType() const {return type;}
+		GETTER_R_BY_VAL(SceneNodeType, type, getSceneNodeType)
 
 		const Object* getParent() const {return getObjParent();}
 		Object* getParent() {return getObjParent();}
 		const Object::Container& getChildren() const {return getObjChildren();}
 		Object::Container& getChildren() {return getObjChildren();}
 
-		bool isVisible() const {return visible;}
-		void setVisible(bool v) {visible = v;}
+		GETTER_SETTER_BY_VAL(bool, visible, isVisible, setVisible)
+
+		GETTER_R(std::string, name, getSceneNodeName)
 		/// @}
 
 		/// @name Updates
@@ -84,6 +87,9 @@ class SceneNode: public Object
 
 		SceneNodeType type;
 		bool compoundFlag; ///< This means that the children will inherit the world transform of this node
+		std::string name;
+
+		static uint uid; ///< Unique identifier
 
 		/// @name Runtime info
 		/// @{

+ 1 - 2
src/Util/Properties.h

@@ -56,8 +56,7 @@
 	private: \
 		Type__ varName__; \
 	public: \
-		GETTER_RW(Type__, varName__, getFunc__) \
-		void setFunc__(const Type__& x__) {varName__ = x__;}
+		SETTER_GETTER(Type__, varName__, getFunc__, setFunc__)
 
 
 /// Read only private property