1#ifndef OE_RENDER_MESH_RENDERER_H
2#define OE_RENDER_MESH_RENDERER_H
4#include "../scene/node.h"
6#include "../scene/material.h"
7#include "../scene/camera.h"
10#include "shader_base.h"
16 std::vector<bool> enabled_primitives;
27 template <
typename BaseMeshType>
32 node->raw_aabb = scene_mesh.getBoundingBox();
51 const auto primitives_count =
render_mesh.primitives.size();
52 assert(primitives_count > 0);
67 const size_t material_count =
materials.size();
76 result.reserve(material_count);
78 for (
auto id_material = 0u; id_material < material_count; ++id_material)
80 auto* material = &
materials.at(id_material);
82 if (material->is_blend != is_blending_pass)
106 auto model_matrix =
node->getAbsoluteModelMatrix();
107 auto normal_matrix = glm::transpose(glm::mat3(glm::inverse(camera.
getView() * model_matrix)));
109 shader->
setMat4(
"uModel", model_matrix);
110 shader->
setMat3(
"uNormalMatrix", normal_matrix);
Shader class.
Definition shader_base.h:32
void setMat3(const std::string &name, const glm::mat3 &value)
Send a 3x3 matrix uniform to the shader.
void setMat4(const std::string &name, const glm::mat4 &value)
Send a 4x4 matrix uniform to the shader.
The "eye of the scene".
Definition camera.h:31
bool isInFrustum(const glm::vec3 &point) const
Check if a point is visible from the camera point of view.
const glm::mat4 & getView() const
Get the view matrix of the camera.
Render agnostic material.
Definition material.h:90
Render related abstractions (Shader, Framebuffer, Cubemaps, Textures).
Definition opengl.h:12
GeometryPass
Vertex rendering passes.
Definition passes.h:12
@ SOLID
Definition passes.h:14
Definition mesh_renderer.h:15
void fillShader(ShaderBase *shader, const oe::scene::Camera &camera)
Send shader uniforms related to this mesh.
Definition mesh_renderer.h:104
oe::scene::NodePtr node
Related scene node.
Definition mesh_renderer.h:116
std::vector< scene::Material > materials
Distinct list of materials applied on this mesh.
Definition mesh_renderer.h:128
void addMaterial(bool assign_to_primitives=false)
Add a new material.
Definition mesh_renderer.h:49
Mesh render_mesh
Related render mesh (stored in GPU) of this renderer.
Definition mesh_renderer.h:121
bool fillRenderCommands(const scene::Camera &camera, const bool is_blending_pass, std::vector< render::DrawCommand > &result)
Generate a list of {primitives, Material*} to render this mesh.
Definition mesh_renderer.h:65
std::vector< std::vector< bool > > primitives_by_material
List to assign materials to primitives.
Definition mesh_renderer.h:137
Wrapper to a node reference to use pointers to node even if the actual node moves in memory.
Definition node_ptr.h:19