Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

In my opinion - one of the coolest simulations!

NotificationsYou must be signed in to change notification settings

ZERDICORP/soft_body_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

In my opinion - one of the coolest simulations!

What can you say about it? 🙋

I have only two words for you: INCREDIBLY COOL!

I've always wanted to create some kind of simulation related to physics.
And finally,I did it!

P.S. The work I have done is not perfect.
I didn't go deep into formulas.
I didn't try to create a comprehensive universal soft body engine.
Not at all.
I am driven only by wild curiosity, what are you talking about? :D

How it works? 🐣

Everything written below is just acrooked interpretation of the coolest articles onsoft body physics.
Want two-page formulas and buzzwords? Google it! :3

Who seeks will find.
Whoever goes will come.
Those who google will not notice the answer in the first link.

#1 ~ «Introduction»

Well, let's understand howsoft body simulation works.

First, we need to understandwhat the body itself is. And by the way, it won't take long to find the answer (that's why I'm here lol):

  • Particles

Yes,particles are everywhere.
It is from these little freaks that everything around us consists: the phone that you hold in your hands, and the hands themselves.

And, you know, if you want to create asoft body, you don't have tobeat around the bush -steal the idea from nature!

#2 ~ «Particles»

So, okay, we have particles. But what exactly are they?

Here is the basic set of properties for eachparticle:

  • location
  • velocity

I mean, it's pretty primitive.
We have a particle location(x, y) and avelocity vector.
It remains for each frame to update the location, adding velocity to it.

It's all? Do we have a soft body?

Lol, no.. :D

#3 ~ «Springs»

Having onlyparticles, you can get, for example, agas, but obviously not asoft body, because, as you know, a body is a body, because it is anordered set of interconnected particles (crystal lattice).

And, if we were making a regularrigid body, we wouldn't even have to tie anything.
But here's asoft body..
It should behave likejelly, or any othersoft object, that is,deform, and then recover.

And the«Spring Mass System» will help us to achieve this effect.

I will not retellsmart definitions from Wikipedia, but I will explain in simple words:

Our task is tosplit the particles into pairs. Each pair forms aspring.
Next, we need to go through all thesprings (pairs of two particles) and, based on some data, calculate thenext position of the particles in space.

Thus, theparticles become bound to each other.
And thesystem of spring masses allows you to achieve the effect ofjelly, since when the particles move away from each other, they are forced to move towards each other (spring compression), otherwise, if the particles are too close to each other (closer than a certain distance /state of rest), they forced to move in opposite directions (stretching the spring).

Summarizing the above, we have:

  • Particles
  • Springs (a pair of two particles)

This is actually enough to create asoft body.

#4 ~ «Soft body»

Well, let's briefly go through the main steps:

  1. Createparticles.
  2. Connect them withsprings.
  3. Iterate through the springs every frame and apply allsorts of tricky formulas to achieve the spring effect (move away the particles - they return to each other; bring the particles closer - they push each other with all their might; stretch the spring and release it - it will contract and stretch, makingharmonic oscillations, until it reaches astate of rest).

Apart from thespring mass system, you will probably need agravity simulation (just add a constant to the y-axis of the velocity vector every frame), acollision resolution algorithm (because you don't want your soft body to fall forever) anda lot of curiosity (no way without it)!

Demo 🔥

Thanks! Gonkee 💖 (u r cutie btw)

About

In my opinion - one of the coolest simulations!

Topics

Resources

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp