added implementation of graphicalnode
This commit is contained in:
parent
f718c4b670
commit
e4dcab14d9
6
src/scene/graphicalcontainernode.cpp
Normal file
6
src/scene/graphicalcontainernode.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "graphicalcontainernode.h"
|
||||||
|
|
||||||
|
GraphicalContainerNode::GraphicalContainerNode()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
16
src/scene/graphicalcontainernode.h
Normal file
16
src/scene/graphicalcontainernode.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef GRAPHICALCONTAINERNODE_H
|
||||||
|
#define GRAPHICALCONTAINERNODE_H
|
||||||
|
|
||||||
|
#include "graphicalnode.h"
|
||||||
|
#include "glm/mat4x4.hpp"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class GraphicalContainerNode : public GraphicalNode
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
std::vector<GraphicalNode*> m_children;
|
||||||
|
public:
|
||||||
|
GraphicalContainerNode();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRAPHICALCONTAINERNODE_H
|
22
src/scene/graphicalnode.cpp
Normal file
22
src/scene/graphicalnode.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "graphicalnode.h"
|
||||||
|
#include "scenetree.h"
|
||||||
|
|
||||||
|
GraphicalNode::GraphicalNode()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicalNode::setSceneTree(SceneTree *tree){
|
||||||
|
SceneNode::setSceneTree(tree);
|
||||||
|
if (tree)
|
||||||
|
tree->addToIndex(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphicalNode::toggleVisibility(){
|
||||||
|
m_visible = !m_visible;
|
||||||
|
if(m_visible){
|
||||||
|
m_scene->addToIndex(this);
|
||||||
|
}else{
|
||||||
|
m_scene->removeFromIndex(this);
|
||||||
|
}
|
||||||
|
}
|
25
src/scene/graphicalnode.h
Normal file
25
src/scene/graphicalnode.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef GRAPHICALNODE_H
|
||||||
|
#define GRAPHICALNODE_H
|
||||||
|
|
||||||
|
#include "scenenode.h"
|
||||||
|
#include "glm/mat4x4.hpp"
|
||||||
|
|
||||||
|
class SceneTree;
|
||||||
|
|
||||||
|
class GraphicalNode : public SceneNode
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
glm::mat4 m_transform;
|
||||||
|
protected:
|
||||||
|
bool m_visible;
|
||||||
|
public:
|
||||||
|
GraphicalNode();
|
||||||
|
|
||||||
|
void toggleVisibility();
|
||||||
|
void setSceneTree(SceneTree* tree);
|
||||||
|
|
||||||
|
void setTransform(const glm::mat4 &transform) { m_transform = transform; }
|
||||||
|
const glm::mat4& getTransform() { return m_transform; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRAPHICALNODE_H
|
@ -2,16 +2,3 @@
|
|||||||
#include "scenetree.h"
|
#include "scenetree.h"
|
||||||
#include <light.h>
|
#include <light.h>
|
||||||
|
|
||||||
void LightNode::setSceneTree(SceneTree *tree){
|
|
||||||
SceneNode::setSceneTree(tree);
|
|
||||||
tree->addToIndex(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LightNode::toggleVisibility(){
|
|
||||||
m_visible = !m_visible;
|
|
||||||
if(m_visible){
|
|
||||||
m_scene->addToIndex(this);
|
|
||||||
}else{
|
|
||||||
m_scene->removeFromIndex(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,26 +1,21 @@
|
|||||||
#ifndef LIGHTNODE_H
|
#ifndef LIGHTNODE_H
|
||||||
#define LIGHTNODE_H
|
#define LIGHTNODE_H
|
||||||
|
|
||||||
#include "scenenode.h"
|
#include "graphicalnode.h"
|
||||||
#include "glm/mat4x4.hpp"
|
#include "glm/mat4x4.hpp"
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
|
|
||||||
class LightNode : public SceneNode
|
class LightNode : public GraphicalNode
|
||||||
{
|
{
|
||||||
Light *m_light;
|
Light *m_light;
|
||||||
bool m_visible;
|
|
||||||
public:
|
public:
|
||||||
LightNode(Light* light) : m_light(light), m_visible(true) {}
|
LightNode(Light* light) : m_light(light) {GraphicalNode::m_visible = true;}
|
||||||
|
|
||||||
virtual void update()
|
virtual void update()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setSceneTree(SceneTree *tree);
|
|
||||||
|
|
||||||
void toggleVisibility();
|
|
||||||
|
|
||||||
virtual Light* getLight() { return m_light; }
|
virtual Light* getLight() { return m_light; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,18 +5,3 @@
|
|||||||
void MeshNode::setDepth(float depth){
|
void MeshNode::setDepth(float depth){
|
||||||
m_geometry.mesh->setDepth(depth);
|
m_geometry.mesh->setDepth(depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshNode::setSceneTree(SceneTree *tree){
|
|
||||||
SceneNode::setSceneTree(tree);
|
|
||||||
if (tree)
|
|
||||||
tree->addToIndex(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MeshNode::toggleVisibility(){
|
|
||||||
m_visible = !m_visible;
|
|
||||||
if(m_visible){
|
|
||||||
m_scene->addToIndex(this);
|
|
||||||
}else{
|
|
||||||
m_scene->removeFromIndex(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef MESHNODE_H
|
#ifndef MESHNODE_H
|
||||||
#define MESHNODE_H
|
#define MESHNODE_H
|
||||||
|
|
||||||
#include "scenenode.h"
|
#include "graphicalnode.h"
|
||||||
#include "glm/mat4x4.hpp"
|
#include "glm/mat4x4.hpp"
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
|
|
||||||
@ -9,16 +9,16 @@
|
|||||||
* @brief The MeshNode class holds a mesh
|
* @brief The MeshNode class holds a mesh
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MeshNode : public SceneNode
|
class MeshNode : public GraphicalNode
|
||||||
|
|
||||||
{
|
{
|
||||||
GeometryNode m_geometry;
|
GeometryNode m_geometry;
|
||||||
bool m_visible;
|
|
||||||
public:
|
public:
|
||||||
// temp
|
// temp
|
||||||
glm::mat4 m_movement;
|
glm::mat4 m_movement;
|
||||||
glm::mat4 m_acceleration;
|
glm::mat4 m_acceleration;
|
||||||
|
|
||||||
MeshNode(Mesh* mesh) : m_geometry(mesh, glm::mat4()), m_visible(true) {}
|
MeshNode(Mesh* mesh) : m_geometry(mesh, glm::mat4()) {GraphicalNode::m_visible = true;}
|
||||||
|
|
||||||
virtual void update()
|
virtual void update()
|
||||||
{
|
{
|
||||||
@ -26,14 +26,10 @@ public:
|
|||||||
m_geometry.modelMatrix = m_movement * m_geometry.modelMatrix;
|
m_geometry.modelMatrix = m_movement * m_geometry.modelMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setSceneTree(SceneTree *tree);
|
|
||||||
|
|
||||||
void setTransform(const glm::mat4 &transform) { m_geometry.modelMatrix = transform; }
|
void setTransform(const glm::mat4 &transform) { m_geometry.modelMatrix = transform; }
|
||||||
const glm::mat4& getTransform() { return m_geometry.modelMatrix; }
|
const glm::mat4& getTransform() { return m_geometry.modelMatrix; }
|
||||||
void setDepth(float depth);
|
void setDepth(float depth);
|
||||||
|
|
||||||
void toggleVisibility();
|
|
||||||
|
|
||||||
virtual GeometryNode* getGeometryNode() { return &m_geometry; }
|
virtual GeometryNode* getGeometryNode() { return &m_geometry; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ SceneTree::SceneTree() :
|
|||||||
DeferredPipeline *pipeline = new DeferredPipeline();
|
DeferredPipeline *pipeline = new DeferredPipeline();
|
||||||
m_pipeline = pipeline;
|
m_pipeline = pipeline;
|
||||||
pipeline->setRenderTarget(FrameBuffer::screen);
|
pipeline->setRenderTarget(FrameBuffer::screen);
|
||||||
|
m_root.setSceneTree(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneTree::~SceneTree()
|
SceneTree::~SceneTree()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user