Skip to content

BoxGeometry

Generated geometry representing a box.

BoxGeometry generates a mesh for an axis-aligned box defined by its width, height, and depth. Each dimension can be subdivided using segment counts to control vertex density and support smoother lighting or deformation. The geometry is constructed in local space, centered at the origin.

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 material = vglx::PhongMaterial::Create(0x049EF4);

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

INFO

Derives from Geometry and inherits all public properties and methods.

Construction

Constructors


BoxGeometry()

Constructs a box geometry.

cpp
BoxGeometry::BoxGeometry(const Parameters& params);
ParameterDescription
paramsInitialization parameters for constructing the geometry.

Factories preferred


BoxGeometry::Create() std::shared_ptr<BoxGeometry>

Creates a shared instance of BoxGeometry with default parameters.

cpp
static std::shared_ptr<BoxGeometry> BoxGeometry::Create();

BoxGeometry::Create() std::shared_ptr<BoxGeometry>

Creates a shared instance of BoxGeometry with custom parameters.

cpp
static std::shared_ptr<BoxGeometry> BoxGeometry::Create(const Parameters& params);
ParameterDescription
paramsInitialization parameters for constructing the geometry.

Types

BoxGeometry::Parameters struct

Parameters for constructing a BoxGeometry object.

ParameterDescription
width floatSize along the X-axis.
height floatSize along the Y-axis.
depth floatSize along the Z-axis.
width_segments unsignedSubdivisions along X.
height_segments unsignedSubdivisions along Y.
depth_segments unsignedSubdivisions along Z.

Released under the MIT License.