How to animate?

Hello. I’d appreciate a pointer to a tutorial on how to animate. Or, an indication of whether animation is at all possible-- does one just create objects for a single frame, and then animate them “in blender”?

thanks.

Can you be more specific. Are you talking about animating with python- via IPO/keys or mesh animation? Or are you talking about animating with Blender in general. If the latter, you’ll probably want to redirect to the animation forum.

If its IPO/keys, then there are python modules that let you set IPO curves and manipulate them.

If mesh animation, then you’ll probably want to look into script links.

I’m coming from povray, where I was very comfortable animating by typing code. I’ve done some regular animation in blender, before I ever opened the text/python code editor window in the program.

I’m wondering if it were possible to program in python, across frames, either:
i) the motion of bones (say a walking character)
ii) the position of a mesh vertices-- say, if I’ve got python code that outputs a mesh object, can I simply add something like povray’s “clock” variable to the python code and have the mesh respond to it frame by frame?

thanks. It’s possible that just precise jargon could get me going with my own googline.

i) I haven’t personally done it, but I believe its possible. It should be IPO keying. I’d suggest looking for the Collada Importer, BVH Importer, or C3D importer.

ii) Look into script links, specifically frame change ones. Its relatively trivial to modify a mesh every time a frame changes:


from Blender.Mathutils import Rand
import bpy

scn = bpy.data.scenes.active
ob = [o for o in scn.objects if o.name == 'myMeshObject']

if ob:
     me = ob[0].getData(mesh = True)
     for v in me.verts:
          v.co[0] += Rand(-1.0, 1.0)
          v.co[1] += Rand(-1.0, 1.0)
          v.co[2] += Rand(-2.0, 2.0)

Assign that as a script link as an example. To do so, go to the script buttons (buttons window->paper looking icon). It should have the enable script links toggle down by default. Click on the New button next to Scene Script link. Select your source text file. Change the frame and the mesh of the object myMeshObject will change.

Here you go!

http://blenderartists.org/forum/showthread.php?t=131739&highlight=beginer

helloreplica.com provides a wide array of Replica Watches and professional customer sevrice, our goal is to make every customer 100% satsfied. We are more than ready to show our unique prowess and fortes to gain our footing. And we also provide fast delivery service, we guarantee our listing price is lower than other competitor. welcome to oursite Watches replica Rolex Replica replica rolex replica watch

Atom, interesting demo. I couldn’t find in the API any description of a LOCROT parm, nor an indication of how I’d change the IPO of a mesh.

ForTe, I tried that code, complete with entering it into the scripts window, and it had no effect on the basic cube that is there with a New scene.

Most likely because you don’t have an object in your scene called ‘myMeshObject’.

The API documentation is here: http://www.blender.org/documentation/248PythonDoc/index.html

And more specifically, LOCROT is here: http://www.blender.org/documentation/248PythonDoc/Object-module.html#IpoKeyTypes

/Nathan

I finally tried out your code forTe, really neat!

ForTe, can you post a version that works on frame changes specified by the python code itself?

Not exactly sure what you meant by that, so I’ll try to cover multiple bases:

1.) Example files with one set up as a scene script link and one set up as an object script link:

http://gamulabs.freepgs.com/blends/scriptlinkanim.zip

2.) If you’re talking about not using script links (as in keying the animation with a python script), then you’re probably thinking about using shape keys (as an IPO solution to animation would involve script links). In that case look at this example code (see Crouch’s post at the end):

http://blenderartists.org/forum/showthread.php?p=1062800

The one issue with script links that’s very annoying is that since everything is calculated on the frame change event, you need to associate the data with the frame. For instance, if you look at the example I posted, it just continues on, it never repeats. So to counter that you have a couple of options:

Run a python script before the script link runs (or on the first time its run or whenever a parameter is changed) that either:

1.) Writes the different mesh frames to disk. The script link would then open the proper frame and insert the mesh in the object.

2.) Write the different mesh frames to a different scene. You would then look in this storage scene for the proper mesh and load it with a script link. There are some linkage issues with this. I believe one of Kai Kostack’s scripts used this method (can’t remember if its his Demolition (I believe its this one) or his Adaptive Subdiv).

3.) Use the Blender registry to store the mesh positions and load it back with a script link.

There are advantages/trade-offs with speed and memory usage for all three.

Hope that helps! Let me know If I made anything less clear…

Thanks, ForTe, this is extremely helpful. What I wanted to do was exactly laid out in the latter example. I’m still trying to wrap my head around why it’s less useful. But seeing the code for helps me baby-step into bpy in a way that wouldn’t have been possible with a look at the API docs.

Shameless plug: I hand-scripted an animatable character out of a mesh2 in povray, just for the joy of doing things the hard way. I am hoping eventually to do the same thing in blender with python: