Skip to content

BoxGeometry

Generates a box geometry assignable to any mesh.

[BoxGeometry](/reference/geometries/box_geometry) creates a 3D box or rectangular box composed of triangles, based on configurable width, height, and depth. Optional segment parameters allow for subdividing each face, enabling smoother lighting or custom deformation effects.

cpp
auto geometry = vglx::BoxGeometry::Create({
  .width = 2.0f,
  .height = 1.0f,
  .depth = 3.0f,
  .width_segments = 2,
  .height_segments = 2,
  .depth_segments = 2
});

auto mesh = vglx::Mesh::Create(geometry, UnlitMaterial::Create(0x049EF4));
my_scene->Add(mesh);

INFO

Derives from Geometry and inherits all public properties and methods.

Construction

Constructors


BoxGeometry()

cpp
vglx::BoxGeometry::BoxGeometry(const Parameters &params)
ParameterDescription
paramsBoxGeometry::Parameters

Constructs a BoxGeometry object.

Factories preferred


BoxGeometry::Create() auto

cpp
static auto vglx::BoxGeometry::Create()

Creates a shared pointer to a BoxGeometry object with default parameters.

BoxGeometry::Create() auto

cpp
static auto vglx::BoxGeometry::Create(const Parameters &params)
ParameterDescription
paramsBoxGeometry::Parameters

Creates a shared pointer to a BoxGeometry object.

Types

BoxGeometry::Parameters struct

Parameters for constructing a BoxGeometry object.

NameTypeDescription
depthfloatDepth of the box.
depth_segmentsunsignedSubdivisions along the Z-axis.
heightfloatHeight of the box.
height_segmentsunsignedSubdivisions along the Y-axis.
widthfloatWidth of the box.
width_segmentsunsignedSubdivisions along the X-axis.

Released under the MIT License.