Sunday, 27 October 2019

Blender 2.8 and LDraw Renders

The latest version of Blender - v2.8 (https://www.blender.org/download/releases/2-80/ is making rendering Lego ldr files a lot easier - you just need to add the LDraw importer to import the models (https://github.com/TobyLobster/ImportLDraw).  These were rendered on pretty much the default settings.




The main thing to watch out for is the "Add Environment" setting when importing the LDraw file into Blender.  Adding an environment adds a floor (to cast shadows on to) and a background image (as an exr file).  However Blender does not seem to read the exr file correctly - which creates the "pink hue" effect when rendering with missing textures in Blender - as this is a background texture - everything gets the pink hue





The quickest way to fix this is to simple remove the backround.exr file before you render.  Under the Rendering tab, choose the world icon on the right hand side, and remove "background.exr" from the colour setting. 



Your model should now render without the pink hue!




Thursday, 10 October 2019

Building Duplo Walls

My friend in China had a problem with his Duplo build, when building walls with Duplo my code would create models that were not particularly strong, the repeated patterns of bricks would cause "fault lines" to appear in the model.  Whilst there is some ability to deal with this in the code (using a brick discard function for repeated layers), it did not help to solve this particular "fault line" issue.   Consequently I added a function to randomly discard some of the bricks in each layer, to break up the repeating pattern.  Whilst this may not be ideal for the majority of model builds (as smaller bricks tend to decrease the strength of the overall model), in this particular instance it does increase the strength of Duplo walls.



Tuesday, 1 October 2019

Optimising Lego ldraw Duplo Models

What I also needed to do was to optimise the Duplo model to remove repeated 1x1 bricks (as I'd done previously with the Lego models) - the code looks for the definition of 1x1 bricks using the value assigned to the layer matrix; where this value is derived from the dictionary of brick parts - for the Lego conversion this value was 914 - for Duplo - which uses less brick shapes it was 909 - consequently it was relatively easy to fix, allowing for the removal of repeating 1x1 bricks.  Here's Yoshi in Duplo glory!  If anyone is interested with working with Duplo models let me know.


Sunday, 22 September 2019

Creating LDraw Duplo Models

I got an email from someone in China asking if I could make my 3D model to ldr file conversion work for Duplo bricks - he'd already had a go and included some .dat file for 1x1 and 1x2 Duplo bricks but I needed to tweak the code a bit to make it work - with Duplo, the models are less likely to be physically possible to build (at least with the bricks he initially wanted to use - 1x1,1x2,2x2,2x4) but the code tweaks were less complex than I expected.  A couple of examples of Duplo models built using my revised script below:



Thursday, 22 August 2019

Creating More Sculptures - Build Like An Egyptian!

Following a presentation on Lego sculpture I wanted to look at creating some Lego sculptures using some of the models that you can download for free from various online model libraries.  These included TurboSquid, SketchFab, Sketchup's 3D Warehouse and CGTrader.  I went with a bit of an Egyptian theme and downloaded the following models from the various websites



I converted them into Lego models using the process I've outlined here and using the instructions and code on GitHub.  I then rendered the animations in Studio 2.0 (which took a few hours) but I was fairly happy with the results.






Saturday, 3 August 2019

Creating Lego Sculptures - Those boots were made for building!

I wanted to see how flexible my scripts were for building Lego models from a 3D model that I downloaded from the internet.  Ideally I wanted to see if I could convert a 3D model that had been created from a 3D scan, so I selected a file on SketchFab and ran it through my 3D polygon > Coloured voxel > Ldr file pipeline that I've documented here and that's available on github


The final result was rendered in BrickLink's Studio



Wednesday, 24 July 2019

Unreal Lego

I've been looking at importing LDR files into Unreal Engine 4.  I haven't used Unreal Engine since version 3 so I was pleasantly surprised by how easy it is to import assets into Unreal Engine in the latest version.  In the past you had to use esoteric .psk files and the like - now you can simply import .fbx files.




The main problem I had was getting the colours in.  Blender does not seem to include the colours when it exports an .fbx file and I couldn't work out how to bake the colours in using Blender - in the end I had to resort to using Maya to export the FBX file.