add more stuff
This commit is contained in:
40
src/MagnumDrawable.cpp
Normal file
40
src/MagnumDrawable.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "MagnumDrawable.h"
|
||||
|
||||
#include <Magnum/SceneGraph/Camera.h>
|
||||
|
||||
#include "Components.h"
|
||||
|
||||
namespace Rendering::Magnum
|
||||
{
|
||||
void Drawable::draw(const Matrix4& transformationMatrix, SceneGraph::Camera3D& camera)
|
||||
{
|
||||
const auto mesh = _registry.try_get<Components::Mesh>(_entity);
|
||||
if (!mesh) return;
|
||||
|
||||
if (const auto material = _registry.try_get<Components::Material>(_entity))
|
||||
{
|
||||
material->_shader->
|
||||
setDiffuseColor(material->phongConfig->diffuse)
|
||||
.setAmbientColor(material->phongConfig->ambient)
|
||||
.setSpecularColor(material->phongConfig->specular)
|
||||
.setShininess(material->phongConfig->shininess)
|
||||
.setLightPositions({
|
||||
{camera.cameraMatrix().transformPoint({-3.0f, 10.0f, 10.0f}), 0.0f}
|
||||
})
|
||||
.setTransformationMatrix(transformationMatrix)
|
||||
.setNormalMatrix(transformationMatrix.normalMatrix())
|
||||
.setProjectionMatrix(camera.projectionMatrix())
|
||||
.draw(*mesh->mesh);
|
||||
|
||||
if (material->texture)
|
||||
{
|
||||
material->_shader->bindDiffuseTexture(*material->texture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Have a default rendering method
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user