Matin Strubel's Python/Blender Tutorial--No Fear of snakes

I was wondering if anyone had read this tutorial and could answer a few questions I had. It seems that Mr. Strubel has dropped out of the blender world. But I did have some questions on the code he used.

yeah, I read those.

some parts are outdated a bit though.

just fire the question and people will probably answer even if they never read them.

Martin

Ok teeth on line 16 he uses


r=box.SizeX + (0.7 + 0.1 * sine (10 * t  * pi2/speed)

I understand that he is geting the radius of the box for the lamp to tumble in but:

What was the purpose of the “0.7 + 0.1” ?
Why multiply the angle in the sine function by 10?

later he uses:

 lampdat.Energ = 1.0 + 0.5 * r 

I understand that he is varying the brightness of the lamp depending on its position(radius) inside the box but :

Why the 1.0 + 0.5?

Opps,!!! Never mind i just figured out the second question. he is halving the radius and then adding 1.0 to it ( I suppose so the lamp can have at least the default brightness of 1.0) so as the radius gets bigger so does the brightness of the lamp.

But I am still foggy on that first question.

it’s not 0.7 + 0.1 but rather 0.7 + (0.1 sin(10t*pi2/speed))
you have to check for the priorities of operation you know.

as for the multiplication by 10, I guess that he wanted the rotation to be faster.

Martin

You know I forgot all about the priority of operations. I normally do mine from right to left so I assume everyone does. Ok it makes sense now.

The next thing is the differnece between LA:Lamp and OB:LampOBj.

But I need to read that section over again so I can come up with a question that describes what I do not understand. Rigth now its just a big fog :frowning:

Ok I moved on to section two. I decided to wait on the lamp question until I read it over once more. The first example of the second section (New Snake Fodder) Carsten write the classic “Hello World” program.
at the end he uses a line like:

 Register (gui, event, bevent) 

I can not find either Register(), event, or bevent in the pythonapi.pdf, gamelogic.pdf or blenderapi.pdf that I downloaded from blender.org. Are these missing or am I missing something?

If I’m not mistaken, these are parts of the Blender.Draw module. The Register(gui, event, bevent) is the command that initiates a GUI using the defined functions gui (OpenGL buttons and such), event (keyboard events), and bevent (OpenGL button events).
You can see this in action:

001:  # Hello_GUI.py
002:  # [email protected]
003:
004:  from Blender.Draw import *
005:
006:  def gui():
007:    Button("Thanks Ton & Daniel", 1, 40, 100, 150, 19)
008:
009:  def event(evt, val):
010:  # print "event : ",evt,val
011:    if (evt == ESCKEY and not val): Exit()
012:
013:  def bevent(evt):
014:  # print "bevent : ",evt
015:    if   (evt ==  1): Exit()
016:
017:  Register(gui, event, bevent)

edit: No, the draw module is not in any of those doc’s in full. The only way to get documentation for it is by browsing the doc strings in Python. You can use Zr’s doc browser, which is found in this file:
ftp://ftp.linux-magazin.de/pub/graphics/blender/Python4.tgz

that’s not really related to Python but more to the Blender structure in general.
Each object (with the exception of Empties) are made up of two parts. The Object data, which determines where the object is in the 3D space, it’s rotation, it’s size and the Edit data (in your case, Lamp data). The Edit data changes type depending on the kind of object that you have. More than one object can be linked to the same Edit data. Those are called instances of the same data.

I hope that’s clear.

Martin