16

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
    Note 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 9 '12 at 9:26
14

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:

LXF files - info and XML schema

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.
  • 1
    There 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 – RaamEE Sep 26 '18 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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