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.