raisin::RayraiWindow::VisualMeshBuilder
class · #include <rayrai/RayraiWindow.hpp>
Fluent builder for addVisualMesh.
Collects scale/position/orientation/material and flags up front; add() creates the visual via the corresponding addVisualMesh overload, then applies the deferred state via the existing setters and returns the shared_ptr<Visuals>. Setters on the returned visual still work for runtime mutations after creation.
Example:
auto v = renderer.makeVisualMesh("rusty", path)
.scale({1.0, 1.0, 1.0})
.position({0.0, 0.0, 0.5})
.orientation(glm::angleAxis(0.4f, glm::vec3{0, 0, 1}))
.twoSided(true)
.pickable(true)
.castsShadows(true)
.material(rusty)
.pbrEnvironment(env)
.add();Only options that were set are applied. The builder stores a raw pointer to the renderer, which must outlive it.
Constructors & destructor
VisualMeshBuilder
VisualMeshBuilder(
RayraiWindow &renderer,
std::string name,
std::string meshFile)Parameters
| Parameter | Description |
|---|---|
renderer | Renderer that add() creates the visual in (not owned). |
name | Visual name (must be unique). |
meshFile | Mesh file path. |
Public member functions
scale
VisualMeshBuilder &scale(const glm::dvec3 &s)Per-axis mesh scale (default 1).
Parameters
| Parameter | Description |
|---|---|
s | Scale. |
Returns *this.
VisualMeshBuilder &scale(double x, double y, double z)Per-axis mesh scale.
Parameters
| Parameter | Description |
|---|---|
x | X scale. |
y | Y scale. |
z | Z scale. |
Returns *this.
color
VisualMeshBuilder &color(const glm::vec4 &c)RGBA color in [0, 1] (default white).
Parameters
| Parameter | Description |
|---|---|
c | Color. |
Returns *this.
position
VisualMeshBuilder &position(const glm::vec3 &p)World-space position.
Parameters
| Parameter | Description |
|---|---|
p | Position in metres. |
Returns *this.
orientation
VisualMeshBuilder &orientation(const glm::quat &q)World-space orientation.
Parameters
| Parameter | Description |
|---|---|
q | Unit quaternion. |
Returns *this.
twoSided
VisualMeshBuilder &twoSided(bool enabled=true)Disable back-face culling.
Parameters
| Parameter | Description |
|---|---|
enabled | Flag. |
Returns *this.
pickable
VisualMeshBuilder &pickable(bool enabled=true)Sets Visuals::setDetectable(), which controls picking and visibility in sensor-style captures.
Parameters
| Parameter | Description |
|---|---|
enabled | Flag. |
Returns *this.
castsShadows
VisualMeshBuilder &castsShadows(bool enabled=true)Whether the visual casts shadows.
Parameters
| Parameter | Description |
|---|---|
enabled | Flag. |
Returns *this.
useMeshColor
VisualMeshBuilder &useMeshColor(bool enabled)Use the mesh file's own colors instead of color().
Parameters
| Parameter | Description |
|---|---|
enabled | Flag. |
Returns *this.
material
VisualMeshBuilder &material(std::shared_ptr<Material> m)Material override shared with the caller.
Parameters
| Parameter | Description |
|---|---|
m | Material. |
Returns *this.
VisualMeshBuilder &material(const Material &m)Material override (copied).
Parameters
| Parameter | Description |
|---|---|
m | Material. |
Returns *this.
pbrEnvironment
VisualMeshBuilder &pbrEnvironment(const PbrEnvironment &env)Image-based lighting maps for the visual.
Parameters
| Parameter | Description |
|---|---|
env | Environment. |
Returns *this.
add
std::shared_ptr<Visuals> add()Create the visual, apply the deferred state, return the shared_ptr.
Returns The new visual (the name must be unique, RSFATAL otherwise).