Skip to content

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:

cpp
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 ​

cpp
VisualMeshBuilder(
    RayraiWindow &renderer,
    std::string name,
    std::string meshFile)

Parameters

ParameterDescription
rendererRenderer that add() creates the visual in (not owned).
nameVisual name (must be unique).
meshFileMesh file path.

Public member functions ​

scale ​

cpp
VisualMeshBuilder &scale(const glm::dvec3 &s)

Per-axis mesh scale (default 1).

Parameters

ParameterDescription
sScale.

Returns *this.

cpp
VisualMeshBuilder &scale(double x, double y, double z)

Per-axis mesh scale.

Parameters

ParameterDescription
xX scale.
yY scale.
zZ scale.

Returns *this.

color ​

cpp
VisualMeshBuilder &color(const glm::vec4 &c)

RGBA color in [0, 1] (default white).

Parameters

ParameterDescription
cColor.

Returns *this.

position ​

cpp
VisualMeshBuilder &position(const glm::vec3 &p)

World-space position.

Parameters

ParameterDescription
pPosition in metres.

Returns *this.

orientation ​

cpp
VisualMeshBuilder &orientation(const glm::quat &q)

World-space orientation.

Parameters

ParameterDescription
qUnit quaternion.

Returns *this.

twoSided ​

cpp
VisualMeshBuilder &twoSided(bool enabled=true)

Disable back-face culling.

Parameters

ParameterDescription
enabledFlag.

Returns *this.

pickable ​

cpp
VisualMeshBuilder &pickable(bool enabled=true)

Sets Visuals::setDetectable(), which controls picking and visibility in sensor-style captures.

Parameters

ParameterDescription
enabledFlag.

Returns *this.

castsShadows ​

cpp
VisualMeshBuilder &castsShadows(bool enabled=true)

Whether the visual casts shadows.

Parameters

ParameterDescription
enabledFlag.

Returns *this.

useMeshColor ​

cpp
VisualMeshBuilder &useMeshColor(bool enabled)

Use the mesh file's own colors instead of color().

Parameters

ParameterDescription
enabledFlag.

Returns *this.

material ​

cpp
VisualMeshBuilder &material(std::shared_ptr<Material> m)

Material override shared with the caller.

Parameters

ParameterDescription
mMaterial.

Returns *this.

cpp
VisualMeshBuilder &material(const Material &m)

Material override (copied).

Parameters

ParameterDescription
mMaterial.

Returns *this.

pbrEnvironment ​

cpp
VisualMeshBuilder &pbrEnvironment(const PbrEnvironment &env)

Image-based lighting maps for the visual.

Parameters

ParameterDescription
envEnvironment.

Returns *this.

add ​

cpp
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).

RaiSim — physics for robotics and AI.