Тёмный

Coding Challenge 177: Soft Body Physics 

The Coding Train
Подписаться 1,7 млн
Просмотров 150 тыс.
50% 1

Embark on a squishy adventure as I attempt to create a soft body physics simulation for a character with toxiclibs.js and p5.js! Code: thecodingtrain.com/challenges...
🚀 Watch this video ad-free on Nebula nebula.tv/videos/codingtrain-...
p5.js Web Editor Sketches:
🕹️ Soft Body Character: editor.p5js.org/codingtrain/s...
🕹️ Soft Body Character Enhanced: editor.p5js.org/codingtrain/s...
🕹️ Soft Body Dancing Skeleton: editor.p5js.org/codingtrain/s...
🕹️ Soft Body Letters: editor.p5js.org/codingtrain/s...
🕹️ Blank Canvas: editor.p5js.org/codingtrain/s...
🎥 Previous video: • Coding Challenge 176: ...
🎥 All videos: • Coding Challenges
References:
🔗 Nature of Code: nature-of-code-2nd-edition.ne...
🔗 ToxicLibs.js: haptic-data.com/toxiclibsjs/
🔗 ToxicLibs Java Reference: shiffman.github.io/toxiclibs-...
🔗 Advanced Character Physics: www.cs.cmu.edu/afs/cs/academic...
🔗 Thi.ng: thi.ng/
Videos:
🚂 Toxiclibs Verlet Physics playlist: • 5.13: What is Toxiclib...
🚂 Matter.js playlist: • 5.17: Introduction to ...
🎥 Physics of JellyCar: • Physics of JellyCar: S...
🎥 The Making of Nokia and Friends: • Nokia Friends (Making ...
Related Coding Challenges:
🚂 20 3D Cloth with Toxiclibs: • Coding Challenge #20: ...
🚂 63 Texturing Cloth Simulation: • Coding Challenge #63.1...
Timestamps:
0:00 Introduction
2:51 Physics libraries
5:30 Elements in ToxicLibs
5:47 Start coding
7:04 Object destructuring
8:10 Add gravity
9:00 Adding elements to the world
10:35 Updating the physics world
11:40 Adding a spring
15:23 Refactor code
18:07 Inheritance
18:57 Super class
23:31 Spring length
25:44 Create a closed-filled shape to draw the character
26:49 Suggestions for variations
27:07 Other types of springs
27:36 Update about the Nature of Code book!
28:56 Outro
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
🚂 Website: thecodingtrain.com/
👾 Share Your Creation! thecodingtrain.com/guides/pas...
🚩 Suggest Topics: github.com/CodingTrain/Sugges...
💡 GitHub: github.com/CodingTrain
💬 Discord: thecodingtrain.com/discord
💖 Membership: ru-vid.comjoin
🛒 Store: standard.tv/codingtrain
🖋️ Twitter: / thecodingtrain
📸 Instagram: / the.coding.train
🎥 Coding Challenges: • Coding Challenges
🎥 Intro to Programming: • Start learning here!
🔗 p5.js: p5js.org
🔗 p5.js Web Editor: editor.p5js.org/
🔗 Processing: processing.org
📄 Code of Conduct: github.com/CodingTrain/Code-o...
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecod...
#softbody #toxiclibs #verletphysics #p5js #javascript

Опубликовано:

 

30 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 146   
@TheCodingTrain
@TheCodingTrain Год назад
🚂 Source code and passenger showcase: thecodingtrain.com/challenges/177-soft-body-character 💫 Support the Coding Train and watch ad-free on Nebula: nebula.tv/videos/codingtrain-coding-challenge-177-soft-body-character
@CodeParticles
@CodeParticles Год назад
@TheCodingTrain, Huge fan sir thank you for this upload! I know you're incredibly busy these days but with all due respect, I feel that you should have done this from scratch like you've done with the quadtree tutorial, 2d physics, the boids tutorial, and countless others instead of using an external library!
@tile-maker4962
@tile-maker4962 Год назад
This is great. Do you think it is possible to integrate angles instead of springs between points to make it? Like a spring angle or something?
@TheCodingTrain
@TheCodingTrain Год назад
@@CodeParticles I appreciate the feedback, you might like to see the spring challenge which has some more implementation details! ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Rr-5HiXquhw.html
@CodeParticles
@CodeParticles Год назад
@@TheCodingTrain Thank you! 👍
@mathcat4
@mathcat4 Год назад
Amazing you found time to post another video, your enthusiasm always motivates me to program again!
@yohansaba5179
@yohansaba5179 Год назад
Thank you for everything Daniel, you have such a wonderful soul.
@ezrakornfeld8436
@ezrakornfeld8436 Год назад
He’s like the bob ross of programming
@xnick_uy
@xnick_uy Год назад
This is the Coding Challenge video with the highest quality so far: well scripted narrative, lots of tips and logical arguments, an easy to follow and well organized code. Also, the part about how to set up the html and the imports is very appropriate. The video edition also superb. This goes to show your experience making these videos, and also dedicating so much time to the book possibly has an impact on your story-telling style, for the better.
@TheCodingTrain
@TheCodingTrain Год назад
Thank you for this feedback, I really appreciate it!!
@ethanmendelson6978
@ethanmendelson6978 Год назад
@@TheCodingTrain Definitely the best presentation yet. Got halfway through the video without opening my IDE because I was fixed on just watching.
@Lurkingbird
@Lurkingbird 11 месяцев назад
@@TheCodingTrain do more apple ii videos it is so good
@hotrodhunk7389
@hotrodhunk7389 Год назад
I just started learning coding. After finding your content it is like a breath of fresh air! You make it seem so fun! The ability to do anything with a computer is really cool and powerful. Thanks for your videos.
@mmilerngruppe
@mmilerngruppe Год назад
Thank you, Daniel, your videos always make me happy!
@tehcakelie17
@tehcakelie17 Год назад
This is amazing! this came in clutch when I've been researching simple way to create softbody physics. Thank you for this!
@Sayamak
@Sayamak Год назад
Daniel really is a great educator and entertainer. Thank you Sir for your videos and especially The Nature of Code where I am currently enjoying the chapter about fractals.
@richardsymes1844
@richardsymes1844 Год назад
So good to see you back and with another interesting challenge.
@sambeard4428
@sambeard4428 Год назад
When I watch your videos, I feel you talk to me, not just saying something, but actually talking to me, like I'm a child. But not at all in the negative sense. Your instructions are clear, friendly and unassuming. I hope you either have kids or will some day because I'm sure they'll turn out as marvelously curious little beings. Little bit of a weird post, I know, but this is just how I like to express my gratitude.
@RedEyedJedi
@RedEyedJedi Год назад
OMG you're writing a new version of the nature of code :D I have the original and its my favourite book by a mile.
@niczoom
@niczoom Год назад
Super clear explanations. I learn something new every video watched!
@WilderPoo
@WilderPoo Год назад
Amazing! Thank you for really demystifying soft body physics. I thought it would be much more complicated than a few springs 😄
@wxr
@wxr Год назад
I receive every video of the Coding Train as it was a Christmas gift and I was 5 years old ! I'm so happy and excited !
@AaronAsherRandall
@AaronAsherRandall Год назад
I have always loved your videos! I am a novice game programmer in C# and Unity, it seems like a lot of these tools in Javascript could be expanded to make games with complex physics and graphics in the browser!
@redpug5042
@redpug5042 Год назад
it sure would be fun to write the physics engine on your own. I just spent about an hour or so making a quick engine with a system for springs and force fields (a force applied to specified particles based on the particle's conditions like location, hence "field")
@zer001
@zer001 Год назад
nice to have you back.
@IzUrBoiKK
@IzUrBoiKK Год назад
I am mainly a python programmer, but often use your videos as a tutorial for things. Thanks bro for all this. ❤❤❤
@Haapavuo
@Haapavuo Год назад
Greetings from Finland! 🇫🇮 That is where you inspiration came from this time! 😉
@user-rq8wm5bu9s
@user-rq8wm5bu9s Год назад
Thank u so much! I can’t express how much your video helped me but I ‘m surely that you have saved the whole of my college life!😂
@chopstix9093
@chopstix9093 Год назад
its been too long since a coding train video ;-; thank you!!!
@kapilishere
@kapilishere Год назад
It was fun to watch, I'd definitely code my own squishie character!
@nagesh007
@nagesh007 7 месяцев назад
Awesome , Mind Blowing 😍
@Parasbhattarai1
@Parasbhattarai1 Год назад
❤❤love everything done for us and teaching in. Such a cool way❤❤❤
@shachargabbay1496
@shachargabbay1496 Год назад
wow. you are simply a magician. I've been dreaming about this for years!!!!
@LoPhatKao
@LoPhatKao Год назад
pretty cool that you're doing a rewrite of NoC read it last year and played around with Processing niftiest sketch I did was an ant pheromone trail behaviour simulation, reminiscent of SimAnt surface view
@partymarty1856
@partymarty1856 8 месяцев назад
glad to see you making video (I've watched one so far"
@mrthomaschannelearth
@mrthomaschannelearth Год назад
Code refactoring is one of the few things that bring me true joy in this life
@pierregof
@pierregof Год назад
Thank you Daniel 🙏
@RupertBruce
@RupertBruce 11 месяцев назад
I don't have notifications on and it took YT 2 months to suggest this. I have surely watched enough of your videos to get instant feed updates regardless of the notification settings.
@manuelm.561
@manuelm.561 Год назад
Génial !!!
@pbenikovszky1
@pbenikovszky1 Год назад
ah finally a new video :) great as always :).
@Hoobizone
@Hoobizone Год назад
Such a great content! Thanks!!
@PeranMe
@PeranMe Год назад
Oooh, new NoC version! Pardon my drooling here...
@cpasket122
@cpasket122 Год назад
How the hell did you comment 7 hours ago if the video was released 5 hours ago???
@PeranMe
@PeranMe Год назад
@@cpasket122 What? I'm just that fast, ok? Keep up! (Subscribers sometimes get videos early)
@cpasket122
@cpasket122 Год назад
@@PeranMe oh, thought you were a time traveler or something lol
@spacelamaglama
@spacelamaglama 4 месяца назад
what a nice video! You are like the Bob Ross of developing
@anon_y_mousse
@anon_y_mousse Год назад
Are you going to do rigid body physics next? Maybe throw a squishy sphere at a brick wall at varying speeds and animate it bouncing off and breaking through.
@offtheball87
@offtheball87 Год назад
I'd love to see the making of the final character!
@robinkelmen6332
@robinkelmen6332 Год назад
Hi, Loved the video! Would you be able to do a video with collision detection between 2 shapes consisting of a set of points and springs?
@zer001
@zer001 Год назад
Danke! Thank you!
@TheCodingTrain
@TheCodingTrain Год назад
Thanks for the generous support!
@Liloulalalala
@Liloulalalala Год назад
Yeeeees new coding challenge !!
@parkeranderson7599
@parkeranderson7599 Год назад
Soft body physics... my doctor has been wanting me to work on this!😉
@wlockuz4467
@wlockuz4467 Год назад
Can't wait for Nature of Code!
@Freestila
@Freestila Год назад
I never did javascript. I code java for a living, but js and p5 was new to me :) But this looked soo fun, that i wanted to try it. got some problems with preview in vs code (since web editors are not my thing...), but it was really fun :) So thanks for that :)
@nimlhug138
@nimlhug138 Год назад
WOW... I got a flashback of a younger version of me having fun with SodaConstructor back in 2000-2001
@sodaplayer
@sodaplayer Год назад
Ooh, I loved playing with that. >.> I even still have my username named after it.
@Masda.X
@Masda.X Год назад
Thanks a lot sir!
@DOROnoDORO
@DOROnoDORO Год назад
RETURN OF THE KING
@jayjasespud
@jayjasespud Год назад
This train sure has come a long way since departure.
@kimeg7294
@kimeg7294 Год назад
Hello Daniel, this was very fun to watch and educational for learning how particles behave based on soft body interactions. Would this principle be applicable for simulating a "verlet cloth" effect on particles forming a 2D rectangular shape?
@TheCodingTrain
@TheCodingTrain Год назад
Yes! You can see more about this in an older video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-jrk_lOg_pVA.html
@KakoriGames
@KakoriGames Год назад
Fun fact, soft body simulations actually have a lot of similarities with finite element analysis. In fact, one could use a soft body to simulate a ideal truss structure. When it comes to 2D, or 3D, structures, the main difference becomes that the rigidity of the system is calculated based on the shapes between springs, called elements, and there's some resistance to rotation in the nodes, so a square shape doesn't fall flat. But the idea of modeling a continuous body as a set of discrete points forming a graph, that exhibit some degree of rigidity between them, is very much akin to elastic finite element analysis.
@olasoderlind5685
@olasoderlind5685 Год назад
more videos , fun watching. :)
@dreamofeternalhappiness8001
Yay. 👽✌️ Keep making programming fun for everyone and become rich. You are super fun. Knowledge is boring only if there is none to play with it. ❤ * individual physical position vector.
@donnierussellii4659
@donnierussellii4659 Год назад
Thanks for helping the programming community own the toxi libs.
@itsjase92
@itsjase92 Год назад
Is there a reason you prefer the p5js web editor over something like openprocessing? I only recently discovered it but it seems much nicer
@beefox__
@beefox__ Год назад
fun fact! the youtuber who explained recently how jelly car worked, he actually made jelly car!
@mthia
@mthia Год назад
another coding challenge nice!!!
@felipe1876
@felipe1876 Год назад
i understand 15% of the eps, but it is so cool even so
@mileshunter3280
@mileshunter3280 Год назад
Great video. What's the name of the tune at 3m30s?I can't get it out of my head.
@NinjarioPicmin
@NinjarioPicmin Год назад
0:30 that is truly beautiful. Any idea on where to read up on how that was done?
@WhateverOwO
@WhateverOwO Год назад
it's probably pressure soft-body physics with really low pressure and k parameters
@KnakuanaRka
@KnakuanaRka 10 месяцев назад
I need to catch up on the Coding Challenges.
@meguellatiyounes8659
@meguellatiyounes8659 Год назад
new to the channel , thank for presenting this beautiful topic don't you notice the 3D illusion effect 23:55
@FridgeFucker96
@FridgeFucker96 Год назад
I swear if someone ever hurts this man I'll track them down personally
@Michi0-0
@Michi0-0 Год назад
You are the nicest guy ever❤❤❤
@jf4715
@jf4715 Год назад
I miss your videos!
@drobotk
@drobotk Год назад
Would it be possible to make 2 buddies collide and bounce together using this library?
@cypher2960
@cypher2960 Год назад
hi daniel. thank you for everything, you've tought me alot. but could you please try to demessify you playlists please. you have so many greate tutorials and course but they are all out of order and sometimes missing. thankfully someone else has make a playlist of you coding challanges. you've tought a whole lot but honestly i makes my head explode going through it all to find the ones i want. i would learn alot more if your playlists and courses where organized in your channel or a website per say. just a segestion.
@o_2731
@o_2731 Год назад
I really regret i didnt find this video when i started coding
@Bromon655
@Bromon655 Год назад
This is gonna sound crazy but the conversation about repetitive code starting at 15:04 really helped me visualize the purpose of object oriented programming as opposed to procedural programming. Noobish and oddly specific but still
@TheCodingTrain
@TheCodingTrain Год назад
I'm so glad to hear this!
@Stiegosaurus
@Stiegosaurus 4 месяца назад
LOL @ toxic libs. What a great name. Dual meaning
@emilie1977
@emilie1977 Год назад
wow good subject! I want simulate my home under earthquake ;)
@Zzkkb98
@Zzkkb98 Год назад
The only place wheyi feel that i can code what i want
@nathanroed6924
@nathanroed6924 Год назад
please do a series where you make a rigid body physics system without physics libraries like box 2D
@vsueiro
@vsueiro Год назад
Hi, Nathan! In his Nature of Code playlist, Dan builds the basics of a physics engine from scratch… It’s just amazing!
@nathanroed6924
@nathanroed6924 Год назад
@@vsueiro thanks, I'll be sure to watch it!
@PS3centere
@PS3centere Год назад
when destructuring you can write {VerletPhysics2D: physics} to rename the destruct.
@TheCodingTrain
@TheCodingTrain Год назад
Oh! I did not know this!!
@pablobribiesca2596
@pablobribiesca2596 Год назад
I was like "Ohh this reminds of Jelly car... Great game and amazing memories with my brother" Popped up out of the blue
@stormwix
@stormwix 3 месяца назад
1:32 The second picture to the left kinda reminds me of a Hyperbolic tessellation 🤔. Anyone else?
@joshblitz194
@joshblitz194 Год назад
Is there a circuit emulator playlist on this channel?
@bwremjoe
@bwremjoe Год назад
What about detecting and resolving colisions between two soft body objectS? Sounds like a can of worms ^^'
@alwysrite
@alwysrite Год назад
jesus ! you have risen from the dead ! happy easter : )
@zer001
@zer001 Год назад
07:24 is this like the using system.windows.forms in C#?
@alexandermcclure6185
@alexandermcclure6185 2 месяца назад
but how do i make the springs themselves without toxiclibs :(
@ToastaToast
@ToastaToast Год назад
I'd like to learn more about object destructuring
@deanolium
@deanolium Год назад
It's pretty straight forward. Say you have an object `X` with the properties `a`, `b`, and `c`. You can access these by doing: X.a X.b X.c You can also assign these to local variables to make it easier to access: let a = X.a let b = X.b let c = X.c Object destructuring is a thing which lets you do all this in a single line by doing: let {a, b, c} = X This then creates local variables which are set to the properties on `X` that have the same name. You can use this to pick and choose which properties you want: let {a, c} = X // This only picks X.a and X.c You can also rename properties: let {a: newA} = X // We now have a variable called newA that is the same as X.a Finally you can store the remaining, non-picked properties using the rest operator `...` let {a, ...otherProps} = X // We now have the variables `a` and `otherProps` where `otherProps` is an object with properties otherProps.b and otherProps.c It's all basically shorthand but very, very useful.
@codingcompetitiveprogrammi6118
can you make video about algorithm and structure sir you should become professor and teaching in highest university like MIT and harvard
@andrewcrook6444
@andrewcrook6444 8 месяцев назад
Don’t they have dampeners with springs?
@euglossine4ever
@euglossine4ever Год назад
❤❤❤❤❤
@russellg3775
@russellg3775 Год назад
Wait, new edition of The Nature of Code coming?
@TheCodingTrain
@TheCodingTrain Год назад
Slowly but surely!
@SleepyGarysGameStream
@SleepyGarysGameStream Год назад
👍👍
@namelastname4077
@namelastname4077 Год назад
Another Dane saves the day. They invented C++, PHP, C# and V8
@lucbloom
@lucbloom Год назад
The JellyCar update is triggering a revisit of softbody physics projects by a bunch of devs :-)
@darkfrei2
@darkfrei2 Год назад
Is it code for slime and truss physics?
@x_czt
@x_czt Год назад
The ToxicLib is the next Golan Levin
@matthewhook3375
@matthewhook3375 11 месяцев назад
Novice here, please could someone explain why referencing a global variable from within a class is considered bad practice (as discussed at 20:38)?
@unveil7762
@unveil7762 Год назад
🎉❤🎉
@makershake8040
@makershake8040 Год назад
Coding Challenge: Atom rendering like minute physics in this video ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-W2Xb2GFK2yc.html&ab_channel=minutephysics I think this would be an adequate challenge and addition to the playlist.
@aliciadelpino8209
@aliciadelpino8209 Год назад
I'm doing it on vs code and it says that 'GravityBehavior' is undefined and that it cant access "physics" before initialization :(
@TheCodingTrain
@TheCodingTrain Год назад
Can you pop into the coding train discord we can help there! Link in description.
@aliciadelpino8209
@aliciadelpino8209 Год назад
@@TheCodingTrain Thank you for replying so fast! that's amazing, I will do that, thank you!
@01binaryboy
@01binaryboy Год назад
Buy the Book(Nature of Code 2nd edition) option not working
@TheCodingTrain
@TheCodingTrain Год назад
It's not out yet, the site is just a preview! (old version: natureofcode.com/)
@gknomics
@gknomics 11 месяцев назад
hey daniel i tried copying the code but on my end it isnt working can you pls explain?
@gknomics
@gknomics 11 месяцев назад
btw really great video
@howardalien2720
@howardalien2720 Год назад
How would one make this without a physics engine? Like from a raw programming language?
@garrethutchington1663
@garrethutchington1663 Год назад
Learn the basic principles of physics and code it yourself 😊
@gower1973
@gower1973 Год назад
You don’t need a physics library to do what he did here, it’s pretty simple stuff, have a look at his spring and pendulum videos, I took what he did there and implemented it c++ with direct 2d as the canvas
@deanolium
@deanolium Год назад
The paper he linked to has the basic formulae needed to create this. Basically it's about figuring out what the next position of a point is based on the previous position and acceleration vector applied to it. Then you add in the constraints, but rather than it be fixed, you use the constraints to change the acceleration vector applied to the point based on how far from the 'ideal' length the point is. Add gravity and you get your own physics engine.
@howardalien2720
@howardalien2720 Год назад
thanks guys
@superdepressif6047
@superdepressif6047 Год назад
i missed you 😞
@bbbasia100
@bbbasia100 Год назад
Does anyone done that in Visual Studio Code? I have problem with toxiclibsjs 🥺
@gorillasun
@gorillasun Год назад
Juhani, look! You're on TV!
@ernest3rd
@ernest3rd Год назад
🤯
@toastyPredicament
@toastyPredicament Год назад
Finally
@sharadkumarsingh4802
@sharadkumarsingh4802 Год назад
Write a "complete" physics engine (from scratch) [in 60 mins]
Далее
Coding Challenge 178: Climate Spiral
41:07
Просмотров 85 тыс.
Coding Challenge 170: The Monty Hall Problem
32:16
Просмотров 156 тыс.
The last one surprised me! 👀 🎈
00:30
Просмотров 4,2 млн
Coding Adventure: Ant and Slime Simulations
17:54
Просмотров 1,8 млн
Coding Challenge 167: Ulam Spiral of Prime Numbers
24:13
The Physics of BeamNG
5:00
Просмотров 63 тыс.
Physics of JellyCar: Soft Body Physics Explained
17:02
Просмотров 111 тыс.
Coding Challenge 93: Double Pendulum
31:11
Просмотров 915 тыс.
I Made a Soft-Body Tetris That’s Actually Playable
10:18
I Made a Neural Network with just Redstone!
17:23
Просмотров 677 тыс.
Apple ][ Coding Challenge: Fractal Tree
35:35
Просмотров 368 тыс.
STOP Using Classes In JavaScript | Prime Reacts
14:02
Просмотров 224 тыс.
Coding Challenge #85: The Game of Life
38:20
Просмотров 679 тыс.