Hi -

I am currently writing a python script to export models from the Lego modeling program LDRAW to another program – currently I do not know which one, but it will most likely be Blender.

An LDRAW file includes different types of lines, as follows…

For a line (linetype 2):

2 color x1 y1 z1 x2 y2 z2

For a triangular face (linetype 3):

3 color x1 y1 z1 x2 y2 z2 x3 y3 z3

For a quadrilateral face (linetype 4):

4 color x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4

where (xi, yi, zi) are points. These are easy. The hard part is the linetype 1 statement, which allows you to include another LDRAW file in the current file. It looks like this:

1 color x y z a b c d e f g h i part.dat

where fields x through i fit into a standard transformation matrix:

[ a b c x ]

[ d e f y ] = [T]

[ g h i z ]

[ 0 0 0 1 ]

[locx ]

[locy ] = [P]

[locz ]

[1 ]

and a position [P] in homogeneous coordinates is transformed by:

[T] x [P] = [P’]

I have already written the recursive code that processes all LDRAW files included at any level in the file being exported, so that is not a problem. The problem lies in the transformation matrix – it is a combination of rotations about the x, y and z axes, and nonuniform scales about each axis. Correct me if I’m wrong, but I cannot recover any of the Euler rotation angles or any of the scale information from the matrix if I do not know any of it to begin with.

Is it possible in Blender to enter a transformation matrix directly, or do I need to write the script to transform all of the points before importing? (I am pretty sure it’s not possible). If it isn’t possible, is there any format that does allow matrices to be entered directly?

[Eeshlo – do you have any quick advice on using the Lightflow ASCII or binary formats?]

Thanks a lot guys -->

Matt