PDA

View Full Version : Bullet Physics and Legos



wyattharris
06-04-2012, 10:54 AM
I'm participating in the latest FXWars challenge over at CGTalk which is basically smashing CG Legos (more or less :D) and I've got a few questions.

I've been doing test sims with boxes which is easy enough but when I go with the lego models things get a bit screwy. If I set the type to mesh the stack explodes any time its acted upon by a rigid object. If I set it to box the parts that overlap shoot away from each other when activated. That actually makes sense but doesn't help me.

1. I'm experimenting with the mesh settings but haven't found anything promising yet. If anyone could point me in the right direction that would be helpful.

2. Would it be possible to set the type to box and make the cube part active but set the pegs on top of the Lego as transparent to physics? Not sure if that can be done.

wyattharris
06-04-2012, 12:48 PM
First problem worked out. I modeled the Legos to scale and of course tiny objects act crazy in bullet. After increasing the size about 1500% its working much better. Not the result I was going for but maybe better.

wyattharris
06-05-2012, 02:52 PM
Hey everybody, so I figured out how to get this to work. All it took was running the sim dozens of times tweaking the settings until I finally stumbled on the one that seemed to work. No problem. :D

I do like how fast Bullet is and that it works very practically. What I mean is at one point I added a Lego ground plate to test it and it worked pretty close to how I expected.

Anyway, here is the rendered result.
http://www.youtube.com/watch?v=XRtjYvRcF3w

And here is the R&D.
http://www.youtube.com/watch?v=G3tm4MGraQc

Nangleator
06-06-2012, 09:47 AM
Thanks for fighting the good fight!

It's encouraging that Bullet is fast enough that you can just experiment without fear of endless calculations.

Amurrell
06-06-2012, 04:49 PM
Still looks like there are quite a few sponaneous reactions going on, but a lot better than what you started with.

Mr. Wilde
06-10-2012, 07:25 AM
Looks good. But I think one of the problems is: you would not be able to do that in real life. A Lego cube like that is stable as hell. You would have to destroy the bricks if you want to smash that structure. So that might be a reason why you don't get a simulation that gives you what you want.

Cryonic
06-10-2012, 01:13 PM
Yep. You'd have to chip away at the bricks from the top down because the way they are overlapped makes the wall incredibly tough against the bricks just popping apart like that.

jwiede
06-10-2012, 03:46 PM
Hey everybody, so I figured out how to get this to work. All it took was running the sim dozens of times tweaking the settings until I finally stumbled on the one that seemed to work. No problem. :D

I do like how fast Bullet is and that it works very practically. What I mean is at one point I added a Lego ground plate to test it and it worked pretty close to how I expected.

Anyway, here is the rendered result.
http://www.youtube.com/watch?v=XRtjYvRcF3w

And here is the R&D.
http://www.youtube.com/watch?v=G3tm4MGraQc
I think your problem might have been that Bullet was giving you physical reality, it just wasn't what you wanted. A Lego box like that would more likely separate from the floor as a unit, than come apart into bricks. Their extreme stability when assembled is one reason why Legos are so popular.

Looking at the anim, even if I could accept bricks coming out when hit by the ball there's no way I'd accept that bricks still attached would separate and detach based solely on the weight/imbalance of other bricks. You can pick up a big Lego structure by the top brick and still not have it detach, those connections are *strong*. A few bricks' weight being enough to pull others apart looks very wrong to me.

It's a nicely rendered anim, don't get me wrong, but the physics look way off to me. Legos attached IRL just do not behave as "loosely" as those in the anim, esp. when attached at both top and bottom.

Then again, the whole challenge seems to be about physically simulating and rendering Legos moving in physically-improbable ways, so...(shrug)

wyattharris
07-14-2012, 01:44 PM
Thanks everyone. I agree with all of your critiques but in this case I think its a matter of form over function. I was going for a look similar to the Lego games where Legos blow apart without too much effort. The reduced model I'm using to cut poly count would also not give nearly as much stability as the inner bits are gone. But I don't disagree with you guys at all.

So here is today's problem and the deadline is looming.
I built a new scene:
Building similar to the above
Missile with a particle emitter attached for exhaust
Bullet physics on both
The missile shoots through the building and Lego bricks go flying

I got the whole thing perfect and animating properly. Saved and went to eat lunch while it created a preview. I came back, preview looked good, so I started working on the next bit which was just another building similar to the first.

In modeler I saved the first building as a new object and made my modifications on it. I went back into Layout and realized the Hub had replaced my existing building with the new one. No problem, I just reloaded the scene and the original configuration is back.

Here's the problem. For whatever reason the missile and the building will not see each other using dynamics. As in the missile still flies but goes straight through with no effect.

I've removed physics on all objects and added it back. I've gone as far as removing the object from the scene and adding it back. I deleted the Dynacache thinking maybe it got pointed at the new object. No change so far. I can recreate the scene again but what is causing this? If I need to work on a scene from start to finish without reloading that's fine but I just need to know if that is what the real problem is.

Thanks for any help. Clock is ticking. :D

wyattharris
07-14-2012, 02:47 PM
I recreated the entire scene and the problem still exists. So I was quite confused. BUT THEN...

I see the problem.
I ticked the "draw collision shapes" check box and the missile's collision shape is back at the origin. Almost like it didn't follow it's parent. I did load the missile and all of its pieces from another scene so perhaps that's it but it worked the first time. Not sure why reloading the scene screwed it up unless you have to re-keyframe your objects everytime for bullet.

Any ideas?

wyattharris
07-14-2012, 03:24 PM
So got it all fixed, the collision shapes are where they are supposed to be. Got the scene back to perfect. Before I moved on I wanted to make sure what to expect so I saved and reloaded.

First the missile and its parts are no where to be found. After searching a bit I disabled dynamics and, tada, they popped back where they are supposed to be. So it looks like the key frames on rigid objects are being saved as their dynamic values instead of their actual keyframes... I guess. Funny thing is the collision is still right so an invisible missile smashes through the building. So I turned off bullet on the missile parts, turned them back on and the keyframes are correct again. But guess what, the collision shapes are back at the origin AGAIN! :cursin:

Oh this is fun. :D Just a matter of learning what to do to fix that which gets broken.

juice
07-15-2012, 03:40 AM
great work and great reference you did there

wyattharris
07-17-2012, 01:07 PM
Hello folks, well I'm done. In the end I found no solution for the collision shapes problem. So what I ended up doing was setting everything up on my workstation, saving, reloading on my render box and deleting and resetting up all of the dynamic elements then rendering right then.

I haven't loaded v11 sp2 yet so don't know if its addressed. Otherwise I'll file a bug report.

The final animation is here http://youtu.be/mrGo0856bB0.
Voting goes up Friday or Saturday it sounds like, so stop by the FXWars page and check it out.

robertoortiz
08-01-2012, 11:26 AM
Congratz Wyatt on winniing the challenge.
:)

monovich
08-01-2012, 11:33 AM
Great job! That is a whole lot of physics going on and way to thread a story in there too instead of simply blowing stuff up.

jeremydk
08-02-2012, 07:30 AM
As a lego fan and builder (and Danish) i am shocked to see hollow bricks ! :)
Just kidding.

Try and have a look at a program called LEOCAD. It has 4000 3D Lego bricks
in the database and i believe you can export them.

Nice work.

edit: ah,, you finished already.

wyattharris
08-03-2012, 10:18 AM
Thanks Roberto, that challenge was tons of fun on a bun.
This has really rekindled my joy for doing 3D.


As a lego fan and builder (and Danish) i am shocked to see hollow bricks ! :)
Just kidding.

Try and have a look at a program called LEOCAD. It has 4000 3D Lego bricks
in the database and i believe you can export them.

Nice work.

edit: ah,, you finished already.
Thanks Jeremy. I had actually modeled very accurate Lego bricks but the poly count would have been astronomical so I scaled way back and removed all of the inner bits. Now I'm curious how they would behave in Bullet if they were accurate. May have to run some new tests.

DonJMyers
08-03-2012, 11:43 AM
Making each brick 1 meter in size might help the calc if you originally made them too small.

50one
08-03-2012, 11:59 AM
Saw your entry over @ Cgtalk, neatly done. Congrats!:thumbsup: