Saturday 16 February 2019

A World of Colour - Coloured Voxels Part 1



I've returned to converting voxel models to ldr files, but this time my hope is to be able to convert coloured 3D models to a .ldr file with coloured bricks.  Binvox does not seem to support coloured models so I needed to research other voxel modelers with colour support.  Consequently I discovered Magica Voxel and Goxel - both support coloured voxel models and both are free to use.  Both have useful toolsets for creating and rendering voxels models but Goxel has better import/export options than Magica Voxel and there is also a iOS goxel app (but you have to pay for that).   Magica Voxel created and use their own .vox format (which supports coloured voxels) and Goxel can import and export .vox files




Goxel also supports it's own internal scripting language which opens up considerable possibilities for procedural builds and designs.



As part of my research I also discovered py-vox-io (which like binvoxpy) would take the heavy lifting out of having to decode Magica Voxel's .vox file format as py-vox-io allows python to read and write .vox files.  Unfortunately py-vox-io only runs under Python 3 so I would need to switch from Python 2.7 to Python 3.  To be honest I needed an excuse to switch to Python 3, which has become increasingly established so I decided to jump in with this project.  I also decided to switch my IDE to Microsoft's Visual Studio Code.  My previous IDE was a lash up of Notepad++ with some plug-ins so I could call python directly - it worked for me but it wasn't exactly "standard"!


Changing to Python 3 and switching my IDE means that I've had to go back an rewrite some of my binvox code that I created previously to build .ldr files from binvox files and I also needed to add support for reading the colour information in the .vox file format.  Currently although I can access details about the differences in colour between each voxel linking together the Lego colour palette and the .vox file palette is quite complex and at the moment I need to manually assign the correct Lego colours in the LDR file.


So the image above shows the original .vox model in Magica Voxel, the initial LDR output (before processing the colours) and the final LDR file with the colours manually remapped (using a find/replace function) to Lego colours




   


No comments:

Post a Comment