Skip to content

BoxGeometry

Generates a box geometry assignable to any mesh.

BoxGeometry 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()

Constructs a BoxGeometry object.

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

Factories preferred


BoxGeometry::Create() auto

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

cpp
static auto BoxGeometry::Create();

BoxGeometry::Create() auto

Creates a shared pointer to a BoxGeometry object.

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

Types

BoxGeometry::Parameters struct

Parameters for constructing a BoxGeometry object.

ParameterDescription
width floatWidth of the box.
height floatHeight of the box.
depth floatDepth of the box.
width_segments unsignedSubdivisions along the X-axis.
height_segments unsignedSubdivisions along the Y-axis.
depth_segments unsignedSubdivisions along the Z-axis.

Released under the MIT License.