added addChild/removeChild to GraphicalContainerNode
This commit is contained in:
parent
4026283f1c
commit
aed140ca5c
@ -26,7 +26,7 @@ void ContainerNode::removeChild(SceneNode* node)
|
|||||||
if(*it == node)
|
if(*it == node)
|
||||||
{
|
{
|
||||||
m_children.erase(it);
|
m_children.erase(it);
|
||||||
break;
|
// break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void removeChild(SceneNode* node);
|
void removeChild(SceneNode* node);
|
||||||
/**
|
/**
|
||||||
* @brief addedToSceneTree is called when this node is added to a SceneTree
|
* @brief setSceneTree is called when this node is added to a SceneTree
|
||||||
*
|
*
|
||||||
* @param tree
|
* @param tree
|
||||||
*/
|
*/
|
||||||
|
@ -4,3 +4,28 @@ GraphicalContainerNode::GraphicalContainerNode()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphicalContainerNode::addChild(GraphicalNode *node)
|
||||||
|
{
|
||||||
|
if(node != nullptr)
|
||||||
|
{
|
||||||
|
node->setSceneTree(m_scene);
|
||||||
|
m_children.push_back(node);
|
||||||
|
node->m_parent = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicalContainerNode::removeChild(GraphicalNode *node)
|
||||||
|
{
|
||||||
|
if(node != nullptr)
|
||||||
|
{
|
||||||
|
for(auto it = m_children.begin(); it != m_children.end(); ++it)
|
||||||
|
{
|
||||||
|
if(*it == node)
|
||||||
|
{
|
||||||
|
m_children.erase(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -11,6 +11,8 @@ protected:
|
|||||||
std::vector<GraphicalNode*> m_children;
|
std::vector<GraphicalNode*> m_children;
|
||||||
public:
|
public:
|
||||||
GraphicalContainerNode();
|
GraphicalContainerNode();
|
||||||
|
void addChild(GraphicalNode* node);
|
||||||
|
void removeChild(GraphicalNode* node);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHICALCONTAINERNODE_H
|
#endif // GRAPHICALCONTAINERNODE_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "graphicalnode.h"
|
#include "graphicalnode.h"
|
||||||
#include "scenetree.h"
|
#include "scenetree.h"
|
||||||
|
|
||||||
GraphicalNode::GraphicalNode()
|
GraphicalNode::GraphicalNode() : m_visible(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ class LightNode : public GraphicalNode
|
|||||||
{
|
{
|
||||||
Light *m_light;
|
Light *m_light;
|
||||||
public:
|
public:
|
||||||
LightNode(Light* light) : m_light(light) {GraphicalNode::m_visible = true;}
|
LightNode(Light* light) : m_light(light) {}
|
||||||
|
|
||||||
virtual void update()
|
virtual void update()
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
glm::mat4 m_movement;
|
glm::mat4 m_movement;
|
||||||
glm::mat4 m_acceleration;
|
glm::mat4 m_acceleration;
|
||||||
|
|
||||||
MeshNode(Mesh* mesh) : m_geometry(mesh, glm::mat4()) {GraphicalNode::m_visible = true;}
|
MeshNode(Mesh* mesh) : m_geometry(mesh, glm::mat4()) {}
|
||||||
|
|
||||||
virtual void update()
|
virtual void update()
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "glm/vec2.hpp"
|
#include "glm/vec2.hpp"
|
||||||
#include "sparrowshell/shellbuffer.h"
|
#include "sparrowshell/shellbuffer.h"
|
||||||
#include "sparrowshell/shellscrollbar.h"
|
#include "sparrowshell/shellscrollbar.h"
|
||||||
|
#include "scene/graphicalcontainernode.h"
|
||||||
|
|
||||||
class Input;
|
class Input;
|
||||||
class MeshNode;
|
class MeshNode;
|
||||||
@ -18,7 +19,7 @@ namespace sf {
|
|||||||
class Window;
|
class Window;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SparrowShell : public ContainerNode
|
class SparrowShell : public GraphicalContainerNode
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
sf::Window* m_window;
|
sf::Window* m_window;
|
||||||
@ -52,8 +53,8 @@ public:
|
|||||||
void out(std::string);
|
void out(std::string);
|
||||||
void setSceneTree(SceneTree* tree)
|
void setSceneTree(SceneTree* tree)
|
||||||
{
|
{
|
||||||
ContainerNode::setSceneTree(tree);
|
GraphicalContainerNode::setSceneTree(tree);
|
||||||
// m_buffer->setSceneTree(tree);
|
m_buffer->setSceneTree(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::ivec2 getPosition(){return m_position;}
|
glm::ivec2 getPosition(){return m_position;}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user