Voxel Bounds
Note: This article uses a 3D coordinate system where:
- The X axis increases to the right.
- The Y axis increases towards the screen.
- The XY plane is the "ground" plane.
- The Z axis increases upwards.
Technical explanation
Voxel bounds define the dimensions of a "voxel container box", so to speak, its relative position in the game world, and thus, the box's center of rotation.
When a unit is placed in a cell, the game assumes the center of that cell's ground plane to be the 0,0,0 point of the said "voxel container box". The "boxes" of the turret/barrel of that voxel also assume the same point as 0,0,0. Thus, all three parts of the unit have the same axes of rotation. The Z axis of rotation (vertical axis) is particularly important, since the unit will rotate around it when turning.
Even more technical comment: The game defines bounds as six integers: MinX, MinY, MinZ, MaxX, MaxY, MaxZ. Each of them stores a corresponding x/y/z coordinate of the "box"'s two opposite corner points (back lower left corner is assumed as Min, front upper right is assumed as Max), relative to the said 0,0,0 point.
Thus, a voxel's "box" is always (MaxX-MinX) x (MaxY-MinY) x (MaxZ-MinZ) , and its rotational center is always 0,0,0 .
So, following this logic, the turret's "box" should be positioned on top of the unit "box", and the barrel "box" should be in front of the turret "box".
You should also know that the voxel will be resized to fit in the "box" if necessary. So, if you want to make the voxel unit half as long and twice as wide, you can just halven the min/max X values and double the min/max Y values.
Note: When creating train voxels, it is recommended to set the minZ to at least 3, to avoid the traintrack images overlapping your train.
Example
For example, observe the Rhino Tank:
Unit (htnk.vxl) bounds:
Min X: -19 Min Y: -17 Min Z: 0 Max X: 26 Max Y: 16.5 Max Z: 11.5
Turret (htnktur.vxl) bounds:
Min X: -16 Min Y: -9 Min Z: 11.5 Max X: 11.5 Max Y: 9 Max Z: 20
Barrel (htnkbarl.vxl) bounds:
Min X: 12 Min Y: -1.5 Min Z: 13 Max X: 30.5 Max Y: 1.5 Max Z: 16
As you can see:
- The unit "box" is 45 x 33.5 x 11.5 .
- The turret "box" is 28.5 x 18 x 8.5 .
- The barrel "box" is 17.5 x 3 x 29 .
- The unit "box" is approximately 11 voxelblocks high and is positioned at ground level, the turret "box" is positioned exactly above the body "box" (turret.minZ approx= body.maxZ) , and the barrel "box" is directly in front of the "turret "box" (barrel.minX approx= turret.maxX).
- The combined object's Z axis (and the not-so-important Y axis) is shifted a bit to the back, since MinX and MaxX values are different in value, not just in sign.
Advanced Usage
Voxel bounds are useful for shrinking the unit in any, or all, directions as well. It is an excellent way to make slight size adjustments where drawing the voxel unit proportionally would result in a loss of details, and it just needs to be narrowed in one axis, but it can also be used to mitigate (if not eliminate) "black dot syndrome" as it is known.
In many voxels with a single layer thickness, a lack of shrinkage means that at certain rendering angles, espectially on curved or angled surfaces, the engine would allow the player to see "between" the dots in places. That gap is then filled by rendering whichever dot was the next layer visible, almost certainly with a normals value facing the opposing direction. The side effect of seeing that wrong dot is then the lighting applied inverted, making the dot appear black, or without light.
Shrinking such a voxel to even 90% size (ie. multiplying the bounds values by 0.9) is enough to close the gaps in most cases, but greater shrinkage can be applied. Ultimately the better solution is to thicken the voxel's skin, applying the same or similar normals values to the second layer of dots, as the auto-normals tool in VXLSE does, however there are still benefits to shrinkage.
Note: The voxel renderer in RA2/YR is actually very good at colour blending neighbouring dots as they overlap, but with shrinkage applied this happens in all directions and all facings, which means that remappable sections that aren't large enough will be colour blended with their neighbours also. This can drastically alter the resulting colour as seen by the player.
A good example would be: a blue toned unit with a red house colour, will blend adjacent dots to some shade of pink or purple, which could in fact be another house colour, making at-a-glance identification difficult. One way to mitigate this is using remappable areas surrounded by grayscale texturing, then any blending will only change brightness, not the tonal range.
The effects of voxel shrinkage should be considered (and tested!) as it relates to the renderer, care should be taken with drawing and texturing the voxel.
Credits
This article is a compilation of information provided by various members of the community, including Blade, CannisRabidus, Stucuk, and G-E.