Voxel is defined as: "(in computer-based modeling or graphic simulation) each of an array of elements of volume that constitute a notional three-dimensional space, especially each of an array of discrete elements into which a representation of a three-dimensional object is divided."–Google

—In other words, a voxel is a 3D pixel.

Voxel

Syntax: voxel[x,y,z, r,g,b]

A voxel placed at the origin.

The voxel command creates a single voxel at the given XYZ: voxel[0,0,0]
It is useful for precise placement and prototyping.

Four voxels each with their own RGB colors.

The voxel command can also take RGB color parameters. These extra parameters follow the XYZ coordinates: voxel[0,0,0, 255,165,0]

Note: If left empty, the color defaults to white.

Color

Syntax: [...r,g,b]

Assortment of colors.

The color parameter is not a command, but it can be added to almost any command to make the voxel it creates have a RGB color.

The RGB values should always follow any other command parameters and be between 0-255.

Examples:
voxel[0,0,0, 255,0,0]


cube[0,0,0, 10,10,10, 200,200,0]

Each voxel in a fill may have its own color.

Note: the fill command is an exception to the syntax rule. Instead of putting the RGB values at the end of the fill command parameters, the values must be put at the end of each voxel command inside the fill (each voxel may have a unique color).

Example:
fill[0,0,0, 0,5,1]{
voxel[0,0,0, 255,255,255]
voxel[1,0,0, 0,0,0]
}

Cube

Syntax: cube[x1,y1,z1, x2,y2,z2, r,g,b]

A large cube.

The cube command takes a starting point and an ending point and creates a cube between the two. This is the best way to make walls and other straight lines. Although it is also very useful for infilling areas with needed voxels or for creating large boxes.

Example:
cube[0,0,0, 10,10,10]

Something to keep in mind: the cube command includes the end point voxel inside of the cube. If it were a cube in real life, including this end point voxel would make it one unit bigger than it should be. This is sort of the case here, too, but the cube command functions in this way because it makes sense to include the end point in a voxel editing program.



(Note: If the cube is very large—or if there are a lot of cubes—it may take some time to compile. This is normal. If the browser gives a warning about the page taking a long time to load, just be patient.)

A colored wall.

Color can be added to any cube. The extra RGB parameters follow the ending point's XYZ coordinates.

Example:
cube[0,0,0, 5,1,0, 255,0,0]

Fill

Syntax: fill[x1,y1,z1, x2,y2,z2]{...}

Fill makes a 3D line.

The fill command essentially draws a line in 3D space. It takes two XYZ points for its parameters. But it can also be thought of as a loop that takes any amount of voxels and places them on the points of a 3D line.

Example:
fill[0,0,0, 0,5,2]{
voxel[0,0,0]
}


When placing voxels inside of the fill loop, the XYZ coordinates are local to the fill, not global to the scene. This means that even if you type:
fill[0,0,0, 5,5,5]{
voxel[10,10,10]
}

It wil be the same as:
fill[0,0,0, 5,5,5]{
voxel[0,0,0]
}


Also, something to keep in mind: the voxels inside the fill are centered based on the bounding box's center point. This center point is matched to the 3D line's points. These points are calculated based on the starting and ending point parameters. The voxels in the bounding box are translated as needed.



(Note: Currently, the fill command can only take voxels inside its brackets. Support for cubes and nested fills are planned to be added eventually.
Also, everything in the fill command must be on a new line, including the closing curly brace.

This means don't write:
fill[0,0,0, 5,2,0]{voxel[0,0,0]}

or:
fill[0,0,0, 5,2,0]{
voxel[0,0,0]}
.

Instead write:
fill[0,0,0, 5,2,0]{
voxel[0,0,0]
}


)

Multicolor fill.

The voxels inside the fill loop can all take individual RGB colors.

Example:
fill[0,0,0, 0,5,2]{
voxel[0,0,0, 255,0,0]
voxel[1,0,0, 0,255,0]
voxel[2,0,0, 0,0,255]
}

Grid

Syntax: grid:on or grid:off

One voxel with grid:on (red) and one with grid:off (white)

The grid variable controls the snapping of voxels to an integer grid (A.K.A. all float XYZ values will be rounded to ints). The grid var can be set and reset throughout the code.

Example:
grid:off
voxel[0.5,0.5,0.5]
grid:on
voxel[0.5,0.5,0.5, 255,0,0]

The first voxel is not rounded and at the point (0.5, 0.5, 0.5) the second voxel is rounded to the point (1, 1, 1)

Fill with grid (white) and without grid (black).

Grid is especially seen in the fill command:
grid:off
fill[0,0,0, 0,5,2]{
voxel[0,0,0, 0,0,0]
}
grid:on
fill[1,0,0, 1,5,2]{
voxel[0,0,0, 255,255,255]
}

Filename

Syntax: filename:name

The filename variable changes the export file name. There should be no white space between the colon and the name of the file.

Example:
filename:AwesomeVoxel



(Note: The filename is not too important for exporting .stl, but it is very important in exporting .obj. Each .obj model should have a unique filename. Also, filenames cannot contain spaces; if they do, it will break the color export for .obj)

Comment

Syntax: *

To comment out any line of code, simply put an asterisk (*) in front of it.

Example:
*voxel[0,0,0]

In the case of a multi-line command, such as fill, there must be an asterisk at the beginning of every line.

Example:
*fill[0,0,0, 10,10,10]{
*voxel[0,0,0]
*voxel[1,0,0, 0,0,0]
*}

Compile

The compile button generates all model data and prepares it to be exported.
Depending on how many voxels are used in a model, this can take some time.

Preview

The preview button generates only enough model data to render it to the screen. It does not prepare the model for exporting.
Although not thoroughly speed-tested, preview is about 99.3% faster than compile. Because of this difference, compile should only be used when the model is done and ready to be exported.

Exporting to STL

.stl files are very common for 3D printers. VoxelCode can export these files in standard ASCII format. These are fully readable by 3D printing software.



(Note: .stl files do not contain any color specifications.)

Exporting to OBJ

.obj files are commonly used in 3D modeling software and game engines. This is because .obj files contain color data. So, if you need to export color, use this format.



(Note: The .obj model format requires two additional files. These files are a texture file stored as a .png and a material file stored as a .mtl. Both of these file are exported when the .obj button is pressed, they need to be saved in the same folder as the .obj file.)

Camera Movement

The camera for the 3D scene, is set to an orbit control.

With this control scheme the following are the bacis movements:

Left-Click: Rotate
Right-Click: Pan
Scroll: Zoom