]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
cleanup
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 7 Apr 2015 11:52:38 +0000 (13:52 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 7 Apr 2015 11:52:38 +0000 (13:52 +0200)
Weave/Graphix/Scene.cpp
Weave/Graphix/Scene.h
Weave/Graphix/Texture.cpp
Weave/Graphix/Texture.h
Weave/Graphix/ViewPort.cpp

index 0fa52c9f6929f16bc12f1ff2c7ee12dd4d3fa342..836913e070a563a5acbb484e093606c592ec9077 100644 (file)
@@ -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<SceneObject*>), 
        ShaderSet(new set<Shader*>),
        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<SceneObject*>* 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)
 {
index 5fe190c33ef25a07171140eddc5fa7609b4cf550..ee985d811608629b477fa5ffbef7644efa5266d5 100644 (file)
@@ -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;
 
index 3dd6953664a5b91045db4f6ec59dec54617a2d53..69ba6312aaca5cd70a822e1ae41c848e91fea1f7 100644 (file)
@@ -1,4 +1,6 @@
 #include "Texture.h"
+#include <GL\glew.h>
+#include "FreeImage.h"
 #include <iostream>
 
 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);
index 1962a1c2a34c63f378b7667d71c51110815d774c..85043e41a2208869a907b122dfbc4ed491cead42 100644 (file)
@@ -1,8 +1,7 @@
 #pragma once
 
 #include <string>
-#include <GL\glew.h>
-#include "FreeImage.h"
+
 
 #include <unordered_map>
 
@@ -23,7 +22,7 @@ public:
        operator string() const;
 
 private:
-       GLuint handle;
+       unsigned int handle;
        string path;
 
        static str2int_map texture_map;
index 212f9c44487f14c2f288451506476523248e4de2..75c315b6b8be17bcf6f42e3ffa348fc040f45f7e 100644 (file)
@@ -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));
 
        }