added basic implementation for CameraNode and fixed compatibility with renderer

This commit is contained in:
Lendemor 2016-06-19 15:10:19 +02:00
parent 4295481cfe
commit 91271ea8e4
2 changed files with 13 additions and 10 deletions

View File

@ -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

View File

@ -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; i<img->width*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]);