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?
Asked
Active
Viewed 4,502 times
18
-
1Note that while LU had a number of LEGO models in it, the world as a whole wasn't made of LEGO elements - the landscape was still a standard "terrain mesh" type of thing. – Zhaph - Ben Duguid May 09 '12 at 09:26
1 Answers
13
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.
Zhaph - Ben Duguid
- 19,551
- 6
- 78
- 151
-
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.,
is now – RaamEE Sep 26 '18 at 14:59and attributes angle, ax, ay, az, tx, ty, tz are now a single transformation attribute -
-
1@tommy.carstensen I believe the
ax,ayandazdenoted the axis of rotation, and thentx,tyandtzare the "transform" or positional axis. – Zhaph - Ben Duguid Oct 03 '22 at 16:18