From 91271ea8e422096eec038d53e63ad4b411e54e56 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Sun, 19 Jun 2016 15:10:19 +0200 Subject: [PATCH] added basic implementation for CameraNode and fixed compatibility with renderer --- src/scenetree.h | 5 ++++- src/tools/loader.cpp | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/scenetree.h b/src/scenetree.h index bcb502e..d0c655c 100644 --- a/src/scenetree.h +++ b/src/scenetree.h @@ -6,6 +6,7 @@ #include "scene.h" #include "light.h" #include "resourcemanager.h" +#include "camera.h" class SimplePipeline; @@ -49,7 +50,9 @@ protected: //TODO : Fix compil error here class CameraNode : public Camera, SceneNode { - + virtual glm::mat4 getProjectionMatrix(){return glm::mat4();} + virtual glm::mat4 getViewMatrix(){return glm::mat4();} + virtual void resize(int width, int height){} }; class SceneTree : public Scene diff --git a/src/tools/loader.cpp b/src/tools/loader.cpp index d956796..acb3cc6 100644 --- a/src/tools/loader.cpp +++ b/src/tools/loader.cpp @@ -41,10 +41,10 @@ Image* Loader::loadImage(const std::string &filename, bool hasAlpha) img->allocate(size); const sf::Uint8 *pixels = sfImg.getPixelsPtr(); if(hasAlpha) - memcpy(img->pixels, pixels, size); + memcpy(img->pixels.data(), pixels, size); else { - sf::Uint8 *ptr = (sf::Uint8*)img->pixels; + sf::Uint8 *ptr = (sf::Uint8*)img->pixels.data(); for(int i=0; iwidth*img->height; ++i) memcpy(ptr + i*3, pixels + i*4, 3); } @@ -245,9 +245,9 @@ bool Loader::loadMTL(const std::string &filename) } else if((tokens[0].compare("Ka") == 0) && tokens.size() == 4) { - mat->ambient.r = std::stof(tokens[1]); - mat->ambient.g = std::stof(tokens[2]); - mat->ambient.b = std::stof(tokens[3]); + mat->emission.r = std::stof(tokens[1]); + mat->emission.g = std::stof(tokens[2]); + mat->emission.b = std::stof(tokens[3]); } else if(tokens[0].compare("Kd") == 0 && tokens.size() == 4) { @@ -268,10 +268,10 @@ bool Loader::loadMTL(const std::string &filename) else if((tokens[0].substr(0,4) == "map_") && tokens.size() == 2) { if(tokens[0].compare("map_Ka") == 0){ - mat->ambient_texture = RESOURCE_GET(Texture,tokens[1]); - if (mat->ambient_texture == NULL){ - mat->ambient_texture = new Texture(loadImage(tokens[1])); - RESOURCE_ADD(mat->ambient_texture,Texture,tokens[1]); + mat->emission_texture = RESOURCE_GET(Texture,tokens[1]); + if (mat->emission_texture == NULL){ + mat->emission_texture = new Texture(loadImage(tokens[1])); + RESOURCE_ADD(mat->emission_texture,Texture,tokens[1]); } } else if(tokens[0].compare("map_Kd") == 0) { mat->diffuse_texture = RESOURCE_GET(Texture,tokens[1]);