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
//{
//
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;
}
}
-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);
}
}
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;
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();
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();
// 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)
int unit = 0;
_texture->bind(unit);
glUniform1i(tmp, unit);
+
+ int tmp2 = _shader->getUniformLocation("material");
+ if (tmp2 >= 0)
+ glUniform4fv(tmp2, 1, value_ptr(_texture->material));
}
}
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;
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;
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;
{
}
-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);
}
{
}
-void SkyBox::useMaterial(const vec4& _material, Shader* _shader) const
-{
-}
-
void SkyBox::useTexture(Texture* _texture, Shader* _shader) const
{
}
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;
#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");
#pragma once
#include <string>
+#include "GLM.h"
#include <unordered_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;
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),
}
if (texturepath != "")
- texture = new Texture(texturepath);
+ texture = new Texture(texturepath, _material);
//Message::info("Creating SkyBox Shader");
//Graphix::getGlError();
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),
//Graphix::getGlError();
//modelID = _shader->getUniformLocation("modelMat");
if (texturepath != "")
- texture = new Texture(texturepath);
+ texture = new Texture(texturepath, _material);
//Message::info("Creating SkyBox Shader");
//Graphix::getGlError();
// drawModel();
- model->drawModel(shader, texture, modelMat, material);
+ model->drawModel(shader, texture, modelMat);
if (Events::isKToggleActive(SDLK_F6))
model->drawBBox(shader, 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;
__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);
mat4 modelMat;
- vec4 material;
Shader* shader;
Texture* texture;
Model* model;