I am interested in writing a game that interprets LXF files into worlds (to create a game such as Lego Universe). After finding out how to extract the LXFML file from the LXF archive, I need to know how to interpret the contained LXFML file. Are there any detailed descriptions of how the LXFML format works?
1 Answer
The LXFML file is an XML document, and there's an XSD document that you can use to validate any LXFML file, along with a textual description of the tags on the LUGNet forums supplied by the LDD Team a few years ago:
The key parts of the LXFML you're going to be interested in start with the <Scene>
element, which contains one or more <model>
elements, which in turn contains one or more <group>
elements, which are made up of <part>
elements.
The tricky part is getting from a <part>
element to an actual model:
<Part refID="0" name="m3680_turn_plate_2x2__lower_part_0" designID="3680"
materialID="1" assemblyID="74340" assemblyRefID="0"
angle="0" ax="0" ay="1" az="0" tx="0" ty="0" tz="0" />
As you can see, the Design ID corresponds to a LEGO element [part:3680] so you'll need some way to get from those to a suitable model - I recommend taking a look at either:
- BricksViewer - A Java app for viewing .lxf scene files - also has a brief discussion of the .lxf and .lxfml formats.
- LDXNA - An XNA library for importing LDraw models - it does include an .lxfml document in one of its examples, but I don't recall it using it - however it does show you how to convert the LDraw parts library into a usable format.
-
2There has been a change in the LXFML file. I didn't check since which version, the change was applied, but LDD 4.3 (Sep-2018) has a different structure. e.g., <Part> is now <Brick> and attributes angle, ax, ay, az, tx, ty, tz are now a single transformation attribute– RaamEESep 26, 2018 at 14:59
-
-
1@tommy.carstensen I believe the
ax
,ay
andaz
denoted the axis of rotation, and thentx
,ty
andtz
are the "transform" or positional axis. Oct 3, 2022 at 16:18