ldr file format for models

ldr file format for models
Hi all.

I want to write a script for Modo that parses the ldr file for exported models. I'll use the info to instance and position parts I've already imported and cleaned up in Modo.
I kind of understand the file format eg
1 72 0.097007982432842255 -8.004612922668457 -59.886787414550781 1 0 0 0 1 0 0 0 1 4282.dat
I understand the 1 and 72 and the 4282.dat, but I'm more used to seeing position, rotation and scale values which the other values don't seem to fit the pattern of (too many numbers).

Anyone care to enlighten me? Would be greatly appreciated.
Many thanks
Re: ldr file format for models
The first '1' is the line type (reference)
72 is the color
next 3 numbers are the position
next 9 numbers is the 3x3 orientation/scale matrix.
and 4282.dat is the 'thing' you need to render/process at the given location/orientation using the given color.

See also


Hope this gets you started.
Re: ldr file format for models
Just jumped back onto this..

Thanks Roland.
I understand a bit more now and should be able to process those lines in Python.
One question though. Is there any way to know the starting orientation of a lego part? I have a library of parts that I have cleaned up and the idea is to read the ldr file and use parts from my library rather than the ldraw parts. The only issue is that my library parts need to line up with the starting position of the ldraw parts, otherwise it will all be a bit messy.

One solution is to import each part I'm using through the Blender plugin and use that as a reference to re-align by hand. But it would be much more efficient if I could read and process the ldr files to figure it out.
Many thanks
Re: ldr file format for models
the starting orientation of a part is the one in its .dat file.

for example, a line from 0/0/0 to 1/0/0 is just there.

there is no other information source about e.g. a different rotation or positioning of a part.

a part is where it is. all about it is coded in its .dat file.

there is an ongoing discussion if we should add such positioning info to our syntax,
so we are able to change that default orientation and positioning even when a part has become official
without having to touch its geometry. however, that syntax has not yet been agreed on, or implemented:
Re: ldr file format for models
There is some human logic to the origin/rest rotation of most LDraw parts. But I don't think you could use those rules to automate conversion transformations.

Far as I know the only thing you can correct for automatically is the negative y axis. This is done by rotating e.g. 180 degrees around the x axis.

Other differences you will have to put in some kind of pep part transformation look up table I guess.
« Next Oldest | Next Newest »

Forum Jump:

Users browsing this thread: 1 Guest(s)