]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
redesigned Model & Shader
authorPeter Schaefer <schaeferpm@gmail.com>
Fri, 3 Apr 2015 13:38:11 +0000 (15:38 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Fri, 3 Apr 2015 13:38:11 +0000 (15:38 +0200)
error! Assimp defekt?

26 files changed:
Weave/Fps.h
Weave/Game.cpp
Weave/Game.h
Weave/Graphix/Act.cpp [deleted file]
Weave/Graphix/Act.h [deleted file]
Weave/Graphix/Model.cpp
Weave/Graphix/Model.h
Weave/Graphix/Performer.cpp [deleted file]
Weave/Graphix/Performer.h [deleted file]
Weave/Graphix/Scene.cpp
Weave/Graphix/Scene.h
Weave/Graphix/SceneObject.cpp
Weave/Graphix/SceneObject.h
Weave/Graphix/Setting.cpp [deleted file]
Weave/Graphix/Setting.h [deleted file]
Weave/Graphix/Shader.cpp
Weave/Graphix/Shader.h
Weave/Graphix/Texture.cpp
Weave/PlayerI.cpp [deleted file]
Weave/PlayerI.h [deleted file]
Weave/Weave.vcxproj
Weave/Weave.vcxproj.filters
Weave/main.cpp
bin/assimp.dll
lib/x64/SDL2.dll [deleted file]
lib/x86/SDL2.dll [deleted file]

index 8c610c0b03e5edf0cd2d9be4e191c7d1bb330483..fdc805a33a299bc16a989898959e7c824ced9d76 100644 (file)
@@ -6,7 +6,7 @@
 class Fps
 {
 public:
-       Fps(const float=0.6f);
+       Fps(const float=0.3f);
        ~Fps();
 
        /* FrameZeit in Millisekunden  */
index 0b9d3befc8870736b7e07f1fa6e44b3a78830145..845e115fad9a5f574e58dc79efa5ebb196218e51 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "Message.h"
 
-#include "PlayerI.h"
+//#include "PlayerI.h"
 
 #include <iostream>
 #include <time.h>
@@ -29,33 +29,30 @@ using std::endl;
 using std::string;
 
 
-Game::Game()
+Game::Game() : playing(true)
 {
        srand((int)time(NULL));
        // Hauptfenster
        Scene* tmp_Scene = new Scene(0, 0, Graphix::getWindowWidth(), Graphix::getWindowHeight(), 60, 0.1f, 100, vec3(0.0f, 0.0f, -4.0f));
        layer[0] = tmp_Scene;
 
-       //Minimap
-       layer[1] = new Scene(tmp_Scene, Graphix::getWindowWidth() - 200, 0, 200, 100, 60, 0.1f, 100, vec3(0.0f, 0.0f, -8.0f));
-
        //Allg Shader
-       Shader* shader1 = new Shader("../shader/basicTexture_VS.hlsl", "../shader/lightingTexture_FS.hlsl");
+       Shader* shader1 = new Shader("basicTexture_VS.hlsl", "lightingTexture_FS.hlsl");
 
        //Player
-       SceneObject* tmp_playerObject = new SceneObject(shader1, glm::mat4(1.0f), "../models/sphere/sphere.dae", "../Textures/simple_trans.png");
+       SceneObject* tmp_playerObject = new SceneObject(shader1, glm::mat4(1.0f), "sphere/sphere.dae", "simple_trans.png");
 
-       tmp_playerObject->setIntelligenz(new PlayerI(tmp_playerObject));
+       //tmp_playerObject->setIntelligenz(new PlayerI(tmp_playerObject));
        tmp_Scene->addObject(tmp_playerObject);
        tmp_Scene->setLookAt(tmp_playerObject);
        //player1 = Player(tmp_playerObject);
 
        // World
-       SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(15.f)), "../models/sphere/sphere.dae", "../Textures/sky_withstars.png",1.f,1.f,1.f,vec3(0.f),nullptr,true);
+       SceneObject* tmp_world = new SceneObject(shader1, scale(vec3(15.f)), "sphere/sphere.dae", "sky_withstars.png",1.f,1.f,1.f,vec3(0.f));
        tmp_world->setCollision(false);
 
-       SceneObject::setTextureDanger("../Textures/enemy.png");
-       SceneObject::setTextureSave("../Textures/enemy_save.png");
+       SceneObject::setTextureDanger("enemy.png");
+       SceneObject::setTextureSave("enemy_save.png");
 
        tmp_Scene->addObject(tmp_world);
 
@@ -73,7 +70,7 @@ Game::Game()
                        --i;
                        continue;
                }
-               tmp_enemy = new SceneObject(shader1, translate(pos), "../models/sphere/sphere.dae", "", (float)(rand() % 10 + 2) / 10.f);
+               tmp_enemy = new SceneObject(shader1, translate(pos), "sphere/sphere.dae", "", (float)(rand() % 10 + 2) / 10.f);
                tmp_enemy->setEnemy(true);
                tmp_Scene->addObject(tmp_enemy);
                //cout << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << endl;
@@ -101,14 +98,11 @@ void Game::play()
        while (!Events::quit){
                fps.step();
 
-               //cout << "fps:" << fps.getAvFPS();
-
                sleep_time += (int)(1000./ FRAMERATE_FIX - fps.getTicks());
 
                if (sleep_time < 0)
                        sleep_time = 0;
 
-               //cout << " stime:" << sleep_time << endl;
                Sleep(sleep_time);              
 
                Events::processEvents();
@@ -149,17 +143,25 @@ void Game::play()
 
 void Game::update(float deltaT)
 {
+       if (playing){
+               for (auto i = layer.begin(); i != layer.end(); ++i){
+                       (*i).second->update(deltaT);
+               }
 
-       for (auto i = layer.begin(); i != layer.end(); ++i){
-               (*i).second->update(deltaT);
-       }
+       //      l_interface->update(deltaT);
+       }else
+               l_menu->update(deltaT);
 }
 
 void Game::draw() const
 {
-       
-       for (auto i = layer.begin(); i != layer.end(); ++i){
-               (*i).second->draw();
+       if (playing){
+               for (auto i = layer.begin(); i != layer.end(); ++i){
+                       (*i).second->draw();
+               }
+       //      l_interface->draw();
        }
+       else
+               l_menu->draw();
 
 }
index 4508931893b50222ee7e338fcd41021ee0ddb91d..137870692a4601497034691984eca8ec443a0e09 100644 (file)
@@ -25,6 +25,10 @@ public:
 
 private:
 
+       bool playing;
+
+       Drawable *l_interface, *l_menu;
+
        map<int,Drawable*> layer;
        //Player player1;
 
diff --git a/Weave/Graphix/Act.cpp b/Weave/Graphix/Act.cpp
deleted file mode 100644 (file)
index 13b49ad..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "Act.h"
-#include "Performer.h"
-
-#include <iostream>
-
-using std::cout;
-using std::endl;
-
-Act::Act(Performer* _performer, mat4 _model) : modelMatrix(_model), performer(_performer), boxPos(vec3(0))
-{
-
-}
-
-Act::~Act()
-{
-       cout << "NICE!" << endl;
-}
-
-
-mat4 Act::getModelMatrix() const
-{
-       return modelMatrix;
-}
-
-void Act::draw() const
-{
-       performer->draw(modelMatrix, -1);
-}
-
-void Act::updateBoxPos(const mat4& _perspective)
-{
-       boxPos = (vec3)(_perspective*modelMatrix)[4];
-}
-vec3 Act::getBoxPos() const
-{
-       return boxPos;
-}
\ No newline at end of file
diff --git a/Weave/Graphix/Act.h b/Weave/Graphix/Act.h
deleted file mode 100644 (file)
index 614a688..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include "GLM.h"
-
-class Performer;
-
-class Act
-{
-public:
-       Act(Performer*,mat4);
-       ~Act();
-
-       //setModelMatrix();
-       //setTexture();
-
-       mat4 getModelMatrix() const;
-
-       void updateBoxPos(const mat4& _perspective);
-       vec3 Act::getBoxPos() const;
-
-       void draw() const;
-
-
-private:
-       Performer* performer;
-       mat4 modelMatrix;
-
-       vec3 boxPos;
-
-       //Texture
-};
-
index 6a4b31ab0a8a0321fd7958f2309ea66a6d727c5a..fcc705a8f7184ca9785f4ac4fbd0ffe2d0f7260b 100644 (file)
@@ -1,9 +1,9 @@
 #include "Model.h"
 
 #include <GL/glew.h>
-#include <assimp/Importer.hpp>
-#include <assimp/scene.h>
-#include <assimp/postprocess.h>
+//#include <assimp/Importer.hpp>
+//#include <assimp/scene.h>
+//#include <assimp/postprocess.h>
 
 #include "Shader.h"
 #include "../Message.h"
 typedef unsigned int uint;
 
 
-Model::Model(const string& _modelpath, Shader* _shader, bool invert) : 
-       shader(_shader), 
-       modelpath(_modelpath),
-       vao(-1),
-       numfaces(0),
-       numvertices(-1)
+Model::Model(const string& _modelpath) : 
+       numfaces(-1),
+       numvertices(-1),
+       vertexBuffer(-1),
+       normalBuffer(-1),
+       uvBuffer(-1),
+       indexBuffer(-1)
 {
 
-       //falls Model mit Shader schon geladen wurde
-       auto i = vao_map.find(*shader);
-       if (i != vao_map.end())
-       {
-               auto j = i->second.find(modelpath);
-               if (j != i->second.end())
-               {
-                       vao = vao_map[*shader][modelpath];
-                       numvertices = buffer_map[modelpath].numvertices;
-                       numfaces = buffer_map[modelpath].numfaces;
-                       return;
-               }
-       }
-       
-       {
-
-               uint vertexBuffer = -1, normalBuffer = -1, uvBuffer = -1, indexBuffer = -1;
-
-               //falls model aber noch nicht mit dem Shader geladen wurde
-               auto i = buffer_map.find(modelpath);
-               if (i != buffer_map.end())
-               {
-                       vertexBuffer = i->second.vertexBuffer;
-                       normalBuffer = i->second.normalBuffer;
-                       uvBuffer = i->second.uvBuffer;
-                       indexBuffer = i->second.indexBuffer;
-                       numvertices = i->second.numvertices;
-                       numfaces = i->second.numfaces;
-               }
-               else
-               {
-                       
                        float *vertex = nullptr, *normals = nullptr, *uvs = nullptr;
                        uint *index = nullptr;
 
-                       import(modelpath, numvertices,numfaces,vertex,uvs,normals,index,invert);
+                       import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index);
 
                        genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
                        genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals);
                        genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs);
                        genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index);
 
-                       buffer_map[modelpath].vertexBuffer = vertexBuffer;
-                       buffer_map[modelpath].normalBuffer = normalBuffer;
-                       buffer_map[modelpath].uvBuffer = uvBuffer;
-                       buffer_map[modelpath].indexBuffer = indexBuffer;
-                       buffer_map[modelpath].numfaces = numfaces;
-                       buffer_map[modelpath].numvertices = numvertices;
-
                        delete vertex, normals, uvs, index;
-               }
-
-               glGenVertexArrays(1, &vao);
-               glBindVertexArray(vao);
-
-               bindBuffer(vertexBuffer, "position");
-               bindBuffer(uvBuffer, "uv", 2);
-               bindBuffer(normalBuffer, "normal");
 
-               glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
-
-               glBindVertexArray(0);
-
-               glBindBuffer(GL_ARRAY_BUFFER, 0);
-               glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-
-               vao_map[*shader][modelpath] = vao;
-       }
 }
 
 
 Model::~Model()
 {
-       /*
+               for (auto i = shader_map.begin(); i != shader_map.end(); ++i){
+                       glDeleteVertexArrays(1, &(i->second));
+               }
                glDeleteBuffers(1, &vertexBuffer);
                glDeleteBuffers(1, &normalBuffer);
                glDeleteBuffers(1, &uvBuffer);
                glDeleteBuffers(1, &indexBuffer);
-               glDeleteVertexArrays(1, &vao);
-       */
+
+       
 }
 
-void Model::useModel() const
+void Model::useModel(Shader* _shader)
 {
+       uint vao=-1;
+       auto i = shader_map.find(*_shader);
+       if (i == shader_map.end())
+               vao = bindShader(_shader);
+       else
+               vao = i->second;
+
        glBindVertexArray(vao);
+       _shader->useShader();
+
+}
+
+void Model::useModel(Shader* _shader) const
+{
+       uint vao = -1;
+       auto i = shader_map.find(*_shader);
+       if (i == shader_map.end())
+               Message::error("The Shader wasn't bind to the Model.\n");
+       else
+               vao = i->second;
+
+       glBindVertexArray(vao);
+       _shader->useShader();
 
-       shader->useShader();
 }
 
 void Model::drawModel() const
 {
 
        glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, 0);
-
        glBindVertexArray(0);
 }
 
+unsigned int Model::bindShader(Shader* _shader)
+{
+       uint vao;
+       glGenVertexArrays(1, &vao);
+       glBindVertexArray(vao);
 
+       bindBuffer(vertexBuffer, _shader->getAttribLocation("position"));
+       bindBuffer(uvBuffer, _shader->getAttribLocation("uv"), 2);
+       bindBuffer(normalBuffer, _shader->getAttribLocation("normal"));
+
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
+
+       glBindVertexArray(0);
+
+       glBindBuffer(GL_ARRAY_BUFFER, 0);
+       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+       shader_map[*_shader] = vao;
+
+       return vao;
+}
 
 void Model::genBuffer(uint &buffer, uint size, void* value)
 {
@@ -126,106 +113,80 @@ void Model::genBuffer(uint &buffer, uint size, void* value)
        glBindBuffer(GL_ARRAY_BUFFER, 0);
 }
 
-void Model::bindBuffer(uint &buffer, string name, uint dim)
+void Model::bindBuffer(const uint &buffer,const uint index,const uint dim)
 {
-       GLint Index = glGetAttribLocation(*shader, name.c_str());
-       if (Index >= 0)
-       {
                glBindBuffer(GL_ARRAY_BUFFER, buffer);
-               glEnableVertexAttribArray(Index);
-               glVertexAttribPointer(Index, dim, GL_FLOAT, GL_FALSE, 0, 0);
+               glEnableVertexAttribArray(index);
+               glVertexAttribPointer(index, dim, GL_FLOAT, GL_FALSE, 0, 0);
                glBindBuffer(GL_ARRAY_BUFFER, 0);
-       }
-       else{
-               Message::info("GL_GetAttLoc: Kann '" + name + "' nicht finden.");
-       }
 }
 
 
 
-bool Model::import(const string& path,uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index, bool invert)
+bool Model::import(const string& path,uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index)
 {
-       Assimp::Importer importer;
-
-       const aiScene* scene = importer.ReadFile(path, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);
-       if (!scene)
-       {
-               Message::error("The file " + path + " couldn't be read.\n" + importer.GetErrorString());
-       }
-
-       if (scene->HasMeshes())
-       {
-               aiMesh* mesh = scene->mMeshes[0];
-               numvertices = mesh->mNumVertices;
-               numfaces = mesh->mNumFaces;
-               vertex = new float[numvertices * 3];
-               uvs = new float[numvertices * 2];
-               index = new uint[numfaces * 3];
-               normals = new float[numvertices * 3];
-               //aiFace* faces = mesh->mFaces;
-
-
-               //load vertices from file
-               for (uint i = 0; i < numvertices; i++)
-               {
-                       vertex[3 * i] = mesh->mVertices[i].x;
-                       vertex[3 * i + 1] = mesh->mVertices[i].y;
-                       vertex[3 * i + 2] = mesh->mVertices[i].z;
-               }
-
-
-
-               //TODO SHOULD BE IVERTED
-               //load UVs from file
-               for (uint i = 0; i < numvertices; i++)
-               {
-                       uvs[2 * i] = mesh->mTextureCoords[0][i].x;//[i]->x;
-                       uvs[2 * i + 1] = mesh->mTextureCoords[0][i].y;//[i]->y;
-               }
-
-
-               //load indices from file
-               for (uint i = 0; i < numfaces; i++)
-               {
-                       index[3 * i] = mesh->mFaces[i].mIndices[0];
-                       index[3 * i + 1] = mesh->mFaces[i].mIndices[1];
-                       index[3 * i + 2] = mesh->mFaces[i].mIndices[2];
-               }
-
-               //TODO SHOULD BE IVERTED
-               //load normals from file
-
-               if (invert)
-               {
-                       for (uint i = 0; i < numvertices; i++)
-                       {
-                               normals[3 * i] = -mesh->mNormals[i].x;
-                               normals[3 * i + 1] = -mesh->mNormals[i].y;
-                               normals[3 * i + 2] = -mesh->mNormals[i].z;
-                       }
-               }
-               else{
-                       for (uint i = 0; i < numvertices; i++)
-                       {
-                               normals[3 * i] = mesh->mNormals[i].x;
-                               normals[3 * i + 1] = mesh->mNormals[i].y;
-                               normals[3 * i + 2] = mesh->mNormals[i].z;
-                       }
-               }
-
-       }
-       else
-       {
-               Message::error("The file " + path + " doesn't contain any nodes.");
-       }
+       //Assimp::Importer importer;
+
+       //const aiScene* scene = importer.ReadFile(path, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);
+       //if (!scene)
+       //{
+       //      Message::error("The file " + path + " couldn't be read.\n" + importer.GetErrorString());
+       //}
+
+       //if (scene->HasMeshes())
+       //{
+       //      //aiMesh* mesh = scene->mMeshes[0];
+       //      numvertices = mesh->mNumVertices;
+       //      numfaces = mesh->mNumFaces;
+       //      vertex = new float[numvertices * 3];
+       //      uvs = new float[numvertices * 2];
+       //      index = new uint[numfaces * 3];
+       //      normals = new float[numvertices * 3];
+       //      //aiFace* faces = mesh->mFaces;
+
+
+       //      //load vertices from file
+       //      for (uint i = 0; i < numvertices; i++)
+       //      {
+       //              vertex[3 * i] = mesh->mVertices[i].x;
+       //              vertex[3 * i + 1] = mesh->mVertices[i].y;
+       //              vertex[3 * i + 2] = mesh->mVertices[i].z;
+       //      }
+
+
+
+       //      //load UVs from file
+       //      for (uint i = 0; i < numvertices; i++)
+       //      {
+       //              uvs[2 * i] = mesh->mTextureCoords[0][i].x;//[i]->x;
+       //              uvs[2 * i + 1] = mesh->mTextureCoords[0][i].y;//[i]->y;
+       //      }
+
+
+       //      //load indices from file
+       //      for (uint i = 0; i < numfaces; i++)
+       //      {
+       //              index[3 * i] = mesh->mFaces[i].mIndices[0];
+       //              index[3 * i + 1] = mesh->mFaces[i].mIndices[1];
+       //              index[3 * i + 2] = mesh->mFaces[i].mIndices[2];
+       //      }
+
+       //      //TODO SHOULD BE IVERTED
+       //      //load normals from file
+
+
+       //      for (uint i = 0; i < numvertices; i++)
+       //      {
+       //              normals[3 * i] = mesh->mNormals[i].x;
+       //              normals[3 * i + 1] = mesh->mNormals[i].y;
+       //              normals[3 * i + 2] = mesh->mNormals[i].z;
+       //      }
+
+       //}
+       //else
+       //{
+       //      Message::error("The file " + path + " doesn't contain any nodes.");
+       //}
 
        return true;
 }
-
-Shader* Model::getShader() const
-{
-       return shader;
-}
-
-int2str2int_map Model::vao_map;
-str2buffer_map Model::buffer_map;
\ No newline at end of file
index 05dd017f06e2a144ede14d934a105aef77782b49..943532337aabbaf01e41f5e05639539174dbf7cb 100644 (file)
@@ -7,46 +7,32 @@ using std::string;
 using std::unordered_map;
 
 //VAO MAP
-typedef unordered_map<string, unsigned int> str2int_map;
-typedef unordered_map<unsigned int, str2int_map> int2str2int_map;
-
-//BUFFER MAP
-typedef struct _myBuffer
-{
-       unsigned int vertexBuffer = -1, normalBuffer = -1, uvBuffer = -1, indexBuffer = -1, numfaces=0, numvertices=0;
-} Buffer;
-typedef unordered_map<string, Buffer> str2buffer_map;
-
+typedef unordered_map<unsigned int, unsigned int> int2int_map;
 
 class Shader;
 
-
 class Model
 {
 public:
-       Model(const string& modelpath,Shader* _shader,bool invert=false);
+       Model(const string& modelpath);
 
        virtual ~Model();
 
-       void useModel() const;
+       void useModel(Shader* shader);
+       void useModel(Shader* shader) const;
        void drawModel() const;
+       unsigned int bindShader(Shader* shader);
 
-       Shader* getShader() const;
-
-protected:
-       unsigned int vao;
-       Shader* shader;
-       string modelpath;
+private:
        unsigned int numvertices, numfaces;
+       unsigned int vertexBuffer, normalBuffer, uvBuffer, indexBuffer;
 
-private:
+       int2int_map shader_map;
 
-       bool import(const string& path, unsigned int& numvertices, unsigned int& numfaces, float*& vertex, float*& uvs, float*& normals, unsigned int*& index, bool invert=false);
+       bool import(const string& path, unsigned int& numvertices, unsigned int& numfaces, float*& vertex, float*& uvs, float*& normals, unsigned int*& index);
        void genBuffer(unsigned int &buffer, unsigned int size, void* value);
-       void bindBuffer(unsigned int &buffer, string name, unsigned int dim = 3);
-
-       static int2str2int_map vao_map;
-       static str2buffer_map buffer_map;
+       void bindBuffer(const unsigned int &buffer, const unsigned int index,const unsigned int dim = 3);
        
+
 };
 
diff --git a/Weave/Graphix/Performer.cpp b/Weave/Graphix/Performer.cpp
deleted file mode 100644 (file)
index 24d5346..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-#include "Performer.h"
-
-#include "GLM.h"
-#include <GL\glew.h>
-#include <fstream>
-
-#include <assimp/Importer.hpp>
-#include <assimp/scene.h>
-#include <assimp/postprocess.h>
-
-
-#include "../Message.h"
-
-using std::ifstream;
-using std::istreambuf_iterator;
-
-typedef unsigned int uint;
-
-
-Performer::Performer(const string& _shader1, const string& _shader2, const string& _modelpath)
-{
-       //SHADER ----------------------------------------------------
-       initShader(_shader1, _shader2);
-
-       //MODEL ------------------------------------------------------
-       initModel(_modelpath);
-}
-
-
-Performer::~Performer()
-{
-
-       glDeleteBuffers(1, &vertexBuffer);
-       glDeleteBuffers(1, &normalBuffer);
-       glDeleteBuffers(1, &uvBuffer);
-       glDeleteBuffers(1, &indexBuffer);
-       glDeleteVertexArrays(1, &vao);
-
-       glDeleteProgram(shader);
-}
-
-void Performer::initShader(const string& _shader1, const string& _shader2)
-{
-       uint handleS1 = loadShader(_shader1);
-       uint handleS2 = loadShader(_shader2);
-
-       shader = loadProgram(handleS1, handleS2);
-
-       glDeleteShader(handleS1);
-       glDeleteShader(handleS2);
-
-       modelID = glGetUniformLocation(shader, "model");
-       viewID = glGetUniformLocation(shader, "view");
-       projectionID = glGetUniformLocation(shader, "projection");
-}
-
-void Performer::initModel(const string& _modelpath)
-{
-       glUseProgram(shader);
-
-       float *vertex = nullptr, *normals = nullptr, *uvs = nullptr;
-       uint *index = nullptr;
-
-       import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index);
-
-       genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
-       genBuffer(normalBuffer, numvertices * 3 * sizeof(float), (void*)normals);
-       genBuffer(uvBuffer, numvertices * 2 * sizeof(float), (void*)uvs);
-       genBuffer(indexBuffer, numfaces * 3 * sizeof(uint), (void*)index);
-
-       delete vertex, normals, uvs, index;
-
-       glGenVertexArrays(1, &vao);
-       glBindVertexArray(vao);
-
-       bindBuffer(vertexBuffer, "position");
-       bindBuffer(uvBuffer, "uv", 2);
-       bindBuffer(normalBuffer, "normal");
-
-       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
-
-       glBindVertexArray(0);
-
-       glBindBuffer(GL_ARRAY_BUFFER, 0);
-       glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
-}
-
-
-void Performer::upgradePerspective(const mat4& _view, const mat4& _projection) const
-{
-       glUseProgram(shader);
-
-       glUniformMatrix4fv(viewID, 1, GL_FALSE, value_ptr(_view));
-       glUniformMatrix4fv(projectionID, 1, GL_FALSE, value_ptr(_projection));
-}
-
-void Performer::draw(const mat4& _model, uint _texture) const
-{
-       bool invert = false;
-
-       glBindVertexArray(vao);
-
-       glUseProgram(shader);
-
-       //other loading
-
-       glUniformMatrix4fv(modelID, 1, GL_FALSE, value_ptr(_model));
-
-       glUniform1i(glGetUniformLocation(shader, "inv"), invert ? -1 : 1);
-
-       glDrawElements(GL_TRIANGLES, numfaces * 3, GL_UNSIGNED_INT, 0);
-
-       glBindVertexArray(0);
-
-}
-
-
-void Performer::useShader() const
-{
-       glUseProgram(shader);
-}
-
-uint Performer::getHandle() const
-{
-       return shader;
-}
-
-
-uint Performer::loadShader(const string& _shaderPath) const
-{
-       uint handle = -1;
-       auto type = _shaderPath.substr(_shaderPath.find_last_of('_') + 1);
-       GLenum shaderType;
-       if (type == "VS.hlsl"){
-               shaderType = GL_VERTEX_SHADER;
-       }
-       else if (type == "FS.hlsl"){
-               shaderType = GL_FRAGMENT_SHADER;
-       }
-       else{
-               Message::error((string)"LoadShader: Typ <" + type + (string)"> nicht erkannt.");
-       }
-
-       ifstream shaderFile(_shaderPath);
-
-       if (shaderFile.good()){
-               string code = string(istreambuf_iterator<char>(shaderFile), istreambuf_iterator<char>());
-               shaderFile.close();
-
-               handle = glCreateShader(shaderType);
-
-               if (handle == 0){
-                       Message::error("LoadShader: Shader konnte nicht erstellt werden.");
-               }
-
-               auto codePtr = code.c_str();
-               glShaderSource(handle, 1, &codePtr, NULL);
-               glCompileShader(handle);
-
-               GLint succeed;
-               glGetShaderiv(handle, GL_COMPILE_STATUS, &succeed);
-
-               if (succeed == GL_FALSE || !glIsShader(handle)){
-                       GLint logSize;
-                       glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &logSize);
-                       auto message = new char[logSize];
-
-                       glGetShaderInfoLog(handle, logSize, NULL, message);
-                       Message::error((string)"LoadShader: Shader konnte nicht kompeliert werden.\n " + message);
-               }
-       }
-       else{
-               Message::error((string)"LoadShader: ShaderFile <" + _shaderPath + (string)"> konnte nicht geöffnet werden.");
-       }
-
-       return handle;
-}
-
-
-uint Performer::loadProgram(uint _shader1, uint _shader2) const
-{
-       uint programHandle;
-
-       programHandle = glCreateProgram();
-
-       if (programHandle == 0){
-               Message::error("LoadProgram: Program konnte nicht erstellt werden.");
-       }
-
-       glAttachShader(programHandle, _shader1);
-       glAttachShader(programHandle, _shader2);
-
-       glBindFragDataLocation(programHandle, 0, "fragColor");
-
-       glLinkProgram(programHandle);
-
-       GLint succeded;
-
-       glGetProgramiv(programHandle, GL_LINK_STATUS, &succeded);
-
-       if (!succeded){
-               GLint logSize;
-               glGetProgramiv(programHandle, GL_INFO_LOG_LENGTH, &logSize);
-               auto message = new char[logSize];
-
-               glGetProgramInfoLog(programHandle, logSize, NULL, message);
-               Message::error((string)"LoadProgram: Program konnte nicht kompeliert werden.\n" + message);
-       }
-       return programHandle;
-}
-
-void Performer::genBuffer(uint &buffer, uint size, void* value) const
-{
-       glGenBuffers(1, &buffer);
-       glBindBuffer(GL_ARRAY_BUFFER, buffer);
-       glBufferData(GL_ARRAY_BUFFER, size, value, GL_STATIC_DRAW);
-       glBindBuffer(GL_ARRAY_BUFFER, 0);
-}
-
-void Performer::bindBuffer(uint &buffer, const string& name, uint dim) const
-{
-       GLint Index = glGetAttribLocation(shader, name.c_str());
-       if (Index >= 0)
-       {
-               glBindBuffer(GL_ARRAY_BUFFER, buffer);
-               glEnableVertexAttribArray(Index);
-               glVertexAttribPointer(Index, dim, GL_FLOAT, GL_FALSE, 0, 0);
-               glBindBuffer(GL_ARRAY_BUFFER, 0);
-       }
-       else{
-               Message::info("GL_GetAttLoc: Kann '" + name + "' nicht finden.");
-       }
-}
-
-
-
-bool Performer::import(const string& path, uint& numvertices, uint& numfaces, float*& vertex, float*& uvs, float*& normals, uint*& index) const
-{
-       Assimp::Importer importer;
-
-       const aiScene* scene = importer.ReadFile(path, aiProcess_GenUVCoords | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);
-       if (!scene)
-       {
-               Message::error("The file " + path + " couldn't be read.\n" + importer.GetErrorString());
-       }
-
-       if (scene->HasMeshes())
-       {
-               aiMesh* mesh = scene->mMeshes[0];
-               numvertices = mesh->mNumVertices;
-               numfaces = mesh->mNumFaces;
-               vertex = new float[numvertices * 3];
-               uvs = new float[numvertices * 2];
-               index = new uint[numfaces * 3];
-               normals = new float[numvertices * 3];
-               //aiFace* faces = mesh->mFaces;
-
-
-               //load vertices from file
-               for (uint i = 0; i < numvertices; i++)
-               {
-                       vertex[3 * i] = mesh->mVertices[i].x;
-                       vertex[3 * i + 1] = mesh->mVertices[i].y;
-                       vertex[3 * i + 2] = mesh->mVertices[i].z;
-               }
-
-
-
-               //TODO SHOULD BE IVERTED
-               //load UVs from file
-               for (uint i = 0; i < numvertices; i++)
-               {
-                       uvs[2 * i] = mesh->mTextureCoords[0][i].x;//[i]->x;
-                       uvs[2 * i + 1] = mesh->mTextureCoords[0][i].y;//[i]->y;
-               }
-
-
-               //load indices from file
-               for (uint i = 0; i < numfaces; i++)
-               {
-                       index[3 * i] = mesh->mFaces[i].mIndices[0];
-                       index[3 * i + 1] = mesh->mFaces[i].mIndices[1];
-                       index[3 * i + 2] = mesh->mFaces[i].mIndices[2];
-               }
-
-               //TODO SHOULD BE IVERTED
-               //load normals from file
-               for (uint i = 0; i < numvertices; i++)
-               {
-                       normals[3 * i] = mesh->mNormals[i].x;
-                       normals[3 * i + 1] = mesh->mNormals[i].y;
-                       normals[3 * i + 2] = mesh->mNormals[i].z;
-               }
-               
-
-       }
-       else
-       {
-               Message::error("The file " + path + " doesn't contain any nodes.");
-       }
-
-       return true;
-}
\ No newline at end of file
diff --git a/Weave/Graphix/Performer.h b/Weave/Graphix/Performer.h
deleted file mode 100644 (file)
index 2f6623c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#pragma once
-
-#include <string>
-#include "GLM.h"
-
-using std::string;
-
-class Shader;
-
-class Performer
-{
-public:
-       Performer(const string& _shader1, const string& _shader2, const string& _modelpath);
-
-       virtual ~Performer();
-
-
-       void upgradePerspective(const mat4& _view, const mat4& _projection) const;
-       void upgradeTexture() const;
-       void draw(const mat4& _model, unsigned int _texture) const;
-       //update(deltaT)
-
-       void useShader() const;
-       unsigned int getHandle() const;
-
-private:
-       //Animation
-
-       //SHADER  ---------------------------------------------------
-       unsigned int shader=-1;
-
-       unsigned int loadShader(const string& _shaderPath) const;
-       unsigned int loadProgram(unsigned int _shader1, unsigned int _shader2) const;
-
-       void initShader(const string& _shader1, const string& _shader2);
-
-
-       //MODEL  ---------------------------------------------------
-       unsigned int modelID=-1;
-       unsigned int vertexBuffer = -1, normalBuffer = -1, uvBuffer = -1, indexBuffer = -1, vao=-1;
-       unsigned int numvertices=0, numfaces=0;
-
-       bool import(const string& path, unsigned int& numvertices, unsigned int& numfaces, float*& vertex, float*& uvs, float*& normals, unsigned int*& index) const;
-       void genBuffer(unsigned int &buffer, unsigned int size, void* value) const;
-       void bindBuffer(unsigned int &buffer, const string&, unsigned int dim = 3) const;
-
-       void initModel(const string& _modelpath);
-
-       //VIEWPERSPECTIVE  -----------------------------------------
-       unsigned int viewID=-1, projectionID=-1;
-
-};
-
-
-
-//DEFINE DEFAULT KONSTRUKTORS
-
-#define PERF_KUH "../shader/basicTexture_VS.hlsl", "../shader/lightingTexture_FS.hlsl","../models/cow/cow.dae"
-#define PERF_SPHERE "../shader/basicTexture_VS.hlsl", "../shader/lightingTexture_FS.hlsl","../models/sphere/sphere.dae"
-#define PERF_BOX "../shader/basicTexture_VS.hlsl", "../shader/lightingTexture_FS.hlsl","../models/box/box.dae"
-
-#define PERF_SKY
\ No newline at end of file
index 669268cdc19fa1e69591b8fb614e55006df39408..98e099751b0b9685bde13226eb8c97d601d61a3e 100644 (file)
@@ -10,8 +10,6 @@
 
 #include "Shader.h"
 
-#include "Setting.h"
-
 /*
 Scene::Scene() : 
        SceneObjects(new list<SceneObject*>),
@@ -76,6 +74,30 @@ void Scene::update(float deltaT)
        vec3 pos;
        //Focus auf Player
 
+
+       if (lookat->getMatter()<1e-2)
+       {
+               Message::error("GameOver");
+       }
+       int move_x = Events::getMouseX();
+       int move_y = Events::getMouseY();
+       int shoot = Events::getAction1();
+       int reset = Events::getAction2();
+
+       //cout << move_x << "      " << move_y << endl;
+
+       if (move_x)
+               lookat->turn(0.3f *move_x, vec3(0.f, 1.f, 0.f));
+       if (move_y)
+               lookat->turn(0.3f *move_y, vec3(1.f, 0.f, 0.f));
+       if (shoot)
+       {
+               vec3 direction = lookat->push(vec3(0.f, 0.f, shoot*0.1f));
+               //SceneObjects->push_back(self->copy();)
+       }
+       if (reset)
+               lookat->stop();
+
        // XYAchse um den Player
        if (Events::getViewX() || Events::getViewY())
        {
@@ -137,6 +159,7 @@ void Scene::update(float deltaT)
 
        if (lookat != NULL)
                view = translate(view,pos - lookat->getPosition());
+
 }
 
 void Scene::draw() const
@@ -146,8 +169,8 @@ void Scene::draw() const
        for (auto i = ShaderSet->cbegin(); i != ShaderSet->cend(); ++i)
        {
                (*i)->useShader();
-               glUniformMatrix4fv(glGetUniformLocation((*i)->getHandle(), "projection"), 1, false, value_ptr(projection));
-               glUniformMatrix4fv(glGetUniformLocation((*i)->getHandle(), "view"), 1, false, value_ptr(view));
+               glUniformMatrix4fv((*i)->getUniformLocation("projection"), 1, false, value_ptr(projection));
+               glUniformMatrix4fv((*i)->getUniformLocation("view"), 1, false, value_ptr(view));
        }
        
 
@@ -174,7 +197,7 @@ void Scene::draw() const
 void Scene::addObject(SceneObject* _add)
 {
        SceneObjects->push_back(_add);
-       ShaderSet->insert(_add->getShader());
+//     ShaderSet->insert(_add->getShader());
        _add->setMainScene(this);
 }
 
@@ -193,10 +216,10 @@ list<SceneObject*>* Scene::getSceneObjects()
        return SceneObjects;
 }
 
-void Scene::setProjection(mat4 _projection)
-{
-       projection = _projection;
-}
+//void Scene::setProjection(mat4 _projection)
+//{
+//     projection = _projection;
+//}
 
 void Scene::setProjection(float fovy, float aspect, float zNear, float zFar)
 {
index e3222872fecb7e207820f132118ba9f6c7ac1d2a..cb4ca4a503bd3ae8d9782d52a390a28af696c19e 100644 (file)
@@ -35,7 +35,7 @@ public:
 
        void setViewPort(unsigned int, unsigned int, unsigned int, unsigned int);
 
-       void setProjection(mat4 _projection);
+//     void setProjection(mat4 _projection);
        void setProjection(float fovy, float aspect, float zNear, float zFar);
        //void updateProjection(mat4);
 
index 8c3b8bfa93ab7af0eb26d7fa81e0083f71f00cc5..3835ffad446055f2cafcbd55be90cd185a6a9468 100644 (file)
@@ -5,11 +5,9 @@
 
 #include "../Message.h"
 #include <string>
-#include "../ArtificialI.h"
 
 #include <iostream>
 
-#include "../Intelligenz.h"
 #include "Shader.h"
 #include "Scene.h"
 #include "Texture.h"
@@ -23,40 +21,37 @@ using std::string;
 using std::cout;
 using std::endl;
 
-SceneObject::SceneObject(Shader* _shader, mat4& _model, string _modelpath, string texturepath, float _matter, float _speed, float _atack, vec3& _direction, Intelligenz* _will, bool _invert) :
-Model(_modelpath, _shader, _invert),
+SceneObject::SceneObject(Shader* _shader, mat4& _model, string _modelpath, string texturepath, float _matter, float _speed, float _atack, vec3& _direction) :
+Model(_modelpath),
 model(_model),
+shader(_shader),
 speed(_speed),
 matter(_matter),
 atack(_atack),
 spin(1.0f),
 direction(_direction),
-will(_will),
 matterDiff(0),
 mainScene(NULL),
 collision_ignore(false),
-invert(_invert),
 isenemy(false),
 texture(nullptr)
 {
-       modelID = glGetUniformLocation(shader->getHandle(), "model");
+       modelID = _shader->getUniformLocation("model");
        model = scale(model, vec3(pow(matter,1./3)));
        if (texturepath!="")
                texture = new Texture(texturepath);
+
+       bindShader(shader);
 }
 
 
 SceneObject::~SceneObject()
 {
-       //if (will!=NULL)
-               delete will;
 //             delete texture;
 }
 
 void SceneObject::update(float deltaT)
 {
-       if (will!=NULL)
-               will->update(deltaT);
 
        //Direction & Speed
        model = translate(deltaT * speed * direction)*model;
@@ -96,17 +91,17 @@ void SceneObject::update(float deltaT)
 
 void SceneObject::draw() const
 {
-       useModel();
+       useModel(shader);
 
        if (texture!=nullptr)
        {
                int unit = 0;
                texture->bind(unit);
-               glUniform1i(glGetUniformLocation(*shader, "ColorTexture"), unit);
+               glUniform1i(shader->getUniformLocation("ColorTexture"), unit);
        }
        glUniformMatrix4fv(modelID, 1, GL_FALSE, value_ptr(model));
 
-       glUniform1i(glGetUniformLocation(*shader, "inv"), invert ? -1 : 1);
+//     glUniform1i(shader->getUniformLocation ("inv"), invert ? -1 : 1);
        
        drawModel();
 }
@@ -145,16 +140,16 @@ vec3 SceneObject::push(vec3& _direction, float _matter)
        float dir_len = VektorAbs(_direction);
        if (dir_len > 0)
        {
-               SceneObject* copy = this->copy();
-               mainScene->addObject(copy);
-               copy->setModel(translate(getPosition() - direct * (float)(1.25*pow(matter*_matter, 1. / 3) + pow(matter, 1. / 3))));
-               copy->direction = direct * dir_len / -_matter;
-               copy->setMatter(_matter*matter*.1);
-               copy->matterDiff = _matter*matter*.9;
-               copy->setEnemy(true);
+               //SceneObject* copy = this->copy();
+               //mainScene->addObject(copy);
+               //copy->setModel(translate(getPosition() - direct * (float)(1.25*pow(matter*_matter, 1. / 3) + pow(matter, 1. / 3))));
+               //copy->direction = direct * dir_len / -_matter;
+               //copy->setMatter(_matter*matter*.1);
+               //copy->matterDiff = _matter*matter*.9;
+               //copy->setEnemy(true);
 
-               delete copy->texture;
-               copy->texture = new Texture("../Textures/enemy.png");
+               //delete copy->texture;
+               //copy->texture = new Texture("../Textures/enemy.png");
 
                direction += direct * dir_len;
                matterDiff -= _matter * matter;
@@ -190,25 +185,18 @@ void SceneObject::setCollision(bool _col)
 }
 
 
-bool SceneObject::operator==(SceneObject _ref)
-{
-       return (this == &_ref);
-}
-
-SceneObject* SceneObject::copy()
-{
-       return new SceneObject(shader, model,modelpath, *texture);
-}
+//bool SceneObject::operator==(SceneObject _ref)
+//{
+//     return (this == &_ref);
+//}
 
+//SceneObject* SceneObject::copy()
+//{
+//     return new SceneObject(shader, model, modelpath, *texture);
+//}
+//
 
 
-
-
-void SceneObject::setIntelligenz(Intelligenz* _intelligenz)
-{
-       will = _intelligenz;
-}
-
 float SceneObject::getMatter()
 {
        return matter;
index 030010e684258b31417c407aac27fc73d1fa3dbe..aea26ab95345191637a5da062afa0ebde02da6a9 100644 (file)
@@ -10,8 +10,8 @@
 using std::string;
 
 class Scene;
-class Intelligenz;
 class Texture;
+class Shader;
 
 //class string;
 
@@ -22,7 +22,7 @@ class SceneObject :
 public:
 
        //SceneObject(Shader* _shader, mat4& model);
-       SceneObject(Shader* _shader, mat4& model, string modelpath, string texturepath, float matter= 1.f, float speed= 1.f, float atack= 1.f, vec3& direction= vec3(0.f), Intelligenz* _will = NULL,bool invert=false);
+       SceneObject(Shader* _shader, mat4& model, string modelpath, string texturepath, float matter= 1.f, float speed= 1.f, float atack= 1.f, vec3& direction= vec3(0.f));
        virtual ~SceneObject();
 
        virtual void update(float);
@@ -40,9 +40,7 @@ public:
        virtual void setModel(mat4&);
        virtual void turn(float, vec3&);
 
-       virtual bool operator==(SceneObject);
-
-       void setIntelligenz(Intelligenz*);
+       //virtual bool operator==(SceneObject);
 
        void setMainScene(Scene *);
 
@@ -63,23 +61,21 @@ protected:
 
        void setMatter(float);
 
-       Intelligenz* will;
-
        mat4 model;
        unsigned int modelID;
 
+       Shader* shader;
+
        Scene* mainScene;
 
        bool collision_ignore;
 
-       virtual SceneObject* copy();
+       //virtual SceneObject* copy();
 
        float matter;
        float speed;
        float atack;
 
-       bool invert;
-
        float matterDiff;
 
        vec3 direction;
diff --git a/Weave/Graphix/Setting.cpp b/Weave/Graphix/Setting.cpp
deleted file mode 100644 (file)
index 83336dd..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "Setting.h"
-
-#include "Act.h"
-#include "Performer.h"
-
-#include "GLM.h"
-
-#include <list>
-
-using std::list;
-
-Setting::Setting() :viewMatrix(mat4(1)), projectionMatrix(mat4(1))
-{
-       
-}
-
-
-Setting::~Setting()
-{
-       cleanAct();
-       //clearPerformers
-}
-
-
-void Setting::setView(mat4 _view)
-{
-       viewMatrix = _view;
-}
-
-void Setting::setProjection(mat4 _projection)
-{
-       projectionMatrix = _projection;
-}
-
-void Setting::setProjection(float fovy, float aspect, float zNear, float zFar)
-{
-       projectionMatrix = perspective(fovy, aspect, zNear, zFar);
-}
-
-mat4 const Setting::getViewMatrix() const
-{
-       return viewMatrix;
-}
-
-
-Act* Setting::newAct()
-{
-       Act* _new = new Act(nullptr,mat4(1));
-       // Act in actLIST einhängen
-
-       actList.push_back(_new);
-
-       return _new;
-}
-
-void Setting::deleteAct(Act* _del)
-{
-       actList.remove(_del);
-       delete _del;
-}
-
-void Setting::cleanAct()
-{
-       actList.clear();
-}
-
-void Setting::draw()
-{
-
-       //update PerformerStuff
-       for (auto i = performerList.begin(); i == performerList.end(); ++i)
-       {
-               i->second->upgradePerspective(viewMatrix, projectionMatrix);
-       }
-
-       //frustumCULLING
-       mat4 perspective = projectionMatrix*viewMatrix;
-       for (auto i = actList.begin(); i == actList.end(); ++i)
-       {
-               (*i)->updateBoxPos(perspective);
-
-       }
-
-       //sort ActLIST
-       actList.sort(
-               [this](const Act* _act1, const Act* _act2)
-               {
-                       mat4 tmp = getViewMatrix();
-                       return dot((vec3)(tmp[4]) - (vec3)(_act1->getModelMatrix()[4]), (vec3)tmp[3])
-                                       > dot((vec3)(tmp[4]) - (vec3)(_act2->getModelMatrix()[4]),(vec3)tmp[3]);
-               }
-       );      //sortiere nach Entfernung
-
-       //draw ActLIST
-       for (auto i = actList.cbegin(); i == actList.cend(); ++i)
-       {
-               //filter....
-               (*i)->draw();
-       }
-
-}
\ No newline at end of file
diff --git a/Weave/Graphix/Setting.h b/Weave/Graphix/Setting.h
deleted file mode 100644 (file)
index ee17664..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#pragma once
-
-#include "GLM.h"
-
-#include <string>
-#include <unordered_map>
-#include <list>
-
-class Act;
-class Performer;
-class Texture;
-
-using std::string;
-using std::unordered_map;
-using std::list;
-
-typedef unordered_map<unsigned int, Performer*> id2performer;
-typedef unordered_map<unsigned int, Texture*> id2texture;
-
-class Setting
-{
-public:
-       Setting();
-       ~Setting();
-
-       void setView(mat4 matrix);
-       void setProjection(mat4 matrix);
-       void setProjection(float fovy, float aspect, float zNear, float zFar);
-
-       mat4 const getViewMatrix() const;
-
-       //Prepare Setting for Draw
-       Act* newAct();
-       void deleteAct(Act*);
-       void cleanAct();
-
-       void draw();
-
-private:
-
-       mat4 viewMatrix;
-       mat4 projectionMatrix;
-
-       //lichtquellen
-
-       //ShaderLIST
-       id2performer performerList;
-
-       //Texturen
-       id2texture textureList;
-       
-       //ActLIST
-       list<Act*> actList;
-};
index 96de52a2b5b50185e2f1d627f514e84c3bce8b49..dff77f4c35fc33226eaea422753cd43d2a596721 100644 (file)
@@ -6,14 +6,10 @@
 
 using namespace std;
 
-//GLuint loadShader(string& _shaderPath);
-//GLuint loadProgram(GLuint _shader1, GLuint _shader2);
-
-
 Shader::Shader(string _shader1, string _shader2)
 {
-       GLuint handleS1 = loadShader(_shader1);
-       GLuint handleS2 = loadShader(_shader2);
+       GLuint handleS1 = loadShader("../shader/"+_shader1);
+       GLuint handleS2 = loadShader("../shader/"+_shader2);
 
        handle = loadProgram(handleS1, handleS2);
 
@@ -34,6 +30,24 @@ void Shader::useShader() const
        glUseProgram(handle);
 }
 
+GLuint Shader::getAttribLocation(const string& name) const
+{
+       GLuint ind = glGetAttribLocation(handle, name.c_str());
+       if (ind < 0)
+               Message::info("GL_GetAttLoc: Kann '" + name + "' nicht finden.");
+
+       return ind;
+}
+
+GLuint Shader::getUniformLocation(const string& name) const
+{
+       GLuint ind = glGetUniformLocation(handle, name.c_str());
+       if (ind < 0)
+               Message::info("GL_GetUniLoc: Kann '" + name + "' nicht finden.");
+
+       return ind;
+}
+
 GLuint Shader::getHandle() const
 {
        return handle;
index 34d9bdfb14bb4fc5f4c80aaf8c12d23b543374ba..3c580302c0adcf1a945316b414d540177322f5ef 100644 (file)
@@ -13,6 +13,8 @@ public:
 
        void useShader() const;
 
+       unsigned int getAttribLocation(const string& name) const;
+       unsigned int getUniformLocation(const string& name) const;
        unsigned int getHandle() const;
        operator unsigned int() const;
 
index 0c1974dcd9b5cb8d1db3e7f03f8517648d525992..9b329614c8173ca9ff5e2b3a51d718b840cc1dbe 100644 (file)
@@ -28,7 +28,7 @@ Texture::Texture(const string& _path) : path(_path)
                system("pause");
                exit(-1);
        }
-       FIBITMAP* data = FreeImage_Load(format, path.c_str());
+       FIBITMAP* data = FreeImage_Load(format, ("../textures/" + path).c_str());
        if (!data)
        {
                cout << "Couldn't read texture file." << endl;
diff --git a/Weave/PlayerI.cpp b/Weave/PlayerI.cpp
deleted file mode 100644 (file)
index eadd870..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "PlayerI.h"
-
-#include "Graphix\SceneObject.h"
-#include "Events.h"
-#include "Message.h"
-
-
-PlayerI::PlayerI(SceneObject* _self) : Intelligenz(_self)
-{
-}
-
-
-PlayerI::~PlayerI()
-{
-}
-
-
-void PlayerI::update(float deltaT)
-{
-       if (self->getMatter()<1e-2)
-       {
-               Message::error("GameOver");
-       }
-       int move_x = Events::getMoveX();
-       int move_y = Events::getMoveY();
-       int shoot = Events::getAction1();
-       int reset = Events::getAction2();
-
-       //cout << move_x << "      " << move_y << endl;
-
-       if (move_x)
-               self->turn(0.3f *move_x, vec3(0.f, 1.f, 0.f));
-       if (move_y)
-               self->turn(0.3f *move_y, vec3(1.f, 0.f, 0.f));
-       if (shoot)
-       {
-               vec3 direction = self->push(vec3(0.f, 0.f, shoot*0.1f));
-               //SceneObjects->push_back(self->copy();)
-       }
-       if (reset)
-               self->stop();
-}
\ No newline at end of file
diff --git a/Weave/PlayerI.h b/Weave/PlayerI.h
deleted file mode 100644 (file)
index b77f6b6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-
-class PlayerI :
-       public Intelligenz
-{
-public:
-       PlayerI(SceneObject*);
-       ~PlayerI();
-
-       void update(float);
-
-       SceneObject* self;
-       list<SceneObject*>* SceneObjects;
-
-};
-
index 7cd19c76a19cd9de1fe8e583a1cc9872988d9db7..58525c7dc9177ccc95fa78e4b45e76e131c8bba9 100644 (file)
   <ItemGroup>
     <ClCompile Include="Events.cpp" />
     <ClCompile Include="Fps.cpp" />
+    <ClCompile Include="Game.cpp" />
+    <ClCompile Include="Graphix\Drawable.cpp" />
     <ClCompile Include="Graphix\GLM.cpp" />
     <ClCompile Include="Graphix\Graphix.cpp" />
+    <ClCompile Include="Graphix\Model.cpp" />
+    <ClCompile Include="Graphix\Scene.cpp" />
+    <ClCompile Include="Graphix\SceneObject.cpp" />
+    <ClCompile Include="Graphix\Shader.cpp" />
+    <ClCompile Include="Graphix\Texture.cpp" />
+    <ClCompile Include="Graphix\ViewPort.cpp" />
     <ClCompile Include="main.cpp" />
     <ClCompile Include="Message.cpp" />
   </ItemGroup>
     <ClInclude Include="Average.h" />
     <ClInclude Include="Events.h" />
     <ClInclude Include="Fps.h" />
+    <ClInclude Include="Game.h" />
+    <ClInclude Include="Graphix\Drawable.h" />
     <ClInclude Include="Graphix\GLM.h" />
     <ClInclude Include="Graphix\Graphix.h" />
+    <ClInclude Include="Graphix\Model.h" />
+    <ClInclude Include="Graphix\Scene.h" />
+    <ClInclude Include="Graphix\SceneObject.h" />
+    <ClInclude Include="Graphix\Shader.h" />
+    <ClInclude Include="Graphix\Texture.h" />
+    <ClInclude Include="Graphix\ViewPort.h" />
     <ClInclude Include="Message.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
index 3268ef89d75f040a1acf01558479783366a9d376..47bc0402abbe0f1133cc72f434ef2701205768e1 100644 (file)
     <ClCompile Include="Graphix\GLM.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Graphix\Shader.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Graphix\Drawable.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Graphix\Texture.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Graphix\ViewPort.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Graphix\Model.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Game.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Graphix\Scene.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Graphix\SceneObject.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Fps.h">
     <ClInclude Include="Graphix\GLM.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Graphix\Shader.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Graphix\Drawable.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Graphix\Texture.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Graphix\ViewPort.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Graphix\Model.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Game.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Graphix\Scene.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Graphix\SceneObject.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>
\ No newline at end of file
index 8797643a666f9e5f0770e896bb615d7d9f897237..76cd9e74f72dd1483285beb7cb121422f03d6993 100644 (file)
@@ -23,7 +23,7 @@
 
 //#include "Fps.h"
 
-//#include "Game.h"
+#include "Game.h"
 
 //using std::cout;
 //using std::endl;
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
 {      
        Graphix::init();
 
-//     Game spiel1;
+       Game spiel1;
 
 //     spiel1.play();
 
index cdaec66ed60063a0c4532e97497001a08148462a..ccb912174f729f5fd917bf0e102f40c68fad99c2 100644 (file)
Binary files a/bin/assimp.dll and b/bin/assimp.dll differ
diff --git a/lib/x64/SDL2.dll b/lib/x64/SDL2.dll
deleted file mode 100644 (file)
index a65b22c..0000000
Binary files a/lib/x64/SDL2.dll and /dev/null differ
diff --git a/lib/x86/SDL2.dll b/lib/x86/SDL2.dll
deleted file mode 100644 (file)
index 18d707f..0000000
Binary files a/lib/x86/SDL2.dll and /dev/null differ