CubeLayout
Source:
CubeLayout.h
CubeLayout¶
src/light/layouts/CubeLayout.h:33Inherits:
LayoutBase
Layout of a 3D cube volume (width×height×depth).
Author: MoonLight, https://github.com/ewowi/MoonLight/blob/main/src/MoonLight/Nodes/Layouts/L_MoonLight.h
Public Attributes¶
lengthType width = 10
: Cube edges. Defaults 10×10×10, range 1..128, MoonLight's exact defaults.
lengthType height = 10
: The cube's extent on y.
lengthType depth = 10
: Its extent on z.
uint8_t wiringOrder = 3
: Which axis the strip runs along fastest, an index into the axis-order table.
bool incX = true
: Per-axis scan direction: set counts up from zero, clear counts down.
bool incY = true
: Whether y counts up.
bool incZ = true
: Whether z counts up.
bool snakeX = false
: Per-axis snake: reverse that axis on alternate passes of the enclosing loop.
bool snakeY = true
: Whether y does.
bool snakeZ = false
: Whether z does.
Public Methods¶
virtual inline void defineControls() override
: The controls a user sets on the card.
virtual inline const char * tags() const override
: The catalog tags this layout carries.
virtual inline Dim dimensions() const override
: How many axes this layout places lights on.
virtual inline nrOfLightsType lightCount() const override
: How many lights the current settings place.
virtual inline void placeLights(const CoordSink & sink) const override
: Emit every light's coordinate, in wiring order.
More info¶
A solid cube of lights: every integer lattice point in a width×height×depth box gets one LED. Unlike SphereLayout (a shell), this is a filled volume, so [lightCount()] is simply the product of the three edges.
The interesting geometry is the WIRING ORDER, the sequence in which the LEDs are addressed. A physical cube is built from a strip that snakes through the volume. Which axis the strip runs along fastest (plus whether it reverses direction on alternate passes, boustrophedon / "snake") determines the index→position mapping. This layout reproduces the predecessor MoonLight's Cube: a 6-way axis-order select, a per-axis increasing-direction flag, and a per-axis snake toggle. The emitted COORDINATE is always the true (x,y,z); only the ORDER of emission (the driver index) changes with these controls, the same principle as GridLayout's serpentine, generalised to three axes.
Prior art: CubeLayout in the predecessor MoonLight, github.com/ewowi/MoonLight, which keeps its own name now that it is ours too. It drives a Wiring helper with per-plane pins (nextPin() per plane). Ours emit coordinates only, the driver owns pins, so that plumbing is dropped and only the geometry is kept.
The wiring walk is reconstructed¶
MoonLight expresses this through an iterate helper that is not in the sources we have, so the walk here is the standard boustrophedon its usage and defaults imply. The per-axis increment picks the base scan direction, ascending by default, and the per-axis snake reverses that direction on odd passes of the enclosing loop. That is the snaking a grid applies on one axis, generalised to three.
The snake toggle keys on the enclosing loop's counter, the physical pass number, which is the physically correct boustrophedon. For the all-ascending default that counter equals the emitted coordinate, so this reproduces MoonLight's default exactly.