Page 1 of 1

Importing LEGO models into Blender/etc for rigging/animation

Posted: 06 Nov 2014, 03:18
by Stryker295
It's a much more complex process than it should be ._.

Thankfully, with the assistance of a friend, and many hours spent in MLCad/LDraw, we've finally ended up with this:
Image
(Full resolution available here.)

For now, setting up the cables and plugs was too difficult, so I doubt we'll put any sort of cables in the finalized renders, but after fully rigging the model (even going so far as to ensure the gears meshed correctly), we've determined important information such as what the range of motion for each joint is, what the full reach area is, etc etc.

It was a long process getting to this point, though. Unfortunately, I don't have access to my LEGOs right now. They're on the opposite side of the country at my parents' place, and I don't have the money to travel back and pick them up, and they're not willing to send them out, so for now they're just sitting in a box in a closet.

Because of this, I've had to do all the planning, engineering, and trial-and-error with a few sheets of paper, a pen, and my laptop. MLCad and LDraw have been absolutely indispensable throughout this project, and I'm really glad for them. Interestingly enough, after doing a few weeks' worth of testing and correcting design errors just via LDraw, a few more updates were made even after it was imported to Blender, but this is a nearly-finished render.

I'm very excited about this project, as I've never tackled something so challenging, but it's been a very interesting experience working entirely with a virtual model. Hopefully I'll be able to animate this in Blender and use the animation process to help further my code a fair bit, as animating the unit will translate roughly into the actual code I need for a proper inverse kinematics system! :D

Anyways, I wasn't sure where to post this, but yeah. It's been an interesting journey. A lot of the normals/faces on these model parts are backwards, so fixing those in blender was a hassle but very much worth it. No post-processing has been done on this picture, either; the blur effect was entirely done in-render. I'm very happy with the way things are progressing, and once I eventually get my hands on my old unit, I'll be able to fire up BricxCC and get back to work coding!

Re: Importing LEGO models into Blender/etc for rigging/anima

Posted: 06 Nov 2014, 05:30
by mightor
I didn't realise that wasn't a photo until I reread the subject :) That's a pretty good render, nice job! The fact that you managed to figure out how to use Blender without killing yourself in the process is a pretty amazing achievement in itself.

Maybe you could do a write-up about how to do this, so that others can learn from it, too!

= Xander

Re: Importing LEGO models into Blender/etc for rigging/anima

Posted: 06 Nov 2014, 05:53
by Stryker295
mightor wrote:you managed to figure out how to use Blender without killing yourself ... Maybe you could do a write-up about how to do this!
I swear I came close several times xD

In all seriousness though. It was a process of about two to three weeks, spending very late nights at a friend's house 'cause he's the blender expert. Initially I was just using a process like this:

Work in MLCad, save file.
Open with LDraw, export as STL.
Import into Blender!

Unfortunately this had a flaw: any multicolor part, such as the motors, sensors, and NXT brick all imported incorrectly, and the differently colored part (everything but the white bits) would simply not exist. We tried exporting as 3DS files instead of STLs, but those took up a LOT more space, and kept crashing his computer, which is a several-thousand dollar kick-ass gaming desktop with 16gb RAM and 2gb dedicated VRAM per video card, which he has two of.

Eventually we realized that the current version of blender has support for .ldr files, assuming you install the LDraw parts library to a very specific location. Once we did that, our workflow changed into thus:

Work in MLCad, safe file.
Import into Blender!

Unfortunately, since a lot of the faces are backwards due to people rushing through the job of modelling several hundred thousand lego parts (who can blame them though), we just turned on some function in Blender that showed the back faces in one color and the frontfaces in another one. Then we were able to click on every single face that was backwards and manually invert them.

Once all the faces were arranged correctly, shading worked dramatically better, and there weren't random holes in parts (like gears and motors).

After parenting some parts and using a few simple scripts to get the gear ratios right, we have (almost) the whole thing fully rigged. All of the basic movement on all three axes works great, and everything is constrained to the actual physical limits of the model. Hopefully next week we can work on the touch/pressure sensor assembly and get that rigged, that'll be the last thing before we can officially start animating it.

Edit: It does look very much like a photograph, but the grey chunk of the NXT Brick is slightly off-colored, which is the only quick indication it's a render xD

Re: Importing LEGO models into Blender/etc for rigging/anima

Posted: 06 Nov 2014, 08:25
by mightor
That's a lot of work, but the results speak for themselves!

Nice job :)

= Xander

Re: Importing LEGO models into Blender/etc for rigging/anima

Posted: 06 Nov 2014, 22:39
by Stryker295
Indeed they do! The most complicated part, honestly, was just getting all the pins, connectors, and axles correctly positioned. Over 60 of the black 2-length technic pin with friction were used, and over 270 parts total were used, which puts this at one of the more physically complex designs I've done on a computer.

Getting the whole model from a pair of concept sketches to a fully-finished .ldr file was the most difficult part, I think, but now we've got it finished and to the point we can work on actually rendering real animations. Hopefully those results will be even better!

P.S. Using an android's native camera to capture a photoshpere for the 3D environment is... not a good idea, heh. For some reason it just can't patch up the images very well, even on a flagship Nexus device. Once we get that working (I'll be trying on an iPhone soon) we'll be able to officially publish renders.

Re: Importing LEGO models into Blender/etc for rigging/anima

Posted: 07 Nov 2014, 18:34
by haydenstudios
That's some pretty neat work you've done there. I remember importing some of my LDraw models into Blender. I was never motivated to do much other than correct the colors and set the camera and lighting up for a render though. That's very impressive that you had the patience to rig the model up. I'm eager to see an animation made with it.

Re: Importing LEGO models into Blender/etc for rigging/anima

Posted: 10 Nov 2014, 04:03
by Stryker295
Major update! I finally learned how to do all the Blender work myself, so I'll be able to pump out some more renders within a week or two, if all goes well. Unfortunately I had to start over from scratch, so I'm using my more recently-updated model for renders, and I have to go in and fix all the errors with the Normals being inverted in some parts.

Also I'm running on a netbook with a surprisingly decent graphics system and 8gb RAM, so while it's no 32gb RAM beast with two identical video card beasts like my friend's computer is set up as, it's still actually capable of handling things better than I expected.