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

Voxel

From ModEnc
(Redirected from VXL)
Jump to: navigation, search

A voxel, or volumetric pixel, is a three-dimensional analogy of a pixel. The file extension for voxel files is .VXL. Voxels may be virtually any colour (assuming the colour is utilised in the palette of the game or voxel editor)and can use surface normals. Voxels may also be animated with the use of an HVA file, but there are limits in the Tiberian Sun and Red Alert 2 engines as to what unit types may use certain types of animations. For example, in Tiberian Sun, an aircraft type may not utilise a turret animation.

Voxels are usually used to render vehicles and turrets in the Tiberian Sun and Red Alert 2 engines, whereas SHP files are generally used for infantry units and buildings. This is due to hard-coded restrictions in the game engines, and also because SHPs are usually of a higher in-game quality than voxels.

It is worth noting that units which are comprised of voxels will tilt while walking up a slope in the aforementioned engines, whereas an SHP unit, such as the Titan or Wolverine, will not. Voxels are generally used for the turrets of SHP buildings such as the Sentry Gun or Grand Cannon, because they allow 360 degree rotation of the turret, without the need for the facings that would be used in an SHP.

Format

Cc kate.png
This article or section is a stub. You can help ModEnc by expanding it.

[insert more info here, re: sections and stuff]
The individual voxels (in terms of volumetric pixels) are stored as a series of five values in WW's voxel format: The X, Y and Z position of the voxel, the color index, and the normal index.
The what color which the color index stands for depends on the palette the voxel is displayed with; what angle a normals value indicates depends on the normals generation and the normals array value for the index.

Voxels cannot be larger than 255x255x255, and have severe graphical problems, such as artifacting and palette errors at such a length on any axis1. This could be a major setback for some types of voxel, such as especially long ships or aircraft, but not a big problem with most voxels which are generally no larger than 100 on the z axis.

In addition to the .VXL file, all voxels must have a .HVA file, which defines the location the voxel occupies in 3 dimensional space relative to 0 on the X,Y,Z axes. THe HVA is also used to line up turrets and barrels vertically and change the point around which the voxels rotate, and to animate multi-sectioned voxels. Without an HVA, voxels cause an internal error.

Multi-sectioned voxels are made up of a hierarchy of voxels within on .VXL This is most obvious in Tiberian Sun's Mammoth MK2, which was a singe .VXL file comprising the body, each upper and each lower leg, and each foot, for a total of 13 voxel objects in the file. This was paired with a more involved HVA that usual to give the unit a walking animation. The same process is used on a much smaller scale in the construction of helicopter units for RA2/YR, where the rotors are a separate section but not a separate file, making it easy to animate. There are no other examples in the vanilla games, but there have been a substantial number of multisectioned voxels released in the modding community.

Rendering

Scale

When drawn parallel to the camera, or the player's point of view, the voxel-to-pixel ratio is exactly 1:1. For example, on default scale a voxel model that is 60 voxels long, when rotated to face sideways to the player PoV, will also appear as 60 pixels long.

When rotated, voxels are transformed to appear isometric. In Tiberian Sun, a flat, square voxel model with length and width of 34 voxels will near perfectly fit within one cell. For Red Alert 2, this number is 43. Exact cell dimensions, in voxels, would be 33.94112 and 42.4264 for TS and RA2, respectively.

One voxel equals approximately 6 (more specifically 6.03397) leptons. This is true for both TS and RA2, as leptons are relative to cell size.

While the size of individual voxels cannot be altered, the voxel model's canvas can be changed using voxel/HVA bounds. This increases or decreases the space between the individual voxels, effectively exploding or shrinking the model. See voxel bounds for more information.

Demonstrating Red Alert 2 voxel scale with a voxel cube that fits as perfectly as possible in one cell. The model's dimensions are 43x43x43 voxels.
The same cube, rotated to face the "camera". Notice how the cube now appears exactly 43 pixels wide.

Rotation

In-game, a voxel model has a total of 32,768 possible facings (32 facings per axis). Each facing is rendered only on demand, then cached for future use during the game session. This improves performance and conserves memory, a strategy needed especially at the time the games were made.

Layering

On voxel models with multiple sections, the order of the sections determines the drawing order. The first section (index 0) is drawn at the bottom, the next one (index 1) is drawn above it, and so forth. See for example the HMEC.VXL (Mammoth Mk.II) and its respective HVA file in Tiberian Sun.

If the unit has a turret, then the turret is drawn above the body as if it were a regular tank. Similarly, if the unit has a barrel, the barrel is drawn above the turret, but only when the turret is facing towards the player's point of view.

Demonstrating voxel turret/barrel drawing order.

See also

Footnotes

1 Only conclusively tested in Tiberian Sun, but there is no reason to conclude that it is not a problem in RA2 - might require testing