I forgot my camera when I went to the lab today, so photos of my Lego Laser Scanner will have to wait.
In the meantime, I spent the early evening figuring out how to use the LDraw tools to draw and animate Lego constructions. To start, I simply made a figure of the four angled liftarm pieces using MLCAD. There are some nice tutorials for using MLCAD that I described in a previous posting.
I then converted the LDRAW file format to the ray-tracing POV format using L3PAO. From there I was able use POV-Ray to access the POV script and modify it to make the animation. The animation was performed by following the Rotation Animation Tutorial by OrionP.

The key is to go into the POV file near the end and find the object commands. Here is one of the four (for my four Lego pieces):
object {
_32009_dot_dat
matrix <1-SW/98,0,0,0,1-SW/20,0,0,0,1-SW/178,SW/2.45,0,SW/-2.225>
matrix <1,0,0,0,1,0,0,0,1,38,23,-2>
#if (version >= 3.1) material #else texture #end { Color0 }
The second matrix specification has two parts:
1,0,0,0,1,0,0,0,1
and
38, 23, -2
The first part is the 3×3 identity matrix, and the second is a translation.
To rotate the pieces, simply remove the translation. Then apply a rotation about the objects center of mass, then translate it. The code looks like this…
object {
_32009_dot_dat
matrix <1-SW/98,0,0,0,1-SW/20,0,0,0,1-SW/178,SW/2.45,0,SW/-2.225>
matrix <1,0,0,0,1,0,0,0,1,0,0,0> rotate<0,0,45> translate<38,23,-2> translate<0,-50,0>
#if (version >= 3.1) material #else texture #end { Color0 }
This will rotate the piece about the z-axis by 45 degrees.
To make an animation, we simply replace 45 by clock (or clock * some number). POV has a variable clock, which advances in time with each rendering. This will increase the rotation.
To pull this off, you need an .ini file. Following OrionP’s lead, this is what mine looks like:
; Animation INI File
Initial_Frame=1
Final_Frame= 30
;Subset_Start_Frame = 1
;Subset_End_Frame = 30
Initial_Clock=0
Final_Clock=360
Width=350
Height=262
Cyclic_Animation=on
Pause_when_Done=off
Output_File_Type=N
; T – Uncompressed Tar 24-bit File
; N – New PNG (portable network graphics) format
; S – System-specific such as Mac Pict or Windows BMP
; C – Compressed Targa-24 format (RLE, run length encoded)
; P – Unix PPM format
Antialias=On
Antialias_Threshold=0.3
This gives me 30 frames with the clock going from 0 to 360 (around the clock so to speak).
To get POV-Ray to use the .ini file, you have to click on the ini icon and set the ini file.
Then run it!
I then took the 30 .png images and converted them to gifs in Adobe Photoshop.
Last, I used Adobe ImageReady to put the gifs together into an animated gif.
This is admittedly a crappy tutorial… its late!
So I promise that I will write up a more detailed one in the near future.
In the immortal words or Tor Johnson, “Time for go to bed!”
Kevin Knuth
Albany NY
Posted under Fun, Lego, Software, Solutions