From a49415ebc0649396e8b9a048537120fa0f6b17e7 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Tue, 7 Apr 2015 13:52:38 +0200 Subject: [PATCH] cleanup --- Weave/Graphix/Scene.cpp | 35 ----------------------------------- Weave/Graphix/Scene.h | 10 ---------- Weave/Graphix/Texture.cpp | 4 +++- Weave/Graphix/Texture.h | 5 ++--- Weave/Graphix/ViewPort.cpp | 8 +++++--- 5 files changed, 10 insertions(+), 52 deletions(-) diff --git a/Weave/Graphix/Scene.cpp b/Weave/Graphix/Scene.cpp index 0fa52c9..836913e 100644 --- a/Weave/Graphix/Scene.cpp +++ b/Weave/Graphix/Scene.cpp @@ -20,8 +20,6 @@ Scene::Scene() : Scene::Scene(unsigned int x, unsigned int y, unsigned int width, unsigned int height, float fovy, float zNear, float zFar, vec3 pos, SceneObject* _lookat) : viewPort(new ViewPort(x, y, width, height, fovy, zNear, zFar)), - projection(perspective(fovy, (float)width / height, zNear, zFar)), - view(translate(pos)), SceneObjects(new list), ShaderSet(new set), newObjects(true), @@ -33,8 +31,6 @@ viewPort(new ViewPort(x, y, width, height, fovy, zNear, zFar)), Scene::Scene(Scene* _Scene, unsigned int x, unsigned int y, unsigned int width, unsigned int height, float fovy, float zNear, float zFar, vec3 pos, SceneObject* _lookat) : viewPort(new ViewPort(x, y, width, height, fovy, zNear, zFar)), - projection(perspective(fovy, (float)width / height, zNear, zFar)), - view(translate(pos)), SceneObjects(_Scene->SceneObjects), ShaderSet((_Scene->ShaderSet)), newObjects(false), @@ -76,7 +72,6 @@ void Scene::update(float deltaT) if (lookat != NULL){ pos = lookat->getPosition(); - view = view*translate(-pos); } int move_x = Events::getMoveX(); @@ -133,9 +128,6 @@ void Scene::update(float deltaT) } - if (lookat != NULL) - view = view*translate(lookat->getPosition()); - } void Scene::draw() const @@ -145,9 +137,6 @@ void Scene::draw() const for (auto i = ShaderSet->cbegin(); i != ShaderSet->cend(); ++i) { viewPort->bindView(*i,lookat->getPosition()+vec3(0.0f,1.0f,0.0f)); - //(*i)->useShader(); - //glUniformMatrix4fv((*i)->getUniformLocation("projection"), 1, false, value_ptr(projection)); - //glUniformMatrix4fv((*i)->getUniformLocation("view"), 1, false, value_ptr(view)); } @@ -183,36 +172,12 @@ void Scene::deleteObject(SceneObject* _del) SceneObjects->remove(_del); } -const vec3 Scene::getViewerPos() const -{ - return vec3(projection * vec4(0.0f)); -} list* Scene::getSceneObjects() { return SceneObjects; } -//void Scene::setProjection(mat4 _projection) -//{ -// projection = _projection; -//} - -void Scene::setProjection(float fovy, float aspect, float zNear, float zFar) -{ - projection = perspective(fovy, aspect, zNear, zFar); -} - -/* -void Scene::updateProjection(mat4 _projection) -{ - projection = _projection * projection; -}*/ - -//void Scene::setViewPort(unsigned int x, unsigned int y, unsigned int width, unsigned int height) -//{ -// viewPort = new ViewPort(x, y, width, height); -//} void Scene::setLookAt(SceneObject* _lookat) { diff --git a/Weave/Graphix/Scene.h b/Weave/Graphix/Scene.h index 5fe190c..ee985d8 100644 --- a/Weave/Graphix/Scene.h +++ b/Weave/Graphix/Scene.h @@ -29,22 +29,12 @@ public: void addObject(SceneObject*); void deleteObject(SceneObject*); - const vec3 getViewerPos() const; - SceneList* getSceneObjects(); -// void setViewPort(unsigned int, unsigned int, unsigned int, unsigned int); - -// void setProjection(mat4 _projection); - void setProjection(float fovy, float aspect, float zNear, float zFar); - //void updateProjection(mat4); - void setLookAt(SceneObject* _lookat); protected: ViewPort* viewPort; - mat4 projection; - mat4 view; SceneObject* lookat; diff --git a/Weave/Graphix/Texture.cpp b/Weave/Graphix/Texture.cpp index 3dd6953..69ba631 100644 --- a/Weave/Graphix/Texture.cpp +++ b/Weave/Graphix/Texture.cpp @@ -1,4 +1,6 @@ #include "Texture.h" +#include +#include "FreeImage.h" #include using std::string; @@ -6,7 +8,7 @@ using std::cout; using std::endl; -Texture::Texture(const string& _path) : path(_path) +Texture::Texture(const string& _path) : path(_path), handle(-1) { auto i = texture_map.find(_path); diff --git a/Weave/Graphix/Texture.h b/Weave/Graphix/Texture.h index 1962a1c..85043e4 100644 --- a/Weave/Graphix/Texture.h +++ b/Weave/Graphix/Texture.h @@ -1,8 +1,7 @@ #pragma once #include -#include -#include "FreeImage.h" + #include @@ -23,7 +22,7 @@ public: operator string() const; private: - GLuint handle; + unsigned int handle; string path; static str2int_map texture_map; diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index 212f9c4..75c315b 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -17,7 +17,8 @@ ViewPort::ViewPort(unsigned int _x, unsigned int _y, unsigned int _width, unsign projection(perspective(fovy, (float)width / height, zNear, zFar)), view_angle_x(0), view_angle_y(0), - view_dist(2) + view_dist(2), + view(0.f) { rotateView(0.f, 0.f); } @@ -48,8 +49,8 @@ void ViewPort::rotateView(float angle_x, float angle_y){ if (angle_y || angle_x){ - view_angle_x += angle_x; - view_angle_y += angle_y; + view_angle_x -= angle_x; + view_angle_y -= angle_y; //Y-Limits if (view_angle_y > VIEW_TOP_LIM) @@ -58,6 +59,7 @@ void ViewPort::rotateView(float angle_x, float angle_y){ if (view_angle_y < VIEW_BOT_LIM) view_angle_y = VIEW_BOT_LIM; + //keine Ahnung warum hier noch durch 50 geteilt werden muss, sonst ists aber irgend wie falsch view = translate(vec3(0.f, 0.f, -view_dist))*rotate(view_angle_y / 50, vec3(1.f, 0.f, 0.f))*rotate(view_angle_x / 50, vec3(0.f, 1.f, 0.f)); } -- 2.47.3