Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::render::MeshRenderer Struct Reference

Component that provide Mesh handling and rendering. More...

#include <OxygenEngine/render/mesh_renderer.h>

Inheritance diagram for oe::render::MeshRenderer:
Collaboration diagram for oe::render::MeshRenderer:

Public Member Functions

template<typename BaseMeshType>
 MeshRenderer (oe::scene::NodePtr &node, const BaseMeshType &scene_mesh)
void addMaterial (bool assign_to_primitives=false)
 Add a new material.
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.
void fillShader (ShaderBase *shader, const oe::scene::Camera &camera)
 Send shader uniforms related to this mesh.

Public Attributes

oe::scene::NodePtr node
 Related scene node.
Mesh render_mesh
 Related render mesh (stored in GPU) of this renderer.
std::vector< scene::Materialmaterials
 Distinct list of materials applied on this mesh.
std::vector< std::vector< bool > > primitives_by_material
 List to assign materials to primitives.

Static Public Attributes

constexpr static const oe::render::GeometryPass geometry_pass = oe::render::GeometryPass::SOLID

Detailed Description

Component that provide Mesh handling and rendering.

Member Function Documentation

◆ addMaterial()

void oe::render::MeshRenderer::addMaterial ( bool assign_to_primitives = false)
inline

Add a new material.

Add the material then init the list (by default the material will not be applied to any primitives)

Parameters
assign_to_primitivesAssign the newly created material to all primitives
Note
No material deletion method available because removal might break the ids on user side
(you can still manipulate primitives_by_material and materials yourself)

◆ fillRenderCommands()

bool oe::render::MeshRenderer::fillRenderCommands ( const scene::Camera & camera,
const bool is_blending_pass,
std::vector< render::DrawCommand > & result )
inline

Generate a list of {primitives, Material*} to render this mesh.

Returns
Does this mesh need to be rendered

◆ fillShader()

void oe::render::MeshRenderer::fillShader ( ShaderBase * shader,
const oe::scene::Camera & camera )
inline

Send shader uniforms related to this mesh.

Note
At this point the mesh is considered to be ready to be drawn, no need to add any checks :)

Member Data Documentation

◆ materials

std::vector<scene::Material> oe::render::MeshRenderer::materials

Distinct list of materials applied on this mesh.

See also
primitives_by_material to assign materials on primitives

◆ primitives_by_material

std::vector<std::vector<bool> > oe::render::MeshRenderer::primitives_by_material

List to assign materials to primitives.

Keys are material ids (ie. position in materials list) and values are primitive flags (ie. true means the corresponding primitive will be drawn using the material)

Note
Primitives assigned to multiple materials will be drawn multiple times (to let use creative effects)

The documentation for this struct was generated from the following file: