Take the 2-minute tour ×
LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. It's 100% free, no registration required.

After researching this question for a few days, I want to post it here so I can share what I learned in an answer, and hopefully learn some new techniques too.

If anyone has found another way to do this, please share! If anyone has used Legolizer for 3ds Max, an answer explaining that process or that has examples of it being used would be useful too.

share|improve this question

1 Answer 1

I found a few ways to convert a 3D model into a Lego sculpture. The first is a program called Dolphin which you can download here. It works very well, as you can see in this image of Yoshi:

Yoshi Lego Sculpture

The downside to this program is that it only runs on Macs, and the output format is a series of images, one for each layer. So you can't import it into MLCAD or your favorite Lego building software. I was looking for something that uses the .ldr format.

Another program is LSculpt. This worked okay but I couldn't seem to get great results. I'll been using a 3D model of Nautilus for my examples. Here is a picture of the LSculpt results:

Nautilus Lego Sculpture

The black version was created from LSculpt and the blue version was creating using my alternate method. It is also worth mentioning there is another technique, a 3ds Max script called Legolizer. Unfortunately, I don't have 3ds Max so that wasn't an option for me. I wanted to do this using only open source software on Windows. Here is how you do it:


Step 1 - Scale your 3D model

You need to scale your model down by a factor of .833. I used MeshLab and the process that it described in the Dolphin manual.

Step 2 - Convert a 3D model into a binvox file

This is done using a program called binvox.exe. You can read about it and find the download link on this minecraft wiki. All you need to do is to download binvox.exe and then copy your 3D model into that folder. Open command prompt, cd into that folder, and run a command that looks something like this:

binvox nautilus.obj -d 128 -rotz -rotz

nautilus.obj is the name of my 3D model, -d 128 specifies the size (128 x 128 x 128 voxels), and -rotz and -rotx will rotate the model. You will have to experiment to get the right rotation, or your bricks won't face up at the end. You might want to start with -d 32 to speed up the process until you get the orientation right, which you won't find out until the end. The output from this is a file with the name nautilus.binvox.

Step 3 - Install Cygwin (optional if you know what you're doing)

I would recommend installing cygwin for the following steps, since that is what I used, but you don't necessarily need it. You just need a way to run c++ and Perl programs. When you install it you can select packages, make sure you install the package named perl and the package named gcc-g++.

Step 4 - Convert the binvox file to a readable txt file using read_binvox

Download this program called read_binvox. Make sure it is saved as read_binvox.cc. Then copy your .binvox file into the same folder. Open Cygwin and cd into that folder. Then run

g++ read_binvox.cc -o read_binvox

to compile the program. Next, you can run it with

read_binvox nautilus.binvox

This will create an output file called voxels.txt.

Step 5 - Convert voxels.txt into your .ldr file

I wrote a program in Perl that will convert the voxels.txt into a .ldr file. Create a new file named binvox2ldr.pl in the same directory as your voxels.txt file. File it with the contents from this pastebin.

Then go back to that directory in cygwin and run the command:

perl voxels.txt > nautilus.ldr

This may take a while to run, depending on what size you made the sculpture. The program uses a very basic algorithm for combining bricks together. It may have floating bricks, so I wouldn't recommend just using the parts list from that and expecting a secure, perfect model. But I think it could be a good way to start a design for a sculpture. The script could definitely use some more improvements, but it's a basic start.

Step 6 - Editing and Render

You can use these instructions from ldraw.org installing some tools for editing and rendering the sculpture. I used MLCAD to change the color and then rendered it using POV-RAY. Here's what it looks like:

Nautilus Lego render

share|improve this answer
    
I have had much success with LSculpt and it can create models in great detail unlike your sculpture (although, it runs slower when you do that). –  rioforce May 6 at 23:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.