Jump to content

Another LEGO Digital Designer G to OBJ converter


lol username
 Share

Recommended Posts

@M2m got me curious about playing around with .g files myself, with his converters and various scripts. I remembered Simon from the LU community had made a .g importer script for Unity some time back, so I got it from him, and tidied it up + expanded on it some more (added support for .g1/.g2/etc files, and UV coordinates), then rigged it up to some obj exporting code. Mostly just for the fun of it, and also cause I hadn't done any binary file reading before, and it seemed like a good chance to see how it worked.

 

Here's the result, a standalone program that can convert LDD .g bricks to OBJ:

 

https://github.com/Terrev/G-to-OBJ/releases

 

 

rINsPHT.png

 

F0r3YNM.png

 

eJZ6IW2.png

 

Mopptnf.png

 


 

On my machine, it converts all 4186 bricks in the LDD library in 1 minute, 2 seconds. I have a solid state drive; it will probably be a bit slower on a mechanical hard drive but still fairly fast.

 

I was thinking of rendering out icons of bricks too, but couldn't think of a practical use for myself, and anybody who'd want that could do it themselves with their program of choice.

 

If you use this on bricks from LDD (as opposed to, say, .g files from LU), be aware you should be using the contents of db.lif in AppData, NOT Assets.lif in Program Files: https://www.rockraidersunited.com/topic/7899-ldd-updatingpatching/

 

To extract LIF files, I recommend: https://github.com/JrMasterModelBuilder/LIF-Extractor/releases

Link to comment
Share on other sites

On 2/24/2019 at 2:21 AM, M2m said:

That’s great. You should enhance it to an LXF to OBJ converter. 

Maaaaaybe... Once I have some more free time.

 

Also, fixed the conversion times, just gonna copy-paste my Eurobricks post for the rest of this: 

 

It turned out to be a simple problem not even with my code particularly - Unity's Mesh class was slowing it down. In the 3DXML to OBJ project, I'd made my own minimalistic CustomMesh class used for most things instead, because back then, Unity couldn't accept meshes with more than 65535 vertices (mesh index buffers could only be 16 bit; it now supports 32 bit index buffers as well, which can have up to 4 billion vertices). When I did this project, I thought "oh, I can just use the normal Mesh class now", but apparently that led to it doing who-knows-what entirely behind the scenes when the OBJ export code used those meshes. I went back to a simple CustomMesh class, and now the entire LDD brick library (4186 bricks) converts in 1 minute, 2 seconds on my machine - much better than the previous 11 minutes, 22 seconds.

 

New release available at the link in the first post.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.