LEGO Set 483 using MLCad & POV-Ray

In my previous post, I have described how to create a replica of the LEGO Set 483 – Alpha 1 Rocket Base using LEGO Digital Designer. Following that, I explored the possibilities of using a different tool, giving me a more sophisticated rendering. The results of this search are described here.

This morning, I have re-created the LEGO Set 483 using MLCad and then rendered the result in POV-Ray. See for yourself.

Posted in LEGO | Tagged | Leave a comment

From LDD to LDraw – Taking LEGO Rendering one Step further

When I originally came across the LEGO Digital Designer, I thought (and still think) that this is a pretty cool toy to create LEGO models virtually.

However, it quickly turned out that there are some limitations:

  • the availability of bricks – some bricks just don’t exist in the LEGO Digital Designer
  • the rendering – while LDD can render images, the quality of the results is far from presentable.

So I started looking into other options – and came across LDraw which is an open standard for LEGO CAD programs. Unfortunately, the first obstacle to overcome with LDraw is the installation – which is all but easy.

Downloading and Installing

The easiest way to start is an LDraw Package distributed as all-in-one Installer. You can download it here – but be prepared to wait, the site is pretty slow at times. What you are downloading is a ZIP-File which itself contains the installer – a single file so unpack it to somewhere, e.g. your Temp directory, and start it. The Installer will greet you with a Welcome dialog.

Just click the Next button. This will bring you to an Information Dialog about De-Installation of previous Versions – click Next again. You will then be presented with three(!) License Agreements where you have to click Next on each one.

At the next dialog, you can enter a Name for LDraw Projects – keep the suggested default and click Next. This brings up the Component Selection dialog.

Keep the defaults again – unless you want one of the additional components (e.g. LeoCAD).

  • LeoCAD and LDGlite are additional Editing Application (just like the selected MLCad),
  • LDView is a pure Viewer for LDraw Models,
  • LPub is used to create Step-by-Step Instructions from MLCad files,
  • LSynth is used to create “bendable” parts for use with LDraw and
  • POV-Ray is a free Raytracing software to create high-quality 3D Images from the LDraw files.

So with that default, click Next. You are now being asked where to place the installation – and the default is pointing to your Program Files or Program Files (x86) directory. And this should change! Many parts of LDraw are pretty old – and I had issues with these files trying to write into the now protected application directories. So it is better to install LDraw separately – e.g. to C:\LDraw:

Now, click the Next button again. You will be asked about the Start Menu Item Name. Keep the default and click Next. This will bring you to the Options dialog. Just keep the defaults and click Next to advance to the Summary dialog. Review the information and then click Next again to finally(!) start the installation.

The installation process itself will take a few moments – this is owed to the size of the included Parts Database – a set of all supported LEGO Bricks you can use with LDraw. When the installation is done, click the Finish button.

Adding POV-Ray to the Installation

You may have wondered why I skipped POV-Ray on the Installer’s Options dialog. The reason is mainly that I wanted to make sure to get the latest version of POV-Ray installed by downloading it directly from their site. Once downloaded, start the POV-Ray Installer and you will see the Welcome dialog.

Click Next to get to the License Agreement dialog. Click Next again and you will see the Destination Folder dialog. I am not sure about POV-Ray but given that it is defaulting to install into my private user directory, I suggest to change that and install into C:\POVRay or so. Then click Next. You will now see the Ready to Install dialog – click Install to kick of the installation process.

In order to get POV-Ray to work with LDraw, there is one other step we will need to do – but later. First, let’s get the hands dirty and build something.

A very simple Model – Classic Space LEGO 885

Making it easy at the first go, let’s look at the Classic Space Set 885 – the Space Scooter.

This model is probably among the most simplistic ones out there – it consists of 19 individual pieces but already shows a couple of typical items used in several other Classic Space kits: the Antenna, the Mini Handle serving as front-end, the Wings and the Slope Brick with Classic Space Logo.

From before, we know that we could use the LEGO Digital Designer to create the model in LDD Extended Mode but we would not get the Classic Space Logo, for example. And we would not get a high-quality image rendered from the model… so let’s try LDraw instead – and use MLCad as our editor of choice.

The Space Scooter is very quickly and easily built – I will have a more detailed post about the how-to’s later. For now, let’s just assume we have built and colored the model in MLCad properly.

The one thing that sticks out immediately: we got our Classic Space Logos! Yeah! Other than that, the model looks complete, reasonably represented but not anywhere near the high-quality rendering that we have been looking for… and this is where the final piece of software we are still missing comes in.

Using POV-Ray to render the Model

We have previously installed POV-Ray to render the models we are going to create. However, POV-Ray does not understand the format that is created by MLCad. Nor can it directly be called from MLCad. We need some piece of translator software in-between and that is where L3P comes in.

L3P is the piece in the middle – but it is not a software that comes with your usual Windows frontend, the buttons and sliders and these things – it is a command-line tool. But don’t worry – for those of us that like the comfort of the Windows world, there is another bit called L3PAO which gives us the user interface and calls the command-line tool for us. Both we need to install…

So download L3P first – it can be found here. Simply search for the term “Download” and then load the most current package available for your operating system. You will actually get a ZIP File containing a single binary file – lp3.exe. Since there is no installer, you need to place the file manually: as we have installed LDraw into C:\LDraw, create a sub-directory named L3P in C:\LDraw and copy the binary there.

Now go to here and download L3PAO – or L3PAdd-on. The ZIP File contains an installer which you are going to run. This will show you the Welcome dialog.

Click Next. On the User Information dialog, you are asked to enter your name – do so. Then click Next. You will see the Installation Folder dialog – again, the installer is defaulting to the Program Files directory – I prefer to have it on the C:\LDraw directory.

Click Next. You will be faced with the Shortcut Folder dialog – keep the defaults and click Next. Now, you will be on the Ready to Install dialog – review the information, then click Next to kick of the process.

The installation will only take a few second – when done, you will be able to click the Finish button.

LGEO POV_Ray Library

Before we can start working with POV-Ray, we need to provide it with a library that tells it just how to render the LDraw bricks. This library can be downloaded from the LDraw website under the section POV-Ray Utilities. There, click on LGEO POV-Ray Library and use the link in the upper right corner – it took me a while to find it… download the ZIP File and extract it into C:\LDraw.

L3PAO’s First Start

When you first start L3PAO, it will need to learn about the location of some files – and it will be very insisting. If you cannot locate a file it thinks it needs, it will not start.

The first one it is asking for is l3p.exe – well, we know where that is – in C:\LDraw\L3P – so locate it with the browser and click OK.

Next – if it cannot find it – it is after lg_defs.in – now that one has come with the original LDraw installation and is in C:\LDraw\lgeo\lg.

Finally, we are asked for ledit.exe – and here, I am drawing a blank: I cannot find ledit.exe anywhere – it is not in the LDraw Installation, I have not found a separate download. I know that ledit.exe was the original LDraw Editor – I just don’t know why it is not included in the All-in-one Installer anymore nor why L3PAO needs it – after all, we are using a different editor altogether.

Now, I have come to help myself and just copied an executable into the C:\LDraw directory and renamed it to ledit.exe. In other words: I faked it just to be able to select it when starting up L3PAO… after that, L3PAdd-On comes up.

We will have to look into that a bit more some other time – for the moments, just note that selecting our LEGO 885 Model at the top and setting the Switches creates a POV-Ray file in the specified location. So all that needs to be done is to click the Run L3P button at the bottom…

Because I have installed POV-Ray manually, I have not yet figured a way to have L3PAO locate it properly – so all it will do is create the .pov file in the defined location. So I need to start POV-Ray manually.

Before any rendering can be done for the first time, you need to tell POV Ray where the LGO Library is located: go to Tools -> Edit Master POVRAY.INI and add the following line at the end of the INI-File:

Library_Path=”C:\LDraw\lgeo\lg”

Then save the file and restart POV-Ray. Remember – this is only required the very first time after installation.

Now we can open the generated LEGO 885.pov file in POV-Ray and click the Run button in the toolbar. The result is…stunning. Here is your high-quality rendering of LEGO Models.

Posted in LEGO | Tagged | Leave a comment

LEGO Set 483 – Resurrecting Alpha-1 Rocket Base from 1979

In my previous post, I have discussed the items you need if you want to build a classic LEGO Set on the computer using LEGO Digital Designer as a modeling application. This post is going to take you through a step-by-step example on just how to do that. My set of choice: the Alpha-1 Rocket Base from the classical space theme.

Getting Instructions and Inventory first

The first duty of the builder is to find the instructions – lucky enough, sites like peeron.com have many sets including the sought-after items. Here is the link to the Alpha-1 Rocket Base. The inventory can be accessed from the top of the page where it says Inventory: Available.

Well, everybody can guess what the instructions are needed for – but the inventory? The key to success is the so called Part Number, the unique ID of each individual item used in the set. Having the official LEGO Part Number allows you to search for the item in LEGO Digital Designer directly – no browsing of hundreds of bricks – just typing a number… so let’s get started.

LEGO Digital Designer

First of all, if you want to build a classic set, you need to enable LEGO Digital Designer to used the “LDD extended” Scheme. Otherwise, you will not have access to bricks which have been discontinued or are not available for self-created models.

Once you have done so, you will see a new tab on the LDD’s Home Screen titled LDDextended.

With that selected, click the Free Build button to start creating the model. Looking at the instructions, you can skip the idea of the Crater Base Plate being available in LDD (but that is not an issue). Use Item 3811 instead and focus on the first construction step for the base, Step 2:

We are going to do that “left to right”, starting with the foundation elements of the ramp and then moving on to the control room later.

So we need a blue brick in 1×4 dimension and a rounded brick. Of course, we can start browsing the bricks in LDD but a quick look into the inventory tells us what we need:

On the left-hand side of LDD, make sure you are on the Bricks tab. Type the first part number – 3010 – into the search line. LDD will now display all bricks matching the search criteria – amongst them the Brick in 1×4 Dimensions.

Now we can just drag the item from there and drop it into the assembly area. Sometimes, you will not find the brick by its part number – the #3941 is such an example: is has been discontinued and replaced by a different part number. In such a case, nothing can save you from browsing the bricks manually.

You can now continue with the placement of the Control Room. There is a specialty to Part No 3479 – the four pillars placed on each edge of the to-become ground floor: they mount in between the studs and therefore require the previously mentioned base plate to be used (otherwise, LDD will mis-align them!). Everything done well, your assembly area should look like this:

According to Step 3 of the Instructions, we are now to add the second layer to the foundation items as well as the base plate of the Control Room. Before we do this, however, I am going to quickly color the placed elements of Step 2 so we can distinguish them from the new ones being added in Step 3. It is an assumption but I am using Color 195 of the Legacy Colors: Royal Blue.

Step 3 again from the left to the right shows that of the four elements already placed for the launch pad, we need an identical set to go on top of the existing ones. So instead of placing them brick by brick, we can simply select the existing ones, copy them (Ctrl-C) and then past them (Ctrl-V) to position them accordingly:

Quickly placing the base plate (Part No 3036) and the two Control Wheels (Part No 3829) completes the Step. All manually placed bricks are shown in red, the ones placed by copy & paste are prurple and the ones from the previous step are blue.

The next step – Step 4 – brings us a first “real” problem: the item Hinge Plate 2×5 does not exist in LDD! And it has not been replaced by an equally qualified item either… so we need to consider our options for replacements.

Searching for the term “hinge” amongst the bricks reveals several items that can be considered. Given the eventual use of the item (to hold and flip the vehicle support structure) The one that might come closest is a combinations of Part No’s 4275 and 4276:

It certainly requires the hinge used twice and maybe some stabilize plates around it since this one only has two connector studs on each side which might (when built in reality) be a bit too weak and instable.

However, for the virtual world (where we do not have to worry about stability and statics as everything is connecting and holding together just “magically” the replacement will do the job.

However, in support of the smaller size of the item, the support structure built up in Step 2 and Step 3 needs to be slightly adjusted. The whole construct will then look like this:

The blue bricks are from the previous steps. The purple bricks are from the previous step but have been repositioned to support the smaller hinge. The red bricks have been just added in the last Step.

Next, we are on to Step 5 of the instructions – which will show if our replacement hinge will work with the model:

Again, we are facing an element replacement: Part No 69c01 has now become Part No 9044. I was lucky to find it using the search term “tap”. The other items are straight forward:

In the next step, we can see the computers being placed inside the control room – which is going to be a bit funny for us using the LDDextended scheme:

But first things first – we start on the left again, building up the Launch Pad structure. Adding the four Launch Area Markers and the vertical support structure goes easily – the Part Numbers are correct. Entering Part Number 3039, however, produces the correct brick (actually a Roof Tile) but without the computer image on the front…

Now this is the limitation of the LDDextended scheme – all bricks are basic and need to be colored manually (and being generic, they don’t have special prints either). But there are “computer bricks” available – just in a different scheme!

So save the Launch Pad Project and create a new project – this time, use the DESIGNbyME theme. You will immediately see several bricks for Part No. 3039 – including some that show computer fronts (even if not the original ones we can see in the instructions).

The trick now is to drag & drop them into the drawing area, then copy them to the clipboard and switch back to our space station project.The remaining thing to do is to adjust the color of the “computer” to blue.

The next two steps – Step 7 and Step 8 – are bringing some more elements to the launch support structure and the control room – the only interesting one is Part No 3066 which is a 1×4 Brick without pins – these will – with a transparent color – become the windows of the Control Room. Since both steps have nothing new for us, I will just add the bricks and show the result:

The only thing that sticks out a little bit is the need for an adjustment in the vertical launch support structure: the original instructions show two 2 x 10 plates on the outer side, with an 2×8 and 2×6 plate each on the inner side. Plus, of course, the 2×4 of the original hinge. Since we are using a replacement hinge, you need to adjust the inner plate sequence: 2×2, 2×8 and 2×6.

The next step – Step 9 – is not adding anything we do not know about already – so this is also a quick skip, we are focusing on Steps 10 and 11. The first thing to find out is that the Part No 3956 exists and can be used – but we will have a problem finding a hose for the support structure. Fortunately enough, Part No 3839 exists so we can get the launch support structure worked out just fine.

Last but not least, we need a Rocket… and a parabolic antenna to support flight control. So let’s get at the rocket first:

The Rocket is straight forward – it really only consists of 6 different types of bricks:

  • The Cone – which also serves as exhaust outlet. – Part No  3942
  • The barrel style brick – Part No 6143.
  • The Mini Handle which serves as antennas of the small satellite. Part No 3839.
  • The Antenna – Part No 3957
  • Four of the 1×1 Plates to serve as lights. Part No 3024 and
  • A 2×2 Plate as cover for the lights – Part No 3022.

Putting it all together on the Launch Pad, it turns out that LDD cannot properly place the rocket in the location of the Launch Pad Area – therefore, this is moving one spot away from the support structure. The completely assembled rocket is now placed on the launch pad – red items indicate the addition in this step.

Last comes the Satellite Dish: this is interesting because it brings us three new bricks we have not used yet:

  • The Turntable 2 x 2 Plate – Part No. 3680
  • The 1×2 Hinge – Part No. 3937 & 3938
  • The Satellite Dish – Part No. 3960

Quickly assembled, our Rocket Base is now ready for operations – just awaiting for the crew to arrive…

Fun playing around with old toys in new ways… and so much cheaper than way back when these have been sold… but then of course, it has always been nicer to have the real model to play with… when you were a child…

Posted in LEGO | Tagged | Leave a comment

Call me a kid – LEGO for Men in 2012…

You might want to call me a kid – but then, what’s wrong in being a big kid if it brings some fun and does not hurt anyone? This post is actually inspired by a friend and her three-year old daughter visiting: the kid needs something to play and one of the things I easily grabbed at the local supermarket was a box of LEGO. No particular theme – just a box of bricks but it reminded me of the days when I loved to play of LEGO for hours and hours – stuff that is not available on the market today (unless you have some luck on eBay)… so I started digging a bit.

Finding the old stuff

The first thing that I was interested in is if the “old stuff” can still be found somewhere in electronic format – mainly the images of the boxes as well as the instructions to build the items.

To no surprise, there seem to be a few more “luna”tics our there  (like myself) and the one set I had a great amount of boxes from was what is now referred to as “Classic Space” theme.

The above shows the original logo of what is now “classic space” stylized in a mosaic of LEGO flowers.

In my search for the original LEGO Sets, one of the best sites I came across is a LEGO Wiki – here, you can browse the different LEGO styles and boxes including the set number. I remember, for example, having owned the Beta-1 Command Base, the Alpha-1 Rocket Base and two of the major spaceships – the Galaxy Explorer and the Starfleet Voyager.

So the first part of my question has been answered: there is more than enough information out there on the original (classic) LEGO Themes including instructions (mainly on peeron.com, here the link to the Classic Space Theme) and in may cases an inventory list (which will be quite useful a bit later).

Building it…

Of course, everyone who ever has played with LEGO wants to just “build” the set. So if you are after the rare old ones, you got two choices: you see if eBay has a physical model on sale or you fall back on virtual reality and model the set on the computer.

The LEGO Company itself is providing the LEGO Digital Designer – for free! Although the idea of this program is to allow people to plan, model and then order their very own sets, it is also possible to use it to just to through any instructions and create the model “virtually”. If have done so with the Glider of Beta-1 Command Base to show you an example.

As we will see later, you may have to cut some compromises in the process but once you got used to the LEGO Digital Designer (or LDD as they call it), you can build almost any model out there… almost.

So for now, this is it – it can be done. Next time, I will walk you through actually doing it!

Posted in LEGO | Tagged | Leave a comment

26 Years ago – Writing a Computer Program in 1985

Way back last year I wrote about having aquired a Sinclar ZX 81 home computer on eBay. Back then, I had problems hooking the old veteran up to my modern TV – and I still have. I have – again on eBay – gotten myself an old 5.5″ Black & White TV and hey, I am having a stable but grizzled image of my ZX 81 screen on that box. Too tiny to work with, too bad an image to even imagine how I could ever have spent hours and hours and hours in from it a very similar setup… but good enough to know it works and is in good shape… now, it is time to leap back in time and share a little bit about programming the old classical one with you.

…but using today’s Computer to do it

There is no way on earth that brings me back in front of the ZX 81 with it’s bad image, its notoriously lousy connectors (which usually provided for at least one “involuntary reset” every 30 minutes) and a cassette recorder to save the programs to. But if you want to experience those old days, there are actually a couple of ZX 81 emulators out on the Internet.

The one I am using is simply called 81 (or “EightyOne” if you put it in words) . You can download a copy here.

Secondly, I got my hands on an old CHIP Computer Magazine, published around 1985 or so.

Back then, computer magazines had been a popular source for new programs: because they focused around providing you with Listings of all types to feed your home computer.

I don’t think that anyone today can imagine to buy a magazine, spend hours to type the listings (BASIC or Assembler for the ZX 81) into the computer and then be happy with it. No, today, we are expecting to get all software for free from the Internet – downloading packages that exceed the available RAM on the ZX81 a million times – and much more.

The tiny program I am going to use as an example has been named Rocket-Pilot by it’s author – and I hope, this very author sees it as a tribute to him and all the other ones that wrote software in these days.

What you are seeing on the right side is the actual BASIC listing as published in the CHIP Special Magazine shown above.

You had no other choice but typing the code in – and once you had finished doing that, hoping it would save to what we referred to as the Datasette – an artificial word trying to describe that we had been using simple music cassette players to record our software.

The problem with the ZX 81 was that it did not really have a “keyboard” – at least none that we would recognize as one today. The ZX 81’s keyboard was a plain plastic sheet with contacts beneath the “keys” – so there have been no real physical keys on that system (makes it very hard to “type”).

Making things even harder was the fact the BASIC commands could not simply be “typed” – each command was associated with a specific key and indicated on the keyboard above the key: for example, if you wanted the command PRINT, you had to press the P key (but only once because the computer would have interpreted this single keystroke as a command input.

The commands had actually been referred to as Keywords by the ZX 81’s manual – and the computer showed by the display of its cursor that it now expected a Keyword – it simply displayed a white K on black ground.

This was – by the way – also the entire display when the computer was switched on – switched is actually the wrong word because there had not been a switch: you simply plugged in the power supply to make it go…

The other obstacle to overcome for a modern style programmer is the lack of any type of procedural or even object-oriented programming language! BASIC back then was flat – your program consisted of a set of line of codes which had been enumerated (usually in steps of 10) and your only means of making the computer execute different areas of the code had been GOTO and GOSUB commands. If you try writing that type of code today, being used to objects, properties, methods, delegates, etc. – you may end up wondering how the programmers of that time had been able to provide some of the great software packages of their time like Wordstar, dBase, etc.

Here is my first line of code:

To get there, I had to press 1 to get the line number (1), then E to get the Keyword REM, then a number of spaces to move the text into the next line, then Shift-I for the opening bracket, C for the C and Shift-O for the closing bracket. The rest of the text is simple typing (you notice the cursor is not an inverted L (instead of the previous K)  – the manual does not say anything about the meaning of the L – maybe it means Literal or something like this. Eventually, I should close that line with a New Line to move it up into my listing. I will “quickly” do the next line, then show you what the screen looks like.

To illustrate the simplicity of the human-machine interaction, let’s look at the next line of code:

30 IF INKEY$="" THEN GOTO 30

This has taken me about 5 seconds to write in the blog – on the ZX 81 it goes like this:

  • Type 30 for the line number.
  • Press U for the keyword IF.
  • Switch to the Function level (SHIFT – Cursor changes to inverted F), then press B for the function INKEY$.
  • SHIFT-L, SHIFT-P, SHIFT-P for =””.
  • SHIFT-3 for the keyword THEN which makes the machine recognize the next things needs to be a Keyword (Cursor switches to K).
  • Press G for GOTO, then finish of with 30 and New Line.

Nice, hm? How much easier is the straight forward simple type-it-in approach of these days? We love the Auto-Complete function of Visual Studio 2010 but hey, the auto-complete had been there a quarter of a century ago – and it sucked!

The first lines of code are now in the computer’s memory. A couple of things come to mind:

  • It is absolutely tedious to cope with the approach of auto-complete of these days – typing the code takes soooo much longer…
  • If you want to format the output of the PRINT commands, you need to manually count the characters and insert spaces to enforce line breaks.
  • There are no lower-case letters – everything is always upper-case!
  • Waiting for the user to press any key (and then evaluate it later) is a nice combination of checking INKEY$ to contain any value and GOTO the same line – see like 90.
  • Lines that are committed are not freely editable like to day – there is no mouse to click somewhere into the code nor are there any cursor key to move around. If you want to edit a line, you need to enter the Keyword EDIT and the line number!

Now, that I have spent a good time writing the code, it would have been a great idea to save it – to tape! Just because the ZX 81 was knows for its involuntary resets because of the very simple power plug – no power, no code…

The Emulator makes the life a little bit easier – not much though. You need to go to the Tape Manager, then either select an existing “tape” or create a new one.

Then, on the ZX 81, you need the keyword SAVE – either SAVE “” or SAVE “<Program.bas>” will work. It is then that the recording to the cassette would start (and your program would hopefully save). Speaking of saving (and loading): here is a video of the load procedure for the few lines if code we have written so far: ZX81 loading code.

Code Maintenance

Today, we are telling the programmers to write clean code. Rules apply – like using speaking names for variables. No magic numbers! No more GOTO & GOSUB… wonder where that came from?

I have typed that but I would have to study it to understand what it does… however, it shows the classical dilemma of a programmer of these days: memory was sacred! And every byte we see on the screen costs one byte in the computers main memory. And the ZX81 originally only came with 1024 Bytes (1KB!) of RAM.

There simply was no room for speaking variable names, no room for in-line comments, basically: there was no room for nothing!

 Cashing in…

Eventually, it is time to cash in – the whole program is about 1700 Bytes (which means it only would run if you had bought the 16KB RAM Extension for the ZX 81). It is a very simple game – see for yourself. And click the Screenshot to play the video!

Posted in ZX-81 | Tagged , | Leave a comment