updated version and added version command in shell

This commit is contained in:
Lendemor 2017-01-30 02:47:04 +01:00
parent 07e65e5713
commit 66f0cf9a7c
30 changed files with 104 additions and 105 deletions

View File

@ -1,8 +1,8 @@
project(SparrowEngine)
cmake_minimum_required(VERSION 2.8)
SET(VERSION_MAJOR 0)
SET(VERSION_MINOR 1)
SET(VERSION_MAJOR 1)
SET(VERSION_MINOR 0)
set(EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/src)

View File

@ -1,7 +1,7 @@
#ifndef DEFAULTKEYSMAP_H
#define DEFAULTKEYSMAP_H
#include "keybindings.h"
#include "SparrowInput/keybindings.h"
class DefaultKeysMap : public IKeysMap
{

View File

@ -2,8 +2,8 @@
#include <SFML/System/Clock.hpp>
#include <SFML/Window.hpp>
#include <input.h>
#include <sparrowrenderer.h>
#include <SparrowInput/input.h>
#include <SparrowRenderer/sparrowrenderer.h>
#include <btBulletCollisionCommon.h>
#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
@ -192,13 +192,6 @@ void Engine::setShowMouseAction(int action)
m_showMouseAction = action;
}
void Engine::outputShell(std::string str) const
{
std::wstring ws;
ws.assign(str.begin(),str.end());
m_sparrowshell->out(ws);
}
void Engine::checkSpecialInputs()
{
for(int action : m_input->getActions())

View File

@ -50,8 +50,6 @@ public:
SparrowShell* getShell() const {return m_sparrowshell;}
SceneTree* getScene() const {return m_scene;}
void outputShell(std::string str) const;
unsigned int getTime() const;
unsigned int getDeltaTime() const;

View File

@ -2,7 +2,7 @@
#define CAMERANODE_H
#include "scenenode.h"
#include "camera.h"
#include "SparrowRenderer/camera.h"
/**
* @brief The CameraNode class is a scene node that can be used by the renderer

View File

@ -3,8 +3,8 @@
#include "glm/vec2.hpp"
#include "glm/vec3.hpp"
#include "mesh.h"
#include "phongmaterial.h"
#include "SparrowRenderer/mesh.h"
#include "SparrowRenderer/phongmaterial.h"
BackGroundNode::BackGroundNode(glm::vec2 position,glm::vec2 dimension, glm::vec3 color, float opacity,float depth,bool visible):
MeshNode(nullptr,visible)

View File

@ -5,16 +5,19 @@
#include <iostream>
#include "scene/scenetree.h"
#include "input.h"
#include "SparrowInput/input.h"
#include "SparrowRenderer/sparrowrenderer.h"
#include "SparrowRenderer/mesh.h"
#include "SparrowRenderer/phongmaterial.h"
#include "sparrowshell/sparrowshell.h"
#include "mesh.h"
#include "phongmaterial.h"
#include "tools/font.h"
#include "resourcemanager.h"
#include "sparrowrenderer.h"
ButtonNode::ButtonNode(glm::vec2 position,ButtonShape* shape):
m_position(position),m_shape(shape),i(0)
m_position(position),m_shape(shape)
{
addChild(m_shape->getBackGround());
}
@ -26,9 +29,10 @@ MeshNode* ButtonNode::getBackGround()
void ButtonNode::update()
{
GraphicalContainerNode::update();
Input* input = getEngine().getInput();
sf::Vector2i v = input->getPosition();
glm::vec2 pos = glm::vec2(v.x,v.y);
glm::vec2 pos = input->getPosition();;
if(m_label_updated){
if(m_label_node)
@ -42,14 +46,6 @@ void ButtonNode::update()
m_label_updated = false;
}
if(i == 120){
glm::vec4 posa = m_transform[3];
glm::vec4 posb = getBackGround()->getParentTransform()[3];
glm::vec4 posc = m_label_node->getParentTransform()[3];
std::cout << posa.x << " " << posa.y <<"\n"<< posb.x << " " << posb.y << "\n" << posc.x << " " << posc.y << "\n"<< std::endl;
i=0;
}
i++;
for (auto action : input->getActions())
{
if (action == m_action){

View File

@ -21,8 +21,6 @@ class ButtonNode : public GraphicalContainerNode
TextNode* m_label_node;
glm::vec3 m_label_color;
int i;
public:
ButtonNode(glm::vec2 m_position, ButtonShape* shape);
MeshNode* getBackGround();

View File

@ -1,6 +1,6 @@
#include "lightnode.h"
#include "scenetree.h"
#include <light.h>
#include <SparrowRenderer/light.h>
#include <glm/mat3x3.hpp>
void LightNode::update()

View File

@ -3,7 +3,7 @@
#include "graphicalnode.h"
#include "glm/mat4x4.hpp"
#include "scene.h"
#include "SparrowRenderer/scene.h"
class LightNode : public GraphicalNode
{

View File

@ -1,5 +1,5 @@
#include "meshnode.h"
#include "mesh.h"
#include "SparrowRenderer/mesh.h"
#include "scenetree.h"
#include <glm/ext.hpp>

View File

@ -3,7 +3,7 @@
#include "graphicalnode.h"
#include "glm/mat4x4.hpp"
#include "scene.h"
#include "SparrowRenderer/scene.h"
class btRigidBody;
class btIndexedMesh;

View File

@ -1,6 +1,6 @@
#include "physicsdebugnode.h"
#include "mesh.h"
#include "phongmaterial.h"
#include "SparrowRenderer/mesh.h"
#include "SparrowRenderer/phongmaterial.h"
PhysicsDebugNode::PhysicsDebugNode() :
MeshNode(new Mesh())

View File

@ -135,7 +135,7 @@ void PlayerCharacterNode::update()
}
// update camera rotation
sf::Vector2i diff = input->getDeltaPosition();
glm::vec2 diff = input->getDeltaPosition();
m_fpsCamera.rotate(diff.x, diff.y);
// update camera position

View File

@ -2,7 +2,7 @@
#define PLAYERCHARACTERNODE_H
#include "cameranode.h"
#include "input.h"
#include "SparrowInput/input.h"
#include <LinearMath/btVector3.h>
class btRigidBody;

View File

@ -1,11 +1,11 @@
#include "scene/scenetree.h"
#include "resourcemanager.h"
#include <pipeline.h>
#include <deferredpipeline.h>
#include <SparrowRenderer/pipeline.h>
#include <SparrowRenderer/deferredpipeline.h>
#include <algorithm>
#include <SFML/Window.hpp>
// Scene
#include <mesh.h>
#include <SparrowRenderer/mesh.h>
#include <iostream>
#include "scene/scenenode.h"
#include "scene/cameranode.h"

View File

@ -3,7 +3,7 @@
#include <vector>
#include <string>
#include "scene.h"
#include "SparrowRenderer/scene.h"
#include "containernode.h"
#include "engine.h"

View File

@ -1,3 +0,0 @@
#include "textnode.h"

View File

@ -8,7 +8,7 @@ TrackBallCameraNode::TrackBallCameraNode(Input *input) :
void TrackBallCameraNode::update()
{
sf::Vector2i diff = m_input->getDeltaPosition();
glm::vec2 diff = m_input->getDeltaPosition();
for(int action : m_input->getActions())
{
if(action == m_action_move)

View File

@ -2,8 +2,8 @@
#define TRACKBALLCAMERANODE_H
#include "cameranode.h"
#include "trackballcamera.h"
#include "input.h"
#include "SparrowRenderer/trackballcamera.h"
#include "SparrowInput/input.h"
/**
* @brief The CameraNode class is a scene node that can be used by the renderer

View File

@ -2,11 +2,18 @@
#include "engine.h"
#include "sparrowshell/sparrowshell.h"
#include <iostream>
#include <sstream>
#include "Version.h"
#include "SparrowInput/Version.h"
#include "SparrowRenderer/Version.h"
#include "SparrowSerializer/Version.h"
#define LUASETFUN(var) m_script.set_function(#var,&ScriptNode::var,this)
ScriptNode::ScriptNode()
{
LUASETFUN(print);
LUASETFUN(version);
}
void ScriptNode::update(){
@ -16,21 +23,28 @@ void ScriptNode::update(){
}
void ScriptNode::print(std::string to_print){
std::wstring ws;
to_print.append("\n");
ws.assign(to_print.begin(),to_print.end());
this->getEngine().getShell()->out(ws);
this->getEngine().getShell()->out(to_print.append("\n"));
}
void ScriptNode::execute(std::wstring to_execute){
void ScriptNode::version(){
std::ostringstream oss;
oss << " SparrowEngine version: "<< SparrowEngine_VERSION_MAJOR << "." << SparrowEngine_VERSION_MINOR;
this->getEngine().getShell()->out(oss.str());
oss.str("");
oss << " SparrowInput version: "<< SparrowInput_VERSION_MAJOR << "." << SparrowInput_VERSION_MINOR;
this->getEngine().getShell()->out(oss.str());
oss.str("");
oss << " SparrowRenderer version: "<< SparrowRenderer_VERSION_MAJOR << "." << SparrowRenderer_VERSION_MINOR;
this->getEngine().getShell()->out(oss.str());
oss.str("");
oss << " SparrowSerializer version: "<< SparrowSerializer_VERSION_MAJOR << "." << SparrowSerializer_VERSION_MINOR;
this->getEngine().getShell()->out(oss.str());
}
void ScriptNode::execute(std::string to_execute){
try{
std::string str;
str.assign(to_execute.begin(),to_execute.end());
m_script.script(str);
m_script.script(to_execute);
}catch(sol::error error_lua){
std::string s = error_lua.what();
std::wstring ws;
ws.assign(s.begin(),s.end());
this->getEngine().getShell()->out(ws,glm::vec3(1,0,0));
this->getEngine().getShell()->out(error_lua.what(),glm::vec3(1,0,0));
}
}

View File

@ -13,7 +13,8 @@ public:
ScriptNode();
void update();
void print(std::string);
void execute(std::wstring);
void version();
void execute(std::string);
};
#endif // SCRIPTNODE_H

View File

@ -1,7 +1,7 @@
#include "shellscrollbar.h"
#include "sparrowshell.h"
#include "mesh.h"
#include "phongmaterial.h"
#include "SparrowRenderer/mesh.h"
#include "SparrowRenderer/phongmaterial.h"
#include "scene/meshnode.h"
#include "tools/utils.h"
#include <iostream>
@ -41,7 +41,7 @@ void ShellScrollBar::update(){
if (m_shell->indexMoved())
{
m_position.y = cran * indexCursor;
std::cout << m_position.x << " " << m_position.y << std::endl;
// std::cout << m_position.x << " " << m_position.y << std::endl;
moveTo2D(m_position);
}
}

View File

@ -1,16 +1,14 @@
#include "sparrowshell.h"
#include "input.h"
#include "SparrowInput/input.h"
#include "scene/scenetree.h"
#include "scene/meshnode.h"
#include "scene/textnode.h"
#include "scene/gui/backgroundnode.h"
#include "scriptnode.h"
#include "mesh.h"
#include "phongmaterial.h"
//#include "tools/utils.h"
#include "SparrowRenderer/mesh.h"
#include "SparrowRenderer/phongmaterial.h"
#include "tools/font.h"
#include "resourcemanager.h"
@ -53,15 +51,17 @@ SparrowShell::SparrowShell(sf::Window* window):
}
// write wstring str in shell
void SparrowShell::out(std::wstring str)
void SparrowShell::out(std::string str)
{
out(str,m_text_color);
}
void SparrowShell::out(std::wstring str,glm::vec3 color)
void SparrowShell::out(std::string str,glm::vec3 color)
{
std::wstring ws;
ws.assign(str.begin(),str.end());
Font *shellfont = RESOURCE_GET(Font,"shellfont");
TextNode* tnode = shellfont->getTextNode(str,color,m_buffer->getFontSize(),false);
TextNode* tnode = shellfont->getTextNode(ws,color,m_buffer->getFontSize(),false);
tnode->setDepth(SHELL_DEPTH+1);
m_buffer->push(tnode);
scrollDown();
@ -125,6 +125,7 @@ void SparrowShell::update()
else if(scroll > 0)
scrollUp();
}
getEngine().getScene()->updateShaders();
GraphicalContainerNode::update();
}
@ -156,7 +157,7 @@ void SparrowShell::updateTextInput()
input_string_updated = true;
break;
default:
m_input_string.insert(m_input_cursor_pos++,std::wstring(1,c));
m_input_string.insert(m_input_cursor_pos++,std::string(1,c));
input_string_updated = true;
}
}
@ -165,7 +166,9 @@ void SparrowShell::updateTextInput()
{
if(m_input_mesh)
this->removeChild(m_input_mesh);
m_input_mesh = shellfont->getTextNode(m_input_string,m_text_color,m_buffer->getFontSize(),false);
std::wstring ws;
ws.assign(m_input_string.begin(),m_input_string.end());
m_input_mesh = shellfont->getTextNode(ws,m_text_color,m_buffer->getFontSize(),false);
m_input_mesh->moveTo2D(glm::vec2(0,m_buffer->getFontSize()*BUFFER_DISPLAYED_LINES));
this->addChild(m_input_mesh);
m_input_mesh->setVisible(true);

View File

@ -8,7 +8,7 @@
#include "sparrowshell/shellbuffer.h"
#include "sparrowshell/shellscrollbar.h"
#include "scene/graphicalcontainernode.h"
#include "keybindings.h"
#include "SparrowInput/keybindings.h"
class Input;
class MeshNode;
@ -36,7 +36,7 @@ private:
ScriptNode * m_script;
glm::vec3 m_text_color;
std::wstring m_input_string;
std::string m_input_string;
unsigned int m_input_cursor_pos;
TextNode* m_input_mesh;
@ -61,8 +61,8 @@ public:
void scrollDown();
void toggleShell();
void out(std::wstring str);
void out(std::wstring str, glm::vec3 color);
void out(std::string str);
void out(std::string str, glm::vec3 color);
glm::ivec2 getPosition(){return m_position;}
glm::ivec2 getDimension(){return m_dimension;}
@ -72,7 +72,6 @@ public:
void setMoveCursorLeftAction(int action){m_move_cursor_left = action;}
void setMoveCursorRightAction(int action){m_move_cursor_right = action;}
// void setPlopTest(int action){m_plop_test = action;}
void setClearConsoleAction(int action){m_clear_console_action = action;}
void moveCursorLeft(){m_input_cursor_pos--;}

View File

@ -1,13 +1,13 @@
#include <engine.h>
#include <input.h>
#include <scene.h>
#include <mesh.h>
#include <deferredpipeline.h>
#include <phongmaterial.h>
#include <SparrowInput/input.h>
#include <SparrowRenderer/scene.h>
#include <SparrowRenderer/mesh.h>
#include <SparrowRenderer/deferredpipeline.h>
#include <SparrowRenderer/phongmaterial.h>
#include <resourcemanager.h>
#include <sparrowrenderer.h>
#include <texture.h>
#include <chunk.h>
#include <SparrowRenderer/sparrowrenderer.h>
#include <SparrowRenderer/texture.h>
#include <SparrowRenderer/chunk.h>
#include "defaultkeysmap.h"
#include <scene/scenetree.h>
@ -34,8 +34,8 @@
#include "scene/gui/backgroundnode.h"
#include "potator.h"
#include "serializationmanager.h"
#include "serializable.h"
#include "SparrowSerializer/serializationmanager.h"
#include "SparrowSerializer/serializable.h"
#include <fstream>
#include "scene/gui/callback.h"
@ -372,8 +372,8 @@ int main(){
}*/
// shell output tests
engine.outputShell("Hello World!");
engine.outputShell("Starting test :");
engine.getShell()->out("Hello World!");
engine.getShell()->out("Starting test :");
// preparing shaders and launching the engine
engine.getScene()->updateShaders();

View File

@ -3,11 +3,11 @@
#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
#include "scene/scenetree.h"
#include "parametricmesh.h"
#include "phongmaterial.h"
#include "SparrowRenderer/parametricmesh.h"
#include "SparrowRenderer/phongmaterial.h"
#include "scene/meshnode.h"
#include "tools/loader.h"
#include "texture.h"
#include "SparrowRenderer/texture.h"
#include "scene/graphicalcontainernode.h"
#define PHYSICS_OFFSET 0.01f

View File

@ -2,7 +2,7 @@
#define POTATOR_H
#include "scene/gibgeneratornode.h"
#include "input.h"
#include "SparrowInput/input.h"
class PlayerCharacterNode;
class Mesh;

View File

@ -1,6 +1,6 @@
#include "font.h"
#include <phongmaterial.h>
#include "mesh.h"
#include <SparrowRenderer/phongmaterial.h>
#include "SparrowRenderer/mesh.h"
#include "scene/textnode.h"
Font::Font()

View File

@ -2,12 +2,12 @@
#include <fstream>
#include <streambuf>
#include <cstring>
#include <image.h>
#include <SparrowRenderer/image.h>
#include "../resourcemanager.h"
#include <SFML/Graphics/Image.hpp>
#include <mesh.h>
#include <phongmaterial.h>
#include "texture.h"
#include <SparrowRenderer/mesh.h>
#include <SparrowRenderer/phongmaterial.h>
#include "SparrowRenderer/texture.h"
#include "utils.h"
#include "font.h"