temp commit shell

This commit is contained in:
Lendemor 2016-07-11 20:46:05 +02:00
parent d6eeddf812
commit 8de35df306
6 changed files with 38 additions and 11 deletions

View File

@ -9,6 +9,7 @@
#include <btBulletDynamicsCommon.h>
#include "resourcemanager.h"
#include "scenetree.h"
#include "sparrowshell.h"
Engine::Engine() :
m_window(NULL),
@ -46,6 +47,7 @@ void Engine::createWindow(std::string title,
m_window->setFramerateLimit(60);
m_input = new Input(m_window);
m_renderer->initGL(w, h);
m_sparrowshell = new SparrowShell(m_window,m_input);
}
void Engine::initPhysics()
@ -104,4 +106,10 @@ void Engine::setScene(SceneTree *scene)
m_scene = scene;
m_renderer->setScene(m_scene);
m_renderer->resizeGL(m_window->getSize().x, m_window->getSize().y);
scene->addObject(scene->getRootObject(), m_sparrowshell);
}
void Engine::outputShell(std::string str)
{
m_sparrowshell->out(str);
}

View File

@ -6,6 +6,8 @@
class Input;
class SparrowRenderer;
class SceneTree;
class SparrowShell;
namespace sf
{
class Clock;
@ -34,6 +36,8 @@ public:
SparrowRenderer* getRenderer() {return m_renderer;}
btDiscreteDynamicsWorld* getPhysics() {return m_world;}
void outputShell(std::string str);
unsigned int getTime();
unsigned int getDeltaTime();
@ -47,6 +51,7 @@ private:
Input* m_input;
SceneTree* m_scene;
SparrowShell* m_sparrowshell;
btDiscreteDynamicsWorld* m_world;
SparrowRenderer* m_renderer;

View File

@ -55,8 +55,8 @@ int main(){
scene.addObject(scene.getRootObject(), node);
*/
SparrowShell *shell = new SparrowShell(engine.getWindow(),engine.getInput());
scene.addObject(scene.getRootObject(),shell);
// SparrowShell *shell = new SparrowShell(engine.getWindow(),engine.getInput());
// scene.addObject(scene.getRootObject(),shell);
// the pipeline needs to updates his shaders because the scene changed
// this should be handled somewhere else in the future

View File

@ -44,6 +44,8 @@ void SceneTree::addObject(ContainerNode *parent, SceneNode *node)
parent->addChild(node);
addToIndex(node);
node->addedToSceneTree(this);
GuiPipeline* pipeline = (GuiPipeline*)this->getPipeline();
pipeline->refreshScene(this);
}
void SceneTree::addToIndex(SceneNode* node){

View File

@ -8,9 +8,9 @@
const unsigned int SparrowShell::BUFFER_MAX_LENGTH = 50;
const unsigned int SparrowShell::BUFFER_DISPLAYED_NUMBER = 10;
const unsigned int SparrowShell::SCROLLBAR_PIXEL_WIDTH = 2;
const unsigned int SparrowShell::SCROLLBAR_PIXEL_WIDTH = 10;
SparrowShell::SparrowShell(sf::Window* window, Input* input): m_window(window),m_input(input),m_position(glm::ivec2(0,0)),m_scrollbar(this)
SparrowShell::SparrowShell(sf::Window* window, Input* input): m_window(window),m_input(input),m_position(glm::ivec2(0,0))
{
sf::Vector2u size = m_window->getSize();
m_dimension = glm::ivec2(size.x,size.y/2);
@ -19,8 +19,11 @@ SparrowShell::SparrowShell(sf::Window* window, Input* input): m_window(window),m
PhongMaterial *mat = new PhongMaterial();
mat->diffuse = glm::vec3(0,0.5,0.5);
mesh->setMaterial(mat);
mesh->setDepth(-0.5);
mesh->initGL();
this->addChild(new MeshNode(mesh));
m_background = new MeshNode(mesh);
this->addChild(m_background);
m_scrollbar = SparrowShell::ScrollBar(this);
}
void SparrowShell::out(std::string s)
@ -44,15 +47,22 @@ void SparrowShell::update()
m_scrollbar.update();
}
//GeometryNode* SparrowShell::getGeometryNode()
//{
// return geometry;
//}
SparrowShell::ScrollBar::ScrollBar(){
}
SparrowShell::ScrollBar::ScrollBar(SparrowShell* shell):m_shell(shell){
m_position = glm::ivec2(m_shell->m_dimension.x - SCROLLBAR_PIXEL_WIDTH,0);
m_dimension = glm::ivec2(SCROLLBAR_PIXEL_WIDTH,m_shell->m_dimension.y);
m_position = glm::ivec2(m_shell->m_dimension.x - SparrowShell::SCROLLBAR_PIXEL_WIDTH,0);
m_dimension = glm::ivec2(SparrowShell::SCROLLBAR_PIXEL_WIDTH,m_shell->m_dimension.y);
Mesh* mesh = new Mesh();
mesh->addRectangle2D(m_position,m_dimension);
PhongMaterial *mat = new PhongMaterial();
mat->diffuse = glm::vec3(1,0,0);
mesh->setDepth(-0.4);
mesh->setMaterial(mat);
mesh->initGL();
m_mesh = new MeshNode(mesh);
m_shell->addChild(m_mesh);
}
void SparrowShell::ScrollBar::update(){

View File

@ -24,6 +24,7 @@ private:
SparrowShell* m_shell;
glm::ivec2 m_position;
glm::ivec2 m_dimension;
MeshNode *m_mesh;
//TODO : Add rectangle mesh
public:
@ -45,6 +46,7 @@ private:
glm::ivec2 m_dimension;
//textMesh
MeshNode* m_background;
ScrollBar m_scrollbar;
public: