Blender 2.6 Tutorial - Basic Python Programming - Part 1

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Thanks for the tutorials. Watching them in 2016 and they are still relevant. Well done!

BrettKromkamp
Автор

Radian is a little more than just another unit system. Degrees can only store the direction, while radians tell you the actual position as well. A radian is the length of the circumference equal to the radius of the circle, so if you know the radian, you also know where that point is in relation to the centre of the circle (or any other position within the circle).

If you have a radian of 3.14, you know it's in the direction of 180 degrees, but you also know it's 1r away, while a direction of 180 degrees don't tell you anything about where the point is in relation to the centre (or any other point within the circle).

If you assume the degree is always pointing to the circumference of the circle, it's easier to count in degrees, when you start out. But once you learn radians, it's hard to go back when doing geometric manipulation. It's so much easier to count in radians, especially if you're working in a 3D environment.

morphman
Автор

t y for taking the time. At first I didn't think you were going to go anywhere but as I dig into python - you are spot on!

helpmenowmark
Автор

Hey! Just want to say thanks for these. Looking forward to working through them in depth.

LEGOblender
Автор

Sci Fi Animator
New to python but, made some changes. This way you don't have to know any radians + you get to pick your start and stop angle + the number of cubes along the arc.

import bpy
from bpy import context
from math import sin, cos, radians

cubeobject =

#Get the cursor location in 3D View
cursor = context.scene.cursor_location

#Increase the radial distance the cube through the loop
radialdist = 5.0

# Number of Objects over specified angle range (integer entered as float)
num = 8.0
start_angle_deg = 90.0
stop_angle_deg = 360.0

# Initialize some variables
deg_to_rad = 3.14159265359 / 180.0 # π/180°
xsize = 1.0
ysize = 1.0
zsize = 1.0

# Start angle and stop angle
theta_start = start_angle_deg * deg_to_rad
theta_stop = stop_angle_deg * deg_to_rad

while theta_start < theta_stop:
    x = cursor.x + radialdist * cos(theta_start)
    y = cursor.y + radialdist * sin(theta_start)
    z = cursor.z
    cubeobject(location=(x, y, z))
    
    # = (0.2, 0.01, 0.01))
    
    # Increment the radian angle of measure
    theta_start += ((stop_angle_deg - start_angle_deg) / num) * deg_to_rad

# Start the drawing angle back at the center for each arm
start_angle_deg = 0.0
stop_angle_deg = 360.0

# Start the radial distance back at the center for each arm
radialdist = 1.0

Chavagnatze
Автор

I'm working on my intermediate (paid) tutorial series right now that's designed to teach more math and Python for game designers. The first tutorial in the series is mixes logic bricks, Python and vector math. The emphasis is on math and programming. I uploaded one of the basic lessons...ijk and the Right Hand Rule.

FirstGradeCalculus
Автор

thanx for this series, i really needed this!

serenityrahn
Автор

Geez, you're a boss at this.  Thanks man.

black_squall
Автор

Just catching up with your videos so I'm not sure if you do this later but the Python math module has a pi constant so you can do:

from math import sin, cos, radians, pi

and then use 2*pi instead of 6.28 which is more readable

paultaylor
Автор

Very Impressive tuts. Thanks for the time you put into preparing and uploading these series to help others. I'm learning so much from your series

palmernoah
Автор

This was exactly what I needed. Thank you so much for getting me started.

jimsimson
Автор

You could use zero to represent 0 degrees and 2PI for 360 degrees and also zero. PI/4 is 45 degrees and etc...

rgloria
Автор

Yes, later videos in the series address that issue.

FirstGradeCalculus
Автор

Hi! Enjoying the video. BTW 2pi/8 is the same as pi/4. Simultaneously less and more confusing. Cheers!

misterlutz
Автор

I've been advoding learning python for the passed year but I keep coming back to coding I guess I should just go ahead and do it like band aid

sallymae
Автор

I love blender and I'm grateful for anything new I can learn so thanks but perhaps you could paste these programs into a blog or something like that for better access? 

Diver
Автор

Hi why do you use 3.14 instead of math.pi ?

rdaneel
Автор

where can i find the math programme that youi use in this video ? is it free ? plz put the link where i can down load it  tkx

abdelhakimfarah
Автор

Hi. I just started watching your video on Python in Blender, and it seems good and like Python is powerful. But, before I go on and spend more time watching, I'd like to ask if Python will let me do what I want to do? Briefly, what I want to do is to model a sequential process of:

1. Start with a central parent sphere of diameter 2 Blender units.
2. Cover its entire surface in tangentially touching, non-overlapping child spheres also of diameter 2. These child spheres should be tangentially touching and non-overlapping with each other and with the parent sphere. You can fit in 12 spheres like this with just a little bit of uncovered surface of the parent sphere left over. At that point, fit in a 13th sphere, and because there's not enough room to fit in the whole sphere, it will be squeezed in there and therefore will bulge into its immediately adjacent neighbors.
3. Cover the child spheres with another layer of child spheres, so that it's like an expanding space made of concentric spheres of spheres.
4. While the child spheres are being added, the bulging into/compression forces where there's not enough room to fit in a whole sphere, will cause these spheres to start moving.
5. As the spheres start to move, parts of their surface will become un-covered by neighboring spheres, so I would like these uncovered surface areas to be re-covered in new child spheres.

So far, I tried adding the child spheres as a particle system, but the spheres all overlap, and I can't get them to not overlap. Is a particle system the right way to do the above? Also, can Python be used to:

o Adjust the positions of the particles in a particle system so that they don't overlap?
o Add non-overlapping child particles just to newly un-covered parts of a sphere's surface (step 5, above)?

Thank you!

Roger

roger
Автор

Hi
Enjoying the tutorial, Will you be expanding this series into creating Addon for blender ?

ArtInMotionStudios