#include "phongentity.h" #include "shader.h" #include #include "material.h" #include "mesh.h" PhongEntity::PhongEntity(Mesh* myMesh, Material* myMat) : mesh(myMesh), mat(myMat) {} void PhongEntity::draw(const glm::mat4 viewMatrix, const glm::mat4 projectionMatrix) { glm::mat4 modelViewMatrix = viewMatrix * modelMatrix; glm::mat4 mvp = projectionMatrix * modelViewMatrix; glm::mat4 normalMatrix = glm::transpose(glm::inverse(modelViewMatrix)); mat->bindAttributes(); Shader* shader = mat->getShader(); shader->bindMatrix(shader->getLocation("viewMatrix"), viewMatrix); shader->bindMatrix(shader->getLocation("modelViewMatrix"), modelViewMatrix); shader->bindMatrix(shader->getLocation("normalMatrix"), normalMatrix); shader->bindMatrix(shader->getLocation("MVP"), mvp); mesh->draw(); } glm::mat4* PhongEntity::getTransform() { return &modelMatrix; } Shader* PhongEntity::getShader() { return mat->getShader(); } Material* PhongEntity::getMaterial() { return mat; }