[2.8] Tutorial: 3D Programming with Python and Blender for Physics Simulations

  Рет қаралды 232,770

Olav3D Tutorials

Olav3D Tutorials

Күн бұрын

Пікірлер: 174
@Olav3D
@Olav3D 4 жыл бұрын
Cool Add-ons for Blender: Human Generator: bit.ly/3rBjJXy Massive Cars And Vehicles Add-On: bit.ly/3cuWF8N 1100 Textures in Blender: bit.ly/2QEJ7yN Flip Fluids Simulation Addon: bit.ly/2Pbu5QR HDRI Maker Addon: bit.ly/3stHdPR Using these links help fund all the free tutorials.
@ArtPomelo
@ArtPomelo 5 жыл бұрын
Yes, more coding tutorials with blender please.
@CryptoAnimated
@CryptoAnimated 5 жыл бұрын
Hi, If I may, not trying to be critical, but I assume some of the people don't know about programming, and it may help to write clear code, instead of counter = 0, if this is the position of x, just call position_of_x, in this way the code becomes more clear in my opinion. I've changed the first part a bit to show as example The same thing when you subtract -2 from the counters, this may confuse people as well, you can add the position after the loop is done, in this way you don't need to subtract. Nonetheless, thanks for introducing programming in blender for me, I'm a developer and I'm just starting out in blender import bpy number_of_cubes = 2 x_pos = 0 y_pos = 0 z_pos = 0 for i in range(number_of_cubes): y_pos = 0 for j in range(number_of_cubes): z_pos = 0 for k in range(number_of_cubes): bpy.ops.mesh.primitive_cube_add(enter_editmode=False, location=(z_pos, y_pos, x_pos)) z_pos += 2 y_pos+=2 x_pos+=2
@Adinkya
@Adinkya 4 жыл бұрын
Wow, noice
@swainuk2024
@swainuk2024 4 жыл бұрын
thank you :)
@CryptoAnimated
@CryptoAnimated 4 жыл бұрын
@@swainuk2024 You are welcome, I am posting some content on unity and games if you are interested
@chrislyonm
@chrislyonm 4 жыл бұрын
@@CryptoAnimated This made SO much more sense. Still thankful that he took the time to make this though.
@CryptoAnimated
@CryptoAnimated 4 жыл бұрын
@@chrislyonm Yeah, I loved the tutorial, I added this just because I saw that people not familliar to programming would suffer a bit
@Napert
@Napert 5 жыл бұрын
Why no asmr tag in the title like wtf
@jaimerojas6578
@jaimerojas6578 4 жыл бұрын
lol so good right?
@IRaul
@IRaul 4 жыл бұрын
it sounds like agressive asmr
@Chillerll
@Chillerll 4 жыл бұрын
@@1islam1 At first, I thought those were time stamps and Allah really loves to add and subtract from numbers in for-loops for some reason
@gizlikullanc4861
@gizlikullanc4861 5 жыл бұрын
Instead of using additional variables like counter, counter2 etc. you can use the values of a, b, c. for a in range(1, number + 1): print(a*2) See that the values of a are equal to corresponding values of counter :)
@gizlikullanc4861
@gizlikullanc4861 5 жыл бұрын
I believe this is doing the same job: import bpy number = 10 for a in range(number): for b in range(number): for c in range(number): bpy.ops.mesh.primitive_cube_add(size=2, location=(a*2, b*2, c*2))
@Olav3D
@Olav3D 5 жыл бұрын
Yup. There are many ways to shorten that script, I wanted to make it as understandable as possible as it is a beginner tutorial.
@vain3d973
@vain3d973 5 жыл бұрын
As a beginner who never uses script, this just reminds me how powerful Blender actually is 🤯... As always, super helpful tutorial Olav3D, thank you!!!
@Roboticdock
@Roboticdock 2 жыл бұрын
Very nice demonstration of “for” loops in 3D modeling! Thanks!
@lpanebr
@lpanebr 5 жыл бұрын
I love it. The tip to create it modify using blender and copy the code is perfect! Thanks
@DJCronixx
@DJCronixx 5 жыл бұрын
For a more concise way of specifying the nested loops, you can use something like this: list_of_coordinate_tuples = [ (x,y,z) for x in range(0, count_x, size) for y in range(0, count_y, size) for z in range(0, count_z, size) ] Great tutorial btw!
@todlu
@todlu 5 жыл бұрын
So you can nest for loops INSIDE the list comprehension?! how cool is that!
@canopus-lab
@canopus-lab 5 жыл бұрын
I'm still using blender 2.79! But I always watch your tutorials, Thanks !
@JackPillawa
@JackPillawa 5 жыл бұрын
the voice is super relaxing and the Tutorial very good, thanks
@bronzekoala9141
@bronzekoala9141 3 жыл бұрын
The creation of the cubes can be made more then 100x faster by re-using the already existing mesh of a single cube and not using operators in the loop (every bpy.ops call refreshes the scene, making it very slow). We just create one Cube at the start of the script and re-use it's data in the loop. At the end, we just delete the first cube. Like this: import bpy counter = 0 bpy.ops.mesh.primitive_cube_add() # create a "source cube" cube = bpy.context.object for a in range(10): counter +=2 counter2 = 0 for b in range(10): counter2 +=2 counter3=0 for c in range(10): new_cube = bpy.data.objects.new(name="New Light", object_data=cube.data) # create a new Object and lets it use the cubes mesh data bpy.context.view_layer.active_layer_collection.collection.objects.link(new_cube) # add the new object to the viewlayer new_cube.location =(counter3+2, counter2-2, counter-2) counter3+=2 bpy.ops.object.delete(use_global=False, confirm=False) # delete the "source cube" With this changes, the execution time goes down from 15 seconds for a 10x10x10 grid to almost instantaniously on my PC.
@blenderenthusiast
@blenderenthusiast 5 жыл бұрын
I'm a beginner to blender and this video was like my starting point, THANK YOU!!!
@Adinkya
@Adinkya 4 жыл бұрын
Gl
@nickhodgskin
@nickhodgskin 4 жыл бұрын
Duuuuuuude, I just stumbled across this. Such a good find, thank you!!
@diggie8372
@diggie8372 3 жыл бұрын
This coding tutorial is more suitable for me Please do more tutorial... Thanks a lot for sharing this.
@Mahm00dM0hanad
@Mahm00dM0hanad 5 жыл бұрын
This is my first time I watch scripting tutorial on blender well done 👍🏻
@guylemay1471
@guylemay1471 5 жыл бұрын
Thank you for this most useful tutorial ...I've been waiting for one just like it for awhile now - thank you again!!!
@merwyn2087
@merwyn2087 4 жыл бұрын
Your tutorials are just amazing !!! I love wath you do.
@cse077mukulrana
@cse077mukulrana 3 жыл бұрын
I just subscribe you really amazing I was searching fir stuff like this finally I found your channel 🙃
@sennabullet
@sennabullet 2 жыл бұрын
Thank you for this incredible tutorial. I learned a ton. Thank you for taking the time to make the video and share your knowledge.
@EvandroMeloz
@EvandroMeloz 5 жыл бұрын
Great tutorial, Batman.
@melegaunt01x
@melegaunt01x 5 жыл бұрын
Excellent Video! Thank you! I subscribed!
@luxraider5384
@luxraider5384 4 жыл бұрын
at 4:01 shouldn't you make the counter3+=2 before the cube generation because the cube here doesn't match the coordinate system of the system and we see that the last cube has a weird coordinate of (20,18,18) and therefore it isn't even a cube it's just a rectange with a 20x18x18 parallelepiped
@ghostriley22
@ghostriley22 5 жыл бұрын
i would suggest adding denoiser....you can get satisfactory results without needing to bump the samples to large values
@erik....
@erik.... 5 жыл бұрын
You can also change the interface scale in Properties so that everything is easier to see in videos. I use scale 1.3 on my 4k screen.
@fmenezes6272
@fmenezes6272 5 жыл бұрын
thanks for increasing the font size in this tutorial
@copypaste3526
@copypaste3526 5 жыл бұрын
import bpy num = 10 step = 2 for i in range(0, num, step): for j in range(0, num, step): for k in range(0, num, step): bpy.ops.mesh.primitive_cube_add(size=2, location=(i, j, k))
@rixyarbrough1702
@rixyarbrough1702 5 жыл бұрын
This is an awesome tutorial! I learned a ton, thanks :D
@voxsideres
@voxsideres 5 жыл бұрын
Why not use the enumerate() function on your for loops? Ex: for counter, a in enumerate(range(0, number): .... I don't know how it affects performance but it prevents having a lot of extra variables in your global scope. Great tutorial!
@chainonsmanquants1630
@chainonsmanquants1630 5 жыл бұрын
really good tutorials out there ! Thanks a lot !
@JohnSmith-rn3vl
@JohnSmith-rn3vl 5 жыл бұрын
Loving this.... definitely interested in more programming tutorials .
@JacobTekiela
@JacobTekiela 5 жыл бұрын
would be super if you made the text size even bigger or zoomed in
@xXSniperProgamerXxHdxxLPXxXx
@xXSniperProgamerXxHdxxLPXxXx 5 жыл бұрын
And why should this script be faster than the array modifier?
@Olav3D
@Olav3D 5 жыл бұрын
Once you have the script written you can make changes to the simulation much faster. Using array modifiers you will have to start over to make adjustments to the number of objects on each axis due to origin points, physics and the applied modifiers.
@nelsonsubervi-hernandez8197
@nelsonsubervi-hernandez8197 5 жыл бұрын
Hello, thanks for your tutorials but for sake of my eyesight I kindly ask you to increase the font size to between 16px or 18px thanks you very much.
@Olav3D
@Olav3D 5 жыл бұрын
I agree, the font size is increased in later tutorials.
@JaaoPonte
@JaaoPonte 5 жыл бұрын
This tutorial is just amazing! So simple and so instructive
@ricopin
@ricopin 5 жыл бұрын
Thanks! I wanted to play around with scripting in blender, so this gave me some important pointers!
@massivetree7937
@massivetree7937 5 жыл бұрын
Running some of these scripts are taking quite a while to execute in the final release of 2.8. Generating the initial cube array of 1000 cubes takes just under a minute to generate which seems very slow for a scene consisting of only 6,000 faces.
@Olav3D
@Olav3D 5 жыл бұрын
What takes time is adding the physics actually.
@massivetree7937
@massivetree7937 5 жыл бұрын
@@Olav3Dwell in the case I'm referring to was just adding the array of cubes. I was just surprised, figured it would be faster.
@simulify8726
@simulify8726 5 жыл бұрын
Please do a tutorial on quick character creation
@iammanishverma
@iammanishverma 3 жыл бұрын
Very well explained!!
@JannisAdmek
@JannisAdmek 5 жыл бұрын
is a great coding tutorial for sure but I think an array modifier is still faster :)
@Olav3D
@Olav3D 5 жыл бұрын
Jannis Adamek That’s why my channel has both ;)
@ldandco
@ldandco 2 жыл бұрын
Cool videos, subscribed
@celestialbody9807
@celestialbody9807 5 жыл бұрын
Nice work ! I loved this tutorial, thanks for it ! 😄
@Myrslokstok
@Myrslokstok 5 жыл бұрын
Awesome 😃 this kind of thing makes me happy. You should allso do one video with an imported object of irregular shape.
@rfpcs1
@rfpcs1 5 жыл бұрын
Why didn't you use EEVEE?
@4.0.4
@4.0.4 4 жыл бұрын
Isn't there a way to set the same settings for all objects without python? Since generating all of them could be done with the array modifier, for instance.
@Olav3D
@Olav3D 4 жыл бұрын
This is to learn to use python in Blender, of course you can do it with a modifier ect.
@saucedplanet5968
@saucedplanet5968 5 жыл бұрын
Great tutorial!
@ravenxrgaming4672
@ravenxrgaming4672 4 жыл бұрын
Can I use blender for rover simulations
@yashwantsahu4069
@yashwantsahu4069 5 жыл бұрын
Sir i want to make video in physics in which we use light rays simulation
@4shC
@4shC 3 жыл бұрын
i am so unlucky for not finding this sooner... Great tutorial btw
@thehulk6866
@thehulk6866 4 жыл бұрын
How much time it takes to render this animation ??
@clown786
@clown786 2 жыл бұрын
Can I download an old version of Blender and use Python on it?
@machbauer132
@machbauer132 5 жыл бұрын
Why not switching immediately to the "Scripting"-Tab? ;) But what makes me wonder too, why does it take so much computational power to generate 1000 cubes??
@종신-l3i
@종신-l3i 5 жыл бұрын
thanks for video. and i have a little problem. my ground moves down with the cubes at same time... so my question is, how I could make my ground stay..?
@muzikermammoth3995
@muzikermammoth3995 4 жыл бұрын
hi there, i tried replacing the 2m blocks with 0.2m meter block of mass 0.2, but the blocks just shoot out like an explosion instead of falling. Why does it do that?
@muzikermammoth3995
@muzikermammoth3995 4 жыл бұрын
Turns out the convex hull detection for the objects means objects that are originally intersecting get pushed outwards because they're considered to be colliding
@keluargamabar
@keluargamabar 4 жыл бұрын
From blender, Could the simulation convert to become desktop based or Web based app?
@cmulation5460
@cmulation5460 3 жыл бұрын
There is no Steps per second parameter in Blender 2.9, there is Substeps per frame instead. I set Substeps Per Frame to 1 and baked, otherwise it takes an enormously long time and cubes move away too far and too fast.
@rahul_siloniya
@rahul_siloniya 5 жыл бұрын
Which gpu are you using
@ItsHxwi
@ItsHxwi 4 жыл бұрын
How often do animators code
@chasenwang4597
@chasenwang4597 4 жыл бұрын
My render view is completely dark grey. I don't know what to do...
@serra_edoardo
@serra_edoardo 2 жыл бұрын
Awesome tutorial! Just a question, is Blender physics simulation realistic? Meaning that it yealds the same results that an experiment in real life would. Thank you a lot
@chasenwang4597
@chasenwang4597 4 жыл бұрын
What GPU do you have?
@mayadah
@mayadah 5 жыл бұрын
Hi, I have a problem with the animation, that is, the plane and the cube move with each other and the cube does not fall on the plane
@ManfredPichler
@ManfredPichler 5 жыл бұрын
Make sure you set the rigid body on the plane to passive, otherwise the plane will have gravity and start falling the moment you play the simulation.
@mayadah
@mayadah 5 жыл бұрын
@@ManfredPichler thank you
@alpha_6t9
@alpha_6t9 5 жыл бұрын
why is the final structure asymmetric? (since all the cubes are identical, the object that is falling has to be completely symmetric. if so, why do the cubes on one side, the side we are observing, fall off while the ones on the other sides don't?) (good tutorial btw)
@Olav3D
@Olav3D 5 жыл бұрын
My first thought: as “steps per second” increases the level of asymmetry will decrease as the accuracy of the baked simulation increases. Good question!
@alpha_6t9
@alpha_6t9 5 жыл бұрын
@@Olav3D I was thinking in the direction of numerical inaccuracies in binary representation of numbers
@mathyoooo2
@mathyoooo2 5 жыл бұрын
@@alpha_6t9 I was also thinking of floating point errors
@artaway6647
@artaway6647 5 жыл бұрын
cool tutorial. But idk why blender always freeze when I press ctrl+c to copy the cube object from the info window.
@maicomcoelholopes9032
@maicomcoelholopes9032 5 жыл бұрын
Olav, poderia me ajudar?estou criando um Addon(tentando) mas estou com dificuldade de vincular parte do script com um botão(nesse caso UI menu) e como posso executar vários comandos com apenas um botão? exemplo: com um clique mover objeto a determinada coordenada e aplicar um modificador como o solidify com apenas um botão?
@aumhren3480
@aumhren3480 4 жыл бұрын
04:44 - this code crashes blender (2.91.0), anyway thx for sharing
@3d-illusions
@3d-illusions 5 жыл бұрын
Cool, thanks. I was wondering though, how could we multithread this on the cpu, or run it in parallel on the gpu using something like numba?
@ElectroGamesYT
@ElectroGamesYT 5 жыл бұрын
Cool tutorial, can u make more tutorials on python I need to learn
@Mountainside101
@Mountainside101 2 жыл бұрын
Is anybody having trouble with the code showing error, it won’t execute in the first section of the code
@indranupaperproducts4186
@indranupaperproducts4186 4 жыл бұрын
is it common that when script starts running,then the software stops responding for a long time??well my pc has only 2gb ram with no graphics card in it
@cipherxen2
@cipherxen2 5 жыл бұрын
What added the randomness to the physics model? No cubes would have fallen out in a perfect model.
@Olav3D
@Olav3D 5 жыл бұрын
I think “steps per second” plays a part.
@cipherxen2
@cipherxen2 5 жыл бұрын
@@Olav3D If one cube is exactly above another cube, their collision cannot make them move horizontally. But as shown in video, the middle cubes move horizontally after collision. If the cubes are perfectly aligned above one another, they would have stayed in place.
@cipherxen2
@cipherxen2 5 жыл бұрын
I've created my own physics simulator, in which I've to add some slight randomness in position to them behave like in this video.
@martinbassoli8876
@martinbassoli8876 5 жыл бұрын
Hi!, How I can apply this script to an object I already create it , like a tree that falls into a house and the roof of the house breaks . I wanna know that because it would be great to add it to my scene.
@sippy_cups
@sippy_cups 5 жыл бұрын
Is there a github with the code from your videos?
@arnavjha7375
@arnavjha7375 2 жыл бұрын
In my case , cubes are moving up in air and are stick to each other . Just reverse of of actual output I was expecting .
@varunahlawat9013
@varunahlawat9013 Жыл бұрын
Could even the sound be simulated? Technically it should be possible I think...
@jisankumar3420
@jisankumar3420 4 жыл бұрын
I can't see number row 5 plss write for me
5 жыл бұрын
Well done,thanks!
@samnomas2739
@samnomas2739 4 жыл бұрын
I feel like I’m being seduced. The information is winning me over, not gonna lie
@allthingslegal1294
@allthingslegal1294 5 жыл бұрын
Hey man, new subscriber. Just wanted to ask which laptop you use for rendering and animation. Thanks
@phadadev2307
@phadadev2307 4 жыл бұрын
Thank you so much. :) :) :)
@Martin-ll7jc
@Martin-ll7jc 5 жыл бұрын
Thank you, much appreciated
@sohaibahmad9030
@sohaibahmad9030 5 жыл бұрын
Can anybody tell is it compulsory to use coding on blender?
@simongunkel7457
@simongunkel7457 5 жыл бұрын
What do you want to use blender for? For most use cases you won't need to code anything, but for some specific things you might want to do so. Think of the ability to use the python API as a bonus - not neccessary for most tasks, but an option to expand functionality even further.
@sohaibahmad9030
@sohaibahmad9030 5 жыл бұрын
@@simongunkel7457 for animation. Ok i got that, thanks.
@themightybeast4716
@themightybeast4716 4 жыл бұрын
i realy love what you do but can you do a video how to make the Minecraft realistic physics simulation. and i subed
@prateekthakur1848
@prateekthakur1848 4 жыл бұрын
I hear that voice and I sub.
@Vinironin
@Vinironin 4 жыл бұрын
my plane is not fix lol, how do i fix it?
@Vinironin
@Vinironin 4 жыл бұрын
ok now all the boxes are passing through the plane
@sams_3d_stuff
@sams_3d_stuff 3 жыл бұрын
uhuh, thank you so much!
@AngelAgudoGuerrero
@AngelAgudoGuerrero 5 жыл бұрын
Yes! Great tuto!
@sansdomicileconnu
@sansdomicileconnu 5 жыл бұрын
thanks for this tuto
@MrRoach-ii4pz
@MrRoach-ii4pz 5 жыл бұрын
Great tutorials! Thanks!
@sm1le0hd
@sm1le0hd 5 жыл бұрын
U can use python in blender?! How many modules does this Swiss knife have?
@Olav3D
@Olav3D 5 жыл бұрын
Blender has so many uses!
@rachittrivedi6322
@rachittrivedi6322 5 жыл бұрын
Nice one...
@vishalsingh-cz8jq
@vishalsingh-cz8jq 5 жыл бұрын
awesome!!
@ismailhaider
@ismailhaider 4 жыл бұрын
can we make web based 3D capacity planning using python ? i dont know they make this. here is the sample sunbirddcim.com/screen-shots/3d-visualization
@WhiteBossGamerYT
@WhiteBossGamerYT 5 жыл бұрын
nice bro
@ehehjehehe5673
@ehehjehehe5673 5 жыл бұрын
I will continue using modifiers
@Olav3D
@Olav3D 5 жыл бұрын
Haha, I have a tutorial for that too ;)
@vynguyenchi9672
@vynguyenchi9672 4 жыл бұрын
Great!
@ArbitraryOnslaught
@ArbitraryOnslaught 5 жыл бұрын
I thought png was larger file then jpg? also great tutorial!
@jascrandom9855
@jascrandom9855 5 жыл бұрын
It is, but its lossless.
@lucaslambert8970
@lucaslambert8970 5 жыл бұрын
Blender froze when i ran the script.. :( Let me reduce number of cubes... :p)
@lello7385
@lello7385 2 жыл бұрын
you just create the cubes in python and add the physics then you run it from blender not from python.
@フジ子-k3i
@フジ子-k3i 4 жыл бұрын
print("THANK YOU"!!)
@daisuki9296
@daisuki9296 4 жыл бұрын
Invalid syntax
3D Programming for Beginners Using Python and Blender 2.8, Tutorial
13:21
Olav3D Tutorials
Рет қаралды 211 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Creating a Mesh from Scratch with Python
13:04
CG Python
Рет қаралды 9 М.
[2.83] Blender Tutorial: Python Programming With Math, Part 1
10:12
Olav3D Tutorials
Рет қаралды 21 М.
3D Game Development in Python with Ursina
19:31
NeuralNine
Рет қаралды 218 М.
Let's code 3D Engine in Python from Scratch
14:55
Coder Space
Рет қаралды 403 М.
I'm Coding an Entire Physics Engine from Scratch
9:19
Gonkee
Рет қаралды 1,7 МЛН
Much bigger simulation, AIs learn Phalanx
29:13
Pezzza's Work
Рет қаралды 2,8 МЛН
Time Saving Blender Python Workflow
9:20
CG Python
Рет қаралды 3,3 М.
Realistic destruction effects in blender
15:21
FxForge
Рет қаралды 814 М.
How to Make Meshes with Python in Blender!
16:26
Curtis Holt
Рет қаралды 46 М.
How to 3D Photoscan Easy and Free!
34:50
CG Geek
Рет қаралды 2,2 МЛН
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН