SparrowRenderer/scene.h
2015-11-18 18:31:06 +01:00

77 lines
1.4 KiB
C++

#ifndef SCENE_H
#define SCENE_H
#include <glm/mat4x4.hpp>
#include "camera.h"
// Scene Node flags :
#define CAMERA_NODE 1
#define DIRECTIONNAL_LIGHT_NODE 2
#define POINT_LIGHT_NODE 4
#define PHONG_NODE 8
#define PHONG_DIFFUSE_TEXTURED_NODE 16
#define PHONG_SPECULAR_TEXTURED_NODE 32
#define PHONG_NORMAL_TEXTURED_NODE 64
#define PARTICLES_NODE 128
// up to 24 more nodes can be added here...
// Scene interface :
class Scene
{
// the scene is supposed to contain Scene Nodes
public:
// this should draw all nodes matching the specified flags.
virtual draw(unsigned int flags) = 0;
};
// Some basic implementations :
class Mesh;
class LeafNode : public SceneNode
{
glm::mat4 transform;
std::vector<LeafNode*> children;
public:
virtual void drawChildren(glm::mat4 m, unsigned int flags)
{
for(LeafNode* node : children)
node->drawChildren(m*transform, flags);
}
};
class MeshNode : public LeafNode
{
Mesh* mesh;
public:
virtual void drawChildren(glm::mat4 m, unsigned int flags)
{
// TODO : draw VAOs matching the flags
for(LeafNode* node : children)
node->drawChildren(m*transform, flags);
}
};
class TreeScene
{
LeafNode* root;
public:
virtual draw(unsigned int flags)
{
root->drawChildren(glm::mat4(), flags);
}
};
class CameraNode : public LeafNode
{
public:
virtual glm::mat4 getProjectionMatrix() = 0;
virtual glm::mat4 getViewMatrix() = 0;
virtual void resize(int width, int height) = 0;
};
#endif // SCENE_H