Blender is free and has so many features that it's often said to be a first-time killer ~~ It's a great software for modeling! However, I don't know what to do to model using many functions suddenly ...
This time, I will model using only one function.
** "I can write Python" ** feature! This time I'm going to do various things with this. ~~ I'm crazy ~~
I will explain it briefly here.
It's easy, isn't it?
Ah installation is here. https://www.blender.org/
Then I will make various things from here
Some people may wonder what it is ... It's like this
import bpy
import random
for i in range(30):
for j in range(30):
bpy.ops.mesh.primitive_cube_add(location=(i-15,j-15,0),scale=(1,1,random.randint(1,10)))
I feel like this
Let's make donuts like the one above
import bpy
import math
for i in range(8):
bpy.ops.mesh.primitive_uv_sphere_add(location=(2*math.cos(math.pi*i/4),2*math.sin(math.pi*i/4),0))
Substituting cos and sin for the x and y coordinates of location = (x coordinate, y coordinate, z coordinate). In short, it means that eight spheres are arranged at equal intervals on the circumference. With this, a certain ring is completed.
Now let's make a graph.
import bpy
import math
for i in range(180):
bpy.ops.mesh.primitive_cube_add(location=(i,10*(math.pow(math.log(0.05*i+1)+math.sin(math.pi*i/30),3))*math.cos(math.pi*i/90),10*(math.pow(math.log(0.05*i+1)+math.sin(math.pi*i/30),3))*math.sin(math.pi*i/90)))
This time, the polar form of $ 10 \ times log_e (0.05 \ times x + 1) + \ sin ({x \ pi/30}) $ is decomposed into the vertical axis component and the horizontal axis component to create a graph with θ as a parameter. We now have
By the way, the graph looks like this. Overall view and view from each axis
Have you seen this source code somewhere? ~~ I don't like kid like you ~~
Now let's make this a flat surface.
import bpy
import math
for i in range(30):
for j in range(20):
bpy.ops.mesh.primitive_cube_add(location=(i,20-j+10*(math.pow(math.log(0.05*i+1)+math.sin(math.pi*i/30),3))*math.cos(math.pi*i/90),j+10*(math.pow(math.log(0.05*i+1)+math.sin(math.pi*i/30),3))*math.sin(math.pi*i/90)))
The horizontal axis of the above formula is arranged at equal intervals, and the vertical axis is slightly spaced between cubes. The graph looks like this.
This time I wrote various easy modeling methods in Python. It can be used for many other things, so please give it a try!
Recommended Posts