I want to make a voxel-based game...


(Image made of Sproxel, a voxel sprite editor)

This is what I want to make, but Sproxel doesn`t save colors when exporting the OBJ file. So I decided to make, or at least download the voxel engine inside Unity.

-I dont need the Marching Cubes. -It doesnt have to be complexed: I just need a pile of coloured cubes made from 3D array.
-It have to be effecient.

Can you advize me on making one, or recommand a good one?

Thanks for reading.

Using cubes isn’t ‘efficient’ in terms of performance and memory (lots of useless and/or duplicated edges) compared to making a mesh. However, it’s super simple to do; you just instantiate cubes where you need them.

A quick and dirty way:
1- Make a 3D array of ints of the size of your box (I’m guessing you won’t need more than 256 diferent colors so can use bytes here).
2- Write bytes depending on the stuff you want to spawn (0=empty, >0 = colors)
3- Instantiate cubes at every point using the int number as an index for premade colors.

This is one of many, many possible approaches.

If you want more elaborate examples you can hop on the 66+ page thread about minecraft-like voxel engines here: http://forum.unity3d.com/threads/63149-After-playing-minecraft

1079864--40391--$22758751.jpg

These are voxels:
1079864--40392--$1074473-kvx50000_32.png

These are polygon cubes mapped on a 3d grid:
1079864--40393--$minecraft.png

I’m sorry, but mincing the definition of voxels has become a peeve of mine.

1 Like

@Not_Sure
voxels aren’t about the representation but about the storage of your 3d data. A voxel is a dot in a 3D space as a pixel is a dot in a 2D space. You can give it any propriety or set of proprieties (color, alpha, random variables and values) depending on what you want to do and then display all that the way you like, should it be as polygons, sprites etc… You only have to care about the spacing between them.

-edit-
Just because i was passing by :

Here is a very basic xml representation of a 4 * 4 * 4 voxel grid with color.
The color is an index represented as you want, like hex values or rgb, rgba. Add extra data like material properties, texture or anything.
Note, as long as you use a separator, the index can be anything like a hex value containing much more data.

Finaly, the structure is simply defined by the dimensions. 3 loops (one for each dimension) will then parse the data and put your voxels where they should be.
I’ve separated the data with spaces just to see more clearly how it should be translated.
There is a smiley on the top layer and a blue square under.

<![CDATA[ 1,0,0,1, 0,0,0,0, 1,0,0,1, 0,1,1,0,

0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,

0,0,0,0,
0,0,0,0,
0,0,0,0,
0,0,0,0,

2,2,2,2,
2,0,0,2,
2,0,0,2,
2,2,2,2
]]>

I think I agree, voxels are basically the idea of a volumetric storage of space that allows small units of space to be added and removed… . but even that can be vague and there will always be things like minecraft that push that definition since the block are so big, or because it uses polygons to draw the blocks, or whatever. To me the volumetric aspect of it is the most voxely, although I am accustomed to voxels being small.