]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
material moved to texture
authorLockedLunatic <locked.lunatic@aon.at>
Sat, 2 May 2015 23:31:31 +0000 (01:31 +0200)
committerLockedLunatic <locked.lunatic@aon.at>
Sat, 2 May 2015 23:31:31 +0000 (01:31 +0200)
12 files changed:
Weave/Graphix/Model/IMesh.cpp
Weave/Graphix/Model/IMesh.h
Weave/Graphix/Model/IMetaMesh.cpp
Weave/Graphix/Model/IMetaMesh.h
Weave/Graphix/Model/Model.cpp
Weave/Graphix/Model/Model.h
Weave/Graphix/Model/SkyBox.cpp
Weave/Graphix/Model/SkyBox.h
Weave/Graphix/Texture.cpp
Weave/Graphix/Texture.h
Weave/Scene/SceneObject.cpp
Weave/Scene/SceneObject.h

index d06493d7e96794057edb52831d74315be8ce21b1..8ef5ca19affca4aa528258a49f26e07b22d2f9fd 100644 (file)
@@ -70,12 +70,6 @@ void IMesh::useModelMat(const mat4& _model, Shader* _shader) const
                glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model*glm::scale(modelScale)* modelMat));
 }
 
-//void IMesh::useMaterial(const vec4& _material, Shader* _shader) const
-//{
-//     //      Model::useMaterial(_material, _shader);
-//     Model::useMaterial(_material, _shader);
-//}
-
 //void IMesh::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const
 //{
 //
index 43ee0ac8f213a3e996a01c58ea33aff031abd140..16626ca804b59d0a6020fcbf8e656ba7a0d40887 100644 (file)
@@ -20,7 +20,6 @@ public:
        virtual ~IMesh();
 
        void useModelMat(const mat4& model, Shader* shader) const;
-//     void useMaterial(const vec4& material, Shader* shader) const;
 
        //void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const;
 
index 8515171975ee291d31745901f89a0c9fefbe0817..13da14242dbf46789c3539737056ab79644c691a 100644 (file)
@@ -76,11 +76,11 @@ void IMetaMesh::bindShader(Shader* _shader)
        }
 }
 
-void IMetaMesh::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat, const vec4& _material) const
+void IMetaMesh::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const
 {
        for (auto i = models.begin(); i != models.end(); ++i)
        {
-               (*i)->drawModel(_shader, _texture, _modelMat, _material);
+               (*i)->drawModel(_shader, _texture, _modelMat);
        }
 }
 
index 0632152ffbcd32c88bcb5e5672139a15e4304029..988877c068262eb3c460a6a1e51a58984ab226c2 100644 (file)
@@ -20,7 +20,7 @@ public:
 
        void bindShader(Shader* shader);
 
-       void drawModel(Shader* shader, Texture* texture, const mat4& modelMat, const vec4& material) const;
+       void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const;
 
        void drawBBox(Shader* shader, const mat4& modelMat) const;
 
index d13f0dd1858f7a51b40e59c44f316adb9eba6f85..5973b83ce56959f780577cd30a9e16356688b560 100644 (file)
@@ -82,7 +82,7 @@ void Model::drawModel() const
        glBindVertexArray(0);
 }
 
-void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat, const vec4& _material) const
+void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const
 {
        //Message::info("Error from before?");
        //Graphix::getGlError();
@@ -95,9 +95,6 @@ void Model::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat,
        useModelMat(_modelMat, _shader);
        //Message::info("IMesh loading MMatrix");
        //Graphix::getGlError();
-       useMaterial(_material, _shader);
-       //Message::info("IMesh loading MMatrix");
-       //Graphix::getGlError();
        drawModel();
        //Message::info("IMesh drawing Elements");
        //Graphix::getGlError();
@@ -119,7 +116,7 @@ void Model::drawBBox(Shader* _shader, const mat4& _modelMat) const
        //      BoundingBox->bindShader(_shader);
        vec3 BBsiz, BBpos;
        getBBsp(BBsiz, BBpos);
-       BoundingBox->drawModel(Graphix::shader_BBox, (Texture*)nullptr, _modelMat*translate(BBpos)*glm::scale(BBsiz), vec4(1.0f, 1.0f, 1.0f, 3.0f));
+       BoundingBox->drawModel(Graphix::shader_BBox, (Texture*)nullptr, _modelMat*translate(BBpos)*glm::scale(BBsiz));
 }
 
 void Model::updateBB(const vec3& _min, const vec3& _max)
@@ -235,6 +232,10 @@ void Model::useTexture(Texture* _texture, Shader* _shader) const
                int unit = 0;
                _texture->bind(unit);
                glUniform1i(tmp, unit);
+
+               int tmp2 = _shader->getUniformLocation("material");
+               if (tmp2 >= 0)
+                       glUniform4fv(tmp2, 1, value_ptr(_texture->material));
        }
 }
 
@@ -245,14 +246,6 @@ void Model::useModelMat(const mat4& _model, Shader* _shader) const
                glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model*glm::scale(modelScale)));
 }
 
-void Model::useMaterial(const vec4& _material, Shader* _shader) const
-{
-       int tmp = _shader->getUniformLocation("material");
-       if (tmp >= 0)
-               glUniform4fv(tmp, 1, value_ptr(_material));
-}
-
-
 void Model::isColliding(float& _overlap, float& _inside, const Model* _model, const mat4& _modelMatThis, const mat4& _modelMatOther) const
 {
        vec3 posA, sizeA, posB, sizeB;
index 034d22cf7b4c7f174d235acbd46e7790d3e29665..fec1a11133c80d4cbffbb445f4be9a8b75177e85 100644 (file)
@@ -18,7 +18,7 @@ public:
        virtual void bindShader(Shader* shader);
 
        /* Draws Model */
-       virtual void drawModel(Shader* shader, Texture* texture, const mat4& modelMat, const vec4& material) const;
+       virtual void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const;
 
        /* Draws a BoundingBox around the Model */
        virtual void drawBBox(Shader* shader, const mat4& modelMat) const;
@@ -50,7 +50,6 @@ protected:
        virtual void useModel(Shader* shader) const;
        virtual void useTexture(Texture* texture, Shader* shader) const;
        virtual void useModelMat(const mat4& model, Shader* shader) const;
-       virtual void useMaterial(const vec4& material, Shader* shader) const;
        virtual void drawModel() const;
 
        static Model* BoundingBox;
index ff7cfd55a52211e610d725bdee48bdbfa955272f..9c37e0c8861c5c0dd5538ec61a8ba7c625fed0da 100644 (file)
@@ -25,10 +25,10 @@ SkyBox::~SkyBox()
 {
 }
 
-void SkyBox::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat, const vec4& _material) const
+void SkyBox::drawModel(Shader* _shader, Texture* _texture, const mat4& _modelMat) const
 {
        glDisable(GL_DEPTH_TEST);
-       Model::drawModel(_shader, _texture, _modelMat, _material);
+       Model::drawModel(_shader, _texture, _modelMat);
        glEnable(GL_DEPTH_TEST);
 }
 
@@ -36,10 +36,6 @@ void SkyBox::useModelMat(const mat4& _model, Shader* _shader) const
 {
 }
 
-void SkyBox::useMaterial(const vec4& _material, Shader* _shader) const
-{
-}
-
 void SkyBox::useTexture(Texture* _texture, Shader* _shader) const
 {
 }
index 14da4b93a349f3afad6ca057bdb890261e86812c..5bf15525a5d63c50ed73324a056a2d5de6ae2264 100644 (file)
@@ -9,11 +9,10 @@ public:
        SkyBox();
        ~SkyBox();
 
-       void drawModel(Shader* shader, Texture* texture, const mat4& modelMat, const vec4& material) const;
+       void drawModel(Shader* shader, Texture* texture, const mat4& modelMat) const;
 
        //uncommend following lines to use default Loaders
        void useModelMat(const mat4& model, Shader* shader) const;
-       void useMaterial(const vec4& material, Shader* shader) const;
        void useTexture(Texture* texture, Shader* shader) const;
 
        void drawBBox(Shader* shader, const mat4& modelMat) const;
index 788de1fe238c6481144ef07e6a961aec70a72f99..6c19a45b46cc329ec19ab02e9c403d2709300cec 100644 (file)
@@ -2,15 +2,15 @@
 #include <GL\glew.h>
 #include "FreeImage.h"
 #include <iostream>
+#include "GLM.h"
 
 #include "../Message.h"
 #include "Graphix.h"
 
 using std::string;
 
-Texture::Texture(const string& _path) : path(_path), handle(-1), TEXTURE_TYPE(-1)
+Texture::Texture(const string& _path, const vec4& _material) : path(_path), handle(-1), TEXTURE_TYPE(-1), material(_material)
 {
-
        //Message::info("Error from before?");
        //Graphix::getGlError();
        //Message::info("Do some Stuff");
index 36ec0a0261ad1f7fe16ebd4627020717b27e307d..7137d6c6533cbee49d6777b815c35e8c0d789241 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <string>
+#include "GLM.h"
 
 
 #include <unordered_map>
@@ -14,13 +15,15 @@ typedef unordered_map<string, unsigned int> str2int_map;
 class Texture
 {
 public:
-       Texture(const string& path);
+       Texture(const string& path, const vec4& material);
        ~Texture();
 
        void bind(int unit);
 
        operator string() const;
 
+       vec4 material;
+
 private:
        unsigned int handle;
        string path;
index 81cebecc269d8ab0cab711dc6b29fb7a933e8c4e..3cfd3f8dd6f4feafe7ffdc5120ab6b5ad33bac10 100644 (file)
@@ -23,7 +23,6 @@ using std::string;
 SceneObject::SceneObject(Shader* _shader, const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath, const vec3& _scale) :
 model(nullptr),
 modelMat(_modelMat),
-material(_material),
 shader(_shader),
 mainScene(NULL),
 collision_ignore(false),
@@ -45,7 +44,7 @@ ignore(false)
        }
 
        if (texturepath != "")
-               texture = new Texture(texturepath);
+               texture = new Texture(texturepath, _material);
        //Message::info("Creating SkyBox Shader");
        //Graphix::getGlError();
 
@@ -59,7 +58,6 @@ ignore(false)
 SceneObject::SceneObject(Shader* _shader, const mat4& _modelMat, const vec4& _material, Model* _model, string texturepath) :
 model(_model),
 modelMat(_modelMat),
-material(_material),
 shader(_shader),
 mainScene(NULL),
 collision_ignore(false),
@@ -75,7 +73,7 @@ ignore(false)
        //Graphix::getGlError();
        //modelID = _shader->getUniformLocation("modelMat");
        if (texturepath != "")
-               texture = new Texture(texturepath);
+               texture = new Texture(texturepath, _material);
        //Message::info("Creating SkyBox Shader");
        //Graphix::getGlError();
 
@@ -150,7 +148,7 @@ void SceneObject::draw() const
 
        //      drawModel();
 
-       model->drawModel(shader, texture, modelMat, material);
+       model->drawModel(shader, texture, modelMat);
        if (Events::isKToggleActive(SDLK_F6))
                model->drawBBox(shader, modelMat);
 }
@@ -187,10 +185,6 @@ void SceneObject::setModel(mat4& _modelMat){
        modelMat = _modelMat;
 }
 
-void SceneObject::setMaterial(vec4& _material){
-       material = _material;
-}
-
 void SceneObject::turn(float angle, vec3& axis){
        //vec3  pos = getPosition();
        //modelMat = rotate(degree, axis)*modelMat;
index 7ad133882aabd857f52650de8960f6c592d17bdc..4fb127c6c7fc6881d71503f96139c1c74ab9abbb 100644 (file)
@@ -32,7 +32,6 @@ public:
 
        __declspec(deprecated)
        virtual void setModel(mat4&);
-       virtual void setMaterial(vec4&);
        __declspec(deprecated)
        virtual void turn(float angle, vec3& axis);
        virtual void turnTo(vec3& direction, float speed = 1);
@@ -67,7 +66,6 @@ protected:
        
 
        mat4 modelMat;
-       vec4 material;
        Shader* shader;
        Texture* texture;
        Model* model;