Skip to content

Mesh

Renderable node that couples geometry with a material.

Mesh represents a draw call in the scene: it owns a shared pointer to a Geometry and a Material and exposes them through the renderable interface. The renderer queries meshes for their geometry, material, and world transform, then issues the appropriate GPU commands. Meshes can also lazily generate a wireframe representation for debugging.

cpp
auto geometry = vglx::BoxGeometry::Create();
auto material = vglx::UnlitMaterial::Create(0x00FFAA);

my_scene->Add(vglx::Mesh::Create(geometry, material));

Construction

Constructors


Mesh()

Constructs a mesh.

cpp
Mesh::Mesh(std::shared_ptr<Geometry> geometry, std::shared_ptr<Material> material);
ParameterDescription
geometryShared pointer to the mesh geometry.
materialShared pointer to the material used for rendering.

Factories preferred


Mesh::Create() std::unique_ptr<Mesh>

Creates an instance of Mesh.

cpp
static std::unique_ptr<Mesh> Mesh::Create(std::shared_ptr<Geometry> geometry, std::shared_ptr<Material> material);
ParameterDescription
geometryShared pointer to the mesh geometry.
materialShared pointer to the material used for rendering.

Functions

GetGeometry() std::shared_ptr<Geometry>

Returns the geometry used by this mesh.

cpp
std::shared_ptr<Geometry> Mesh::GetGeometry() const override;

GetMaterial() std::shared_ptr<Material>

Returns the material used by this mesh.

cpp
std::shared_ptr<Material> Mesh::GetMaterial() const override;

GetNodeType() Node::Type

Identifies this node as Node::Type::Mesh.

cpp
Type vglx::Mesh::GetNodeType() const override;

GetWireframeGeometry() std::shared_ptr<Geometry>

Returns a wireframe representation of the current geometry.

The wireframe geometry is generated on first use from the mesh's triangle-based geometry and cached for subsequent calls.

cpp
std::shared_ptr<Geometry> Mesh::GetWireframeGeometry();

SetGeometry() void

Replaces the geometry used by this mesh.

cpp
void Mesh::SetGeometry(std::shared_ptr<Geometry> geometry);
ParameterDescription
geometryNew geometry to assign.

SetMaterial() void

Replaces the material used by this mesh.

cpp
void Mesh::SetMaterial(std::shared_ptr<Material> material);
ParameterDescription
materialNew material to assign.

Released under the MIT License.