ModEnc is currently in Maintenance Mode: Changes could occur at any given moment, without advance warning.

Voxel Bounds

From ModEnc
Revision as of 08:56, 19 October 2005 by DCoder (talk | contribs) (Created the page, but it's very technical. Feel free to rewrite.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

Credits

This article is a compilation of information provided by various members of the community, including Blade, CannisRabidus, and Stucuk.