This project was developed as part of an advanced programming class, the goal was to build a program that allows the user to draw three dimensional figures from basic forms such as spheres, boxes and ellipses.
The figures are drawn from 3d pixels called voxels. Each drawing constitutes a matrix of voxels that are arranged according to the user instructions. A voxel can be positioned individually through an (x,y,z) coordinate, or a more complex form that draws several voxels can be choosen. Voxels can also be erased in order to create negative spaces.
The program is built around the abstract class 'figuraGeometrica'. The class defines a virtual function 'draw' and the attributes 'r,g,b,a'. Each geometric form is a child class of 'figuraGeometrica' that implements its own version of the function 'draw'.
The method 'parse' from the class 'Interpretador' is responsible for performing the appropriate function calls. To add more drawing instructions (geometric forms), it suffices to create a class that inherits 'figuraGeometrica' and to update the 'Interpretador' class accordingly.
- Clone the repository.
- Make a .txt file with drawing instructions, such as
- Compile the code using g++ or the makefile
~$ make all
~$ ./sculptor
- Type in the relative path of the input file.
- The resulting .off file will be written inside of 'output/'.
The user draws a figure by providing a .txt file with drawing instructions. Each file must start with the instruction 'dim x y z' where x,y,z are the sculpture dimensions. The following instructions are available:
- putvoxel x0 y0 z0 r g b a
- putbox x0 x1 y0 y1 z0 z1 r g b a
- putsphere x0 y0 z0 radius rgba
- putellipsoid x0 y0 z0 radiusx radiusy radiusz r g b a
- cutvoxel x y z
- cutbox x0 x1 y0 y1 z0 z1
- cutsphere x0 y0 z0 radius
- cutellipsoid x0 y0 z0 radius
For instance, one could write:
dim 55 55 55
putbox 0 19 0 19 0 9 64 224 208 0.9
putsphere 9 9 22 8 64 224 208 0.9
putellipsoid 9 9 42 7 3 9 64 224 208 0.9
cutbox 9 17 9 17 22 30
cutellipsoid 11 15 9 7 9 4
cutsphere 10 8 42 5
Once the drawing is finished, an OFF file is created. One can visualize it by using a program such as MeshLab or geomview.
The visualizaton of the sculpture created by the instructions above: