added lots of things to scene
This commit is contained in:
parent
ca6f1bf916
commit
a65269f07f
@ -1,50 +0,0 @@
|
||||
#include "cameranode.h"
|
||||
#include <glm/ext.hpp>
|
||||
|
||||
CameraNode::CameraNode(glm::vec3 position, float yFov, float near, float far) :
|
||||
m_hasMoved(true),
|
||||
m_hasResized(false),
|
||||
m_eye(position),
|
||||
m_target(0, 0, 1),
|
||||
m_yFov(yFov),
|
||||
m_near(near),
|
||||
m_far(far)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CameraNode::setPosition(glm::vec3 position)
|
||||
{
|
||||
m_hasMoved = true;
|
||||
m_eye = position;
|
||||
}
|
||||
|
||||
void CameraNode::setTarget(glm::vec3 target)
|
||||
{
|
||||
m_hasMoved = true;
|
||||
m_target = target;
|
||||
}
|
||||
|
||||
void CameraNode::update()
|
||||
{
|
||||
if(m_hasMoved)
|
||||
m_view = glm::lookAt(m_eye, m_target, glm::vec3(0, 1, 0));
|
||||
if(m_hasResized)
|
||||
m_projection = glm::perspective(m_yFov, m_ratio, m_near, m_far);
|
||||
}
|
||||
|
||||
glm::mat4 CameraNode::getProjectionMatrix()
|
||||
{
|
||||
return m_projection;
|
||||
}
|
||||
|
||||
glm::mat4 CameraNode::getViewMatrix()
|
||||
{
|
||||
return m_view;
|
||||
}
|
||||
|
||||
void CameraNode::resize(int width, int height)
|
||||
{
|
||||
m_hasResized = false;
|
||||
m_ratio = ((float)width)/((float)height);
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
#ifndef CAMERANODE_H
|
||||
#define CAMERANODE_H
|
||||
|
||||
#include "scenetree.h"
|
||||
#include "camera.h"
|
||||
#include "glm/vec3.hpp"
|
||||
|
||||
class CameraNode : public SceneNode, public Camera
|
||||
{
|
||||
bool m_hasMoved;
|
||||
bool m_hasResized;
|
||||
|
||||
glm::vec3 m_eye;
|
||||
glm::vec3 m_target;
|
||||
|
||||
float m_yFov;
|
||||
float m_ratio;
|
||||
float m_near;
|
||||
float m_far;
|
||||
|
||||
glm::mat4 m_projection;
|
||||
glm::mat4 m_view;
|
||||
|
||||
public:
|
||||
CameraNode(glm::vec3 position, float yFov = 70.f, float near = 0.1f, float far = 100.f);
|
||||
CameraNode(float yFov = 70.f, float near = 0.1f, float far = 100.f) :
|
||||
CameraNode(glm::vec3(0), yFov, near, far) {}
|
||||
|
||||
void setPosition(glm::vec3 position);
|
||||
void setTarget(glm::vec3 target);
|
||||
|
||||
virtual void update();
|
||||
|
||||
virtual glm::mat4 getProjectionMatrix();
|
||||
virtual glm::mat4 getViewMatrix();
|
||||
virtual void resize(int width, int height);
|
||||
};
|
||||
|
||||
#endif // CAMERANODE_H
|
@ -9,7 +9,6 @@
|
||||
#include <btBulletDynamicsCommon.h>
|
||||
#include "resourcemanager.h"
|
||||
#include "scenetree.h"
|
||||
#include "cameranode.h"
|
||||
|
||||
Engine::Engine() :
|
||||
m_input(NULL),
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "engine.h"
|
||||
#include <input.h>
|
||||
#include "scene.h"
|
||||
#include "cameranode.h"
|
||||
#include "resourcemanager.h"
|
||||
#include "sparrowrenderer.h"
|
||||
#include "scenetree.h"
|
||||
|
||||
#include "tools/graph.h"
|
||||
#include "tools/pathfinder.h"
|
||||
|
@ -27,8 +27,7 @@ SceneIterator<GeometryNode*>* SceneTree::getGeometry()
|
||||
|
||||
void SceneTree::update()
|
||||
{
|
||||
m_objects.update();
|
||||
m_map.update();
|
||||
m_root.update();
|
||||
}
|
||||
|
||||
// Container Node
|
||||
|
@ -5,7 +5,12 @@
|
||||
#include <string>
|
||||
#include "scene.h"
|
||||
#include "light.h"
|
||||
#include "resourcemanager.h"
|
||||
|
||||
/**
|
||||
* @brief The SceneNode class represents a class of the game
|
||||
* that will be updated or used for rendering every frame
|
||||
*/
|
||||
class SceneNode
|
||||
{
|
||||
public:
|
||||
@ -13,7 +18,9 @@ public:
|
||||
virtual void update() = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief The ContainerNode class represents a node which main use is to contain a collection of nodes
|
||||
*/
|
||||
class ContainerNode : public SceneNode
|
||||
{
|
||||
public:
|
||||
@ -24,6 +31,14 @@ protected:
|
||||
std::vector<SceneNode*> m_children;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The CameraNode class is a scene node that can be used by the renderer
|
||||
*/
|
||||
class CameraNode : public Camera, SceneNode
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class SceneTree : public Scene
|
||||
{
|
||||
public:
|
||||
@ -38,69 +53,17 @@ public:
|
||||
Texture* getSkybox() {return m_skybox;}
|
||||
void setSkybox(Texture* skybox) {m_skybox = skybox;}
|
||||
|
||||
void setMainCamera(const std::string &name) {m_camera = RESOURCE_GET(CameraNode, name);}
|
||||
void addRootObject(const std::string &name) {m_root.addChild(name);}
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
ContainerNode m_objects;
|
||||
ContainerNode m_map;
|
||||
ContainerNode m_root;
|
||||
Texture* m_skybox;
|
||||
};
|
||||
|
||||
//general Node
|
||||
// Additionnal Nodes :
|
||||
|
||||
class ObjectNode : public SceneNode
|
||||
{
|
||||
//add bullet rigidbody
|
||||
public:
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
class FragmentNode: public ObjectNode
|
||||
{
|
||||
// TODO: later
|
||||
};
|
||||
|
||||
class ItemNode: public ObjectNode
|
||||
{
|
||||
// TODO: later
|
||||
};
|
||||
|
||||
// Node
|
||||
class GUINode : public SceneNode//, public GUIEntity
|
||||
{
|
||||
public:
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
class PlayerNode: public SceneNode//, public FPSCamera
|
||||
{
|
||||
public:
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
class EnvironmentNode : public SceneNode
|
||||
{
|
||||
public:
|
||||
virtual void update();
|
||||
// parametre skybox
|
||||
// directionnal light
|
||||
// parametre fog
|
||||
};
|
||||
|
||||
class LightNode : public SceneNode, public Light
|
||||
{
|
||||
public:
|
||||
virtual void update();
|
||||
//position
|
||||
//puissance
|
||||
//lighting angle
|
||||
//couleur
|
||||
};
|
||||
|
||||
class ChunkNode: public SceneNode
|
||||
{
|
||||
public:
|
||||
virtual void update();
|
||||
// map
|
||||
};
|
||||
|
||||
#endif // SCENETREE_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user