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);| Parameter | Description |
|---|---|
| params | Initialization 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);| Parameter | Description |
|---|---|
| params | Initialization parameters for constructing the geometry. |
Types
BoxGeometry::Parameters struct
Parameters for constructing a BoxGeometry object.
| Parameter | Description |
|---|---|
| width float | Size along the X-axis. |
| height float | Size along the Y-axis. |
| depth float | Size along the Z-axis. |
| width_segments unsigned | Subdivisions along X. |
| height_segments unsigned | Subdivisions along Y. |
| depth_segments unsigned | Subdivisions along Z. |