I've been taking a look at the structure of the LDD files recently to see if it's feasible to create a plugin for 3D studio max that allows you to directly open LXF files for higher quality rendering...

It seems possible, but to get some preliminary tests happening I just need to understand exactly how the transformation string works:


It seems pretty obvious from playing around that the last 3 relate to the position of the piece, and the first 9 somehow relate it's rotation (and perhaps 1 or 2 other things I'm not aware of yet). If anyone knows I'd love a detailed explanation as it would save me a LOT of messing around =)

Also are there any good resources of info on lxf files? I have only come across fairly basic stuff so far, would love to find a good resource...

2 Answers 2


There's a fairly in-depth discussion on the Eurobricks Digital Designer Forum in the post Understanding LDDs LFXML Schema, where the transformation element is defined as:

Transformation contains 12 comma separated double precision floating point values that represent the first three columns of a 3d transformation matrix and are thus able to handle any linear transformation. It's something that you'll need to learn for yourself but the first 9 entries handle rotation, the last 3 are translation. It's worth noting that the origin of most bricks is at the bottom with the y-axis heading up through the center of a stud, this makes rotations around the axis of the stud slightly easier. Brick width is 0.8, brick height is 0.96 and plate height 0.32. This probably ties in with real world dimensions in some form, but I don't have the details to hand. The double precision floating point format can't necessary cope with precise decimal values as we might expect to see them, therefore you'll see slight deviations from the values given above, eg. -0.79999935626983643 instead of -0.8. Those 0.707 values are 45 degree rotations, they correspond to the sin or cosine of 45 degrees (or PI/4 in radians) and are part of the transformation. Transformations are in world coordinates.

As Philo points out in the comments, the values that The_Cook queries as "probably ties in with real world dimensions" are indeed the sizes of bricks in centimetres, which means you should be able to transform between systems nicely.

In response to your final goal (building a plugin for 3ds Max) what you're really going to need is a complete set of high-quality meshes - the LDD format works with part models rather than vertices/faces/edges/etc. that 3ds uses. Therefore what you'll probably want to take a look at is a tool to convert from LDD to something like LDraw (you could just use the "Export" function in the LDD file menu), and then use the LDraw model library as your basis for importing into 3ds, or use the features in LDView to export to .3ds (the older, text based file type 3d Studio used before it became "Max").

  • 2
    "Brick width is 0.8, brick height is 0.96 and plate height 0.32.": These are dimensions of bricks in centimeters...
    – Philo
    Commented Jun 2, 2014 at 11:30
  • Good catch, indeed we've covered those nicely on What are the dimensions of a LEGO brick, but it's nice to see that internally LDD is using real world units as well - makes converting easier ;) Commented Jun 2, 2014 at 11:47
  • 1
    Thanks for the info and link, just what I was after =) I've been building a max part library for a while by doing exactly that - importing parts in .3ds and completely rebuilding them for best use in max... hopefully have something fun for others to play with one of these days
    – Phil
    Commented Jun 2, 2014 at 12:57

The 3 last values in the transformation attribute are the position of the brick in 3D space XYZ. Simple.

The interesting part is the first 9 values in the transformation attribute

<Rigid refID="0" transformation="0,0,1,0,0.99999910593032837,0,-0.99999988079071045,0,0,-0.39999967813491821,0.40000063180923462,1.2000013589859009" boneRefs="0"/>

They are read as a 3x3 rotation matrix (in-depth explanation: Wikipedia Rotation Matrix)

[a1 a2 a3]       [ 0  0  1]
[a3 a4 a5]  ==>  [ 0  1  0]
[a6 a7 a8]       [-1  0  0]

In this case, this is a single rotation around the Y axis, as the axes directions are:

enter image description here

So if you describe the rotation of the brick as yaw, pitch, roll you can say that this matrix describes a 90 degrees yaw clockwise. A 90 degrees yaw counter clockwise is considered a turn of -90 degrees. (clockwise and counter clockwise are probably not the right terms to use here. I am using to make the description easier to understand)

as long as the brick does a single 90 degrees yaw, pitch or roll, it is simple to detect the rotation axis, because there is a single row in the matrix that remains the same, see section Basic Rotations. In the case of rotating around Y axis, the middle row [0, 1, 0] doesn't change.

Rotating around X axis, keeps the 1st row unchanged [1, 0, 0]

Rotating around Z axis, keeps the 3rd row unchanged [0, 0, 1]

So, rotating 90 degrees around the Y axis is (2nd row is 0, 1, 0 as described above)

[Cos90   0   Sin90]
[0       1   0    ]
[-Sin90  0   Cos90]

If the transformation is a combination of rotating around 2 or 3 axes, the matrix is not trivial to read and is a matrix multiplication of 2 or 3 of the above matrices with the respective degree of rotation around each axis.

Turning the brick to 90, 180, 270 degrees in each direction, results in values of 0, 1 or -1 for each cell in the matrix. These are the results for the Sin and Cos functions for 0, 90, 180, 270 degrees.

last point to consider:

If you get values that are not 0, 1, -1 there are two options:

  1. LDD has a slight miscalculation (This is not a confirmed fact, only my opinion). You can see in the attribute at the top of the post that one of the values is 0.99999... which is basically 1, so it's a 90 degrees turn.
  2. You turned a LEGO object in an angle which is not a multiplication of 90 (e.g. hat on top of a head turned 30 degrees clockwise)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.