This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

Builderboy2005
Builderboy2005 presents ...

2009/3/20

Softbody Physics

Each line represents a spring, connected at points. You can move the object around with the arrow keys, see how it reacts to the world.

This could be expandabe to any object.

10838 views / 27 in the last 7 days

23 votes | 0 in the last 7 days

Tags: simulation physics with-source spring softbody

This scenario is a member of: Reusable actors & support classes


open in greenfoot
Your browser does not support the canvas tag.
mbreadmbread

2009/6/21

Cool! Just goes to show some of the advanced things you can do with Greenfoot. Seeing some games making use of this would be great too.
DonaldDuckDonaldDuck

2010/10/27

Another nice demo Builderboy. Say, I was considering making a "Jelly Car" like scenario. Would you mind if I use this as a starting point?
Builderboy2005Builderboy2005

2010/10/27

Sure use all the code you need :D
DonaldDuckDonaldDuck

2010/10/28

Thanks =D I was going over your code and I was just wondering (I'm no expert with doubles) if, instead of drawing the lines for the image, you could draw the lines onto the actor and move the actor itself... Just to clarify, instead of having double x as the X location on the image, I'm trying to make it so that it does something like setLocation(x, y) so that I can find if another actor intersects... I'm not great at explaining stuff like this, I'm only 13, so, it's not a wonder. Thanks again Builderboy.
SPowerSPower

2012/7/15

Could you also add gravity? That would make it even better!
Gravity would be trivial to add ^^\
DutaDuta

2013/1/1

In the spring class, it would make the code more readable to change the places where you do "Math.sqrt(Math.pow(someValue, 2) + Math.pow(someOtherValue, 2))" to "Math.hypot(someValue, someOtherValue)"
UpupzealotUpupzealot

2013/6/22

Hi, BuilderBoy. This scenarios is awesome. I'm looking into soft body these days. May I ask, how did it expands to other shape. I looked into your code and find out it was based on the "mass point - spring net" model. If it is a shape with N sides, the number of springs would come to N(N - 1) / 2 (if you put a spring between every two mass points), when N is lager than about 30, things became slow. I search on the internet and find there is an other model called PSB(pressure soft body), it's similar with this one, but the amount of calculation is much less(I think it's about 2N). I tried PSB in greenfoot, but the the effect is not ideal. I thought I'd better share the infomation with you(or anybody who was interested in soft body simulation), hope we can have a better model one day.
DutaDuta

2013/6/22

Upupzealot, if you're interested I did a rewrite of this scenario: http://www.greenfoot.org/scenarios/7158
UpupzealotUpupzealot

2013/6/23

@Duta thanks for replying. I looked into your code. You were using the same model with this one.For the JellyPentagon class, you build 10 springs in a soft body. As I said, it would need N(N - 1) / 2 springs for a shape has N sides. When N comes lager, the scenario comes slow. I was looking for another model which is better. It's called "Pressure Soft Body" which suppose there were some ideal "gas" in the soft body to support it.

See all comments

Want to leave a comment? You must first log in.

Who likes this?

Noobopanda RcCookie DarkMageCkmario Entity1037 davemib123 Upupzealot FlyingRabidUnicornPig gberard Game/maniac bkellermann SPower thegreencoolerman nooby123 GershiBelshi GameCode DonaldDuck mik JSB1992 qnanqing Ninto