Tuesday, 7 January 2020

The High Tower

The problem with the Lego landscapes was that it still doesn't consider the "density" of the build. I wanted to create something where it would pack bricks into the available spaces before it increased the height of the build.  Consequently I would need to analyse the available space left in each layer and fit bricks into those spaces.  My first attempt had a bug in the code that increased the height of the bricks in one of the corners of the build.  Whilst the bug was frustrating to track down it did make quite a nice image!


Saturday, 4 January 2020

Lego Landscapes (In Search Of Studless Models - Part 6)

Having reached a point where I could build various random structures of different heights/colour combinations, I decided to combine them with a script that I wrote a couple of years ago which would randomly combine a library of Lego models (each created on a 4x4 base plate) onto a 48x48 base plate.  This allowed me to create a "landscape" of Lego.












Sunday, 29 December 2019

No Studs Here! (In Search Of Studless Models - Part 5)

Personally, I think the appeal of studless models is that, generally, they just look nicer, and more "polished", so they appear as if they have been finished with a "human touch".  Hence giving a computer the ability to create studless models might begin to blur the boundaries between computer generated models and human created models. 



As the brick matrix was now being randomly created (as opposed to selecting an LDraw part and calculating the brick matrix) it was now much easier to swap out bricks for similar bricks - so swapping a 1x1 standard brick for a 1x1 cylinder brick or  a 1x2 standard brick for a 1x2 grill brick or 1x2 with embossed bricks became much simpler.  Sloping roof tiles were set to only be added at the top of the models (because of the issues with the height of sloping roof tiles noted previously) 

Having managed to track (most of) the available studs in a build I could begin to apply colours to the model to make it more visually pleasing.  I also wanted to include some transparency as that can make the renders look more interesting, especially with the photoreal renderers that are becoming increasingly available.  Distributing the colours over the height of the the design meant adjusting for the max height of the model.  For shorter models (under 5 units high) I coded to add more blue, which helps to break up the green floor of the other models


Thursday, 26 December 2019

What! A Stud? (In Search Of Studless Models - Part 4)

Isolating the available studs in a model requires that you analyse the whole column of bricks above any given stud - by analysing each layer in the column of your build matrix it's possible to isolate where the studs should be available - however my current code is not flawless - in the model below there are a couple of studs that are not identified (one above the base layer and one above the 1x2 wall texture brick).

Monday, 2 December 2019

Imaginary Bricks! (In Search Of Studless Models - Part 3)

I'd returned to just using 1x1 tiles to try to isolate stud availability.  I had been using my brickalo code to generate the models that I would then try to add tiles to, however my brickalo code was an unmanagable mess (of my own making) so I decided to rewrite my code to better support the isolation of studs within a model.

Initially my new code focused purely on the placement of tiles on "imaginary" studs of imaginary bricks!  I coded a mechanism of creating a numpy matrix that could represent the bricks and plates added to a model (without actually bothering to add the brick to the LDraw model).  However it quickly became apparent that having made a functional matrix that could track imaginary bricks and plates - I may as well use it to add real bricks to the LDraw model.  It's worth noting that this approach was very different to the code I'd used for brickalo.  

With brickalo, the code selected a random LDraw part (from a list of parts) and then drilled down into the part to work out what the dimensions (1x2,2x2,2x4 plate or brick etc) of the LDraw part were which then allows the code to calculated the part matrix which is then added to the larger build matrix.  With my new code, that I was using for tile placement, the part matrix is randomly generated, and the corresponding part selected according to the dimensions and size of the randomly generated part matrix.   As it turns out, this new approach would allow for the selection of  many more variations of similar parts.



Thursday, 14 November 2019

Not All Tiles are Equal (In Search Of Studless Models - Part 2)

Initially I looked at trying to use 1x1 sloping roof tiles to place on each available stud but the problem with these parts is that they are not 1 plate width high, so not only do you need to identify available studs but you also need to know the gap distance between the stud and any parts above the stud.  In the little animation below it looks like I got lucky, but if you look carefully, there is an intersection in the model!


Another couple of intersections are more obvious in the model below.

In fact I've yet to solve this problem, so for now sloping roof tiles could only be used on the top of a model!

Saturday, 2 November 2019

In Search Of Studless Models (Part 1)

Studs are, of course, the real magic of Lego, but isolating a specific stud on a specific piece of Lego within LDraw's construction system can be a challenge.  On a standard brick, in a given location you can calculate the stud location, but what if you are randomly placing random bricks and random plates into a model, how can you track the location of available studs within your model?

Tracking stud availability within a random model build would turn out to be a lot trickier than I imagined.   

I started by reviewing the layers of the brick matrix that I use to track the placement of bricks and plates during the model build



Previously I'd only really focused on a single matrix layer during the build process to track the addition of new bricks as they were added to the model build (so I always focused on the top most layer in the matrix).  What I would need to do now was track all the layers for each brick added to the model build and then compare each layer to try to isolate where a stud might be available, by eliminating studs as more bricks were added to the model.