Skip to main content

MeshRenderableConfig Class

Fluent configuration for setting up a Renderable on a GameObject. More...

Declaration

class helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig { ... }

Public Constructors Index

MeshRenderableConfig (helios::engine::ecs::GameObject gameObject)

Constructs a MeshRenderableConfig for the given GameObject. More...

Public Member Functions Index

MeshRenderableConfig &shape (std::shared_ptr< helios::rendering::asset::shape::Shape > shape)

Sets the shape geometry. More...

MeshRenderableConfig &shader (std::shared_ptr< helios::ext::opengl::rendering::shader::OpenGLShader > shader)

Sets the shader program. More...

MeshRenderableConfig &primitiveType (helios::rendering::mesh::PrimitiveType primitiveType)

Sets the primitive type for rendering. More...

MeshRenderableConfig &color (const helios::math::vec4f color)

Sets the base color for the material. More...

voidattachTo (helios::scene::SceneNode *parent)

Builds the renderable and attaches it to a scene node. More...

MeshRenderableConfig &build ()

Builds and attaches the RenderableComponent. More...

Private Member Attributes Index

helios::engine::ecs::GameObjectgameObject_

Non-owning pointer to the target GameObject. More...

std::shared_ptr< helios::rendering::asset::shape::Shape >shape_

The shape geometry to render. More...

std::shared_ptr< helios::ext::opengl::rendering::shader::OpenGLShader >shader_

The shader for rendering. More...

helios::rendering::mesh::PrimitiveTypeprimitiveType_

The primitive type for mesh rendering. More...

helios::math::vec4fcolor_

The base color for the material. More...

Private Static Functions Index

static std::shared_ptr< helios::rendering::mesh::MeshConfig >meshConfig (helios::rendering::mesh::PrimitiveType primitiveType)

Private Static Attributes Index

static std::unordered_map< helios::rendering::mesh::PrimitiveType, std::shared_ptr< helios::rendering::mesh::MeshConfig > >meshConfigs_

Description

Fluent configuration for setting up a Renderable on a GameObject.

Allows specification of shape, shader, primitive type, and color. Builds and attaches a RenderableComponent.

Definition at line 32 of file MeshRenderableConfig.ixx.

Public Constructors

MeshRenderableConfig()

helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::MeshRenderableConfig (helios::engine::ecs::GameObject gameObject)
inline explicit

Constructs a MeshRenderableConfig for the given GameObject.

Parameters
<a href="/docs/helios/namespaces/helios/engine/builder/gameobject">gameObject</a>

Target GameObject to configure.

Definition at line 81 of file MeshRenderableConfig.ixx.

Referenced by build, color, primitiveType, shader and shape.

Public Member Functions

attachTo()

void helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::attachTo (helios::scene::SceneNode * parent)
inline

Builds the renderable and attaches it to a scene node.

Parameters
parent

Parent SceneNode for the new node.

Definition at line 142 of file MeshRenderableConfig.ixx.

143
144 build();
145
146 SceneNodeConfig scn{gameObject_};
147
148 scn.parent(parent);
149 }

References build and helios::engine::builder::gameObject::builders::configs::SceneNodeConfig::parent.

build()

MeshRenderableConfig & helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::build ()
inline

Builds and attaches the RenderableComponent.

Returns

Reference to this config for chaining.

Definition at line 156 of file MeshRenderableConfig.ixx.

157
158 assert(shape_ && shader_ && "Unexpected missing shape and/or shader");
159
160 auto mesh = std::make_shared<helios::ext::opengl::rendering::model::OpenGLMesh>(
161 *shape_,
162 std::move(MeshRenderableConfig::meshConfig(primitiveType_))
163 );
164
165 auto materialProperties = std::make_shared<helios::rendering::material::MaterialShaderProperties>(color_);
166 auto material = std::make_shared<helios::rendering::material::Material>(shader_, materialProperties);
167
168 const auto renderPrototype = std::make_shared<helios::rendering::RenderPrototype>(material, mesh);
169
171 std::make_shared<helios::rendering::mesh::MeshRenderable>(renderPrototype)
172 );
173
175 msc.setAabb(rc.renderable().localAABB());
176
177 return *this;
178 }

Reference MeshRenderableConfig.

Referenced by attachTo.

color()

MeshRenderableConfig & helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::color (const helios::math::vec4f color)
inline

Sets the base color for the material.

Parameters
color

RGBA color vector.

Returns

Reference to this config for chaining.

Definition at line 131 of file MeshRenderableConfig.ixx.

132 color_ = color;
133
134 return *this;
135 }

References color and MeshRenderableConfig.

Referenced by color.

primitiveType()

MeshRenderableConfig & helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::primitiveType (helios::rendering::mesh::PrimitiveType primitiveType)
inline

Sets the primitive type for rendering.

Parameters
primitiveType

The OpenGL primitive type.

Returns

Reference to this config for chaining.

Definition at line 118 of file MeshRenderableConfig.ixx.

References MeshRenderableConfig and primitiveType.

Referenced by primitiveType.

shader()

MeshRenderableConfig & helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::shader (std::shared_ptr< helios::ext::opengl::rendering::shader::OpenGLShader > shader)
inline

Sets the shader program.

Parameters
shader

Shared pointer to the OpenGL shader.

Returns

Reference to this config for chaining.

Definition at line 105 of file MeshRenderableConfig.ixx.

105 MeshRenderableConfig& shader(std::shared_ptr<helios::ext::opengl::rendering::shader::OpenGLShader> shader) {
106 shader_ = shader;
107
108 return *this;
109 }

References MeshRenderableConfig and shader.

Referenced by shader.

shape()

MeshRenderableConfig & helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::shape (std::shared_ptr< helios::rendering::asset::shape::Shape > shape)
inline

Sets the shape geometry.

Parameters
shape

Shared pointer to the shape.

Returns

Reference to this config for chaining.

Definition at line 92 of file MeshRenderableConfig.ixx.

92 MeshRenderableConfig& shape(std::shared_ptr<helios::rendering::asset::shape::Shape> shape) {
93 shape_ = shape;
94
95 return *this;
96 }

References MeshRenderableConfig and shape.

Referenced by shape.

Private Member Attributes

color_

helios::math::vec4f helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::color_

The base color for the material.

Definition at line 57 of file MeshRenderableConfig.ixx.

gameObject_

helios::engine::ecs::GameObject helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::gameObject_

Non-owning pointer to the target GameObject.

Definition at line 37 of file MeshRenderableConfig.ixx.

primitiveType_

helios::rendering::mesh::PrimitiveType helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::primitiveType_

The primitive type for mesh rendering.

Definition at line 52 of file MeshRenderableConfig.ixx.

shader_

std::shared_ptr<helios::ext::opengl::rendering::shader::OpenGLShader> helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::shader_

The shader for rendering.

Definition at line 47 of file MeshRenderableConfig.ixx.

47 std::shared_ptr<helios::ext::opengl::rendering::shader::OpenGLShader> shader_;

shape_

std::shared_ptr<helios::rendering::asset::shape::Shape> helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::shape_

The shape geometry to render.

Definition at line 42 of file MeshRenderableConfig.ixx.

42 std::shared_ptr<helios::rendering::asset::shape::Shape> shape_;

Private Static Functions

meshConfig()

std::shared_ptr< helios::rendering::mesh::MeshConfig > helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::meshConfig (helios::rendering::mesh::PrimitiveType primitiveType)
inline static

Definition at line 64 of file MeshRenderableConfig.ixx.

64 static std::shared_ptr<helios::rendering::mesh::MeshConfig> meshConfig(helios::rendering::mesh::PrimitiveType primitiveType) {
65
66 auto [it, inserted] = meshConfigs_.try_emplace(
68 std::make_shared<helios::rendering::mesh::MeshConfig>(primitiveType)
69 );
70
71 return it->second;
72 }

Private Static Attributes

meshConfigs_

std::unordered_map< helios::rendering::mesh::PrimitiveType, std::shared_ptr<helios::rendering::mesh::MeshConfig> > helios::engine::builder::gameObject::builders::configs::MeshRenderableConfig::meshConfigs_
static

Definition at line 62 of file MeshRenderableConfig.ixx.

62 > meshConfigs_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.