#include "Material.h"


Material::Material(Vec4f ambient, Vec4f diffuse, Vec4f specular, float shininess)
{
	this->ambient = ambient;
	this->diffuse = diffuse;
	this->specular = specular;
	this->shininess = shininess;
}

Material::~Material()
{

}

void Material::activate(float depth, float alpha)
{
	// dunkler machen
	Vec4f manipulate(depth, depth, depth, alpha);

	Vec4f newDiffuse = diffuse;
	Vec4f newSpecular = specular;

	newDiffuse.mult(&manipulate);
	newSpecular.mult(&manipulate);

	// grauer machen
	float greyAmbient = (ambient.x + ambient.y + ambient.z) * 0.3333;
	float greyDiffuse = (diffuse.x + diffuse.y + diffuse.z) * 0.3333;
	float greySpecular = (specular.x + specular.y + specular.z) * 0.3333;

	GLfloat amb[] = {ambient.x, ambient.y, ambient.z, 1};
	GLfloat dif[] = {newDiffuse.x, newDiffuse.y, newDiffuse.z, newDiffuse.w};
	GLfloat spe[] = {newSpecular.x, newSpecular.y, newSpecular.z, newSpecular.w};


	glMaterialfv(GL_FRONT, GL_AMBIENT, amb);

	glMaterialfv(GL_FRONT, GL_DIFFUSE, dif);

	glMaterialfv(GL_FRONT, GL_SPECULAR, spe);

	glMaterialfv(GL_FRONT, GL_SHININESS, &shininess);
}
