Skeletal animation

Carl Banks pavlovevidence at gmail.com
Mon Oct 5 18:25:17 EDT 2009


On Oct 5, 9:09 am, Manowar <r_marcanto... at netzero.net> wrote:
> On Oct 4, 8:38 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
>
>
>
>
>
> > On Oct 4, 5:16 pm, Manowar <r_marcanto... at netzero.net> wrote:
>
> > > On Oct 4, 6:38 pm, TerryP <bigboss1... at gmail.com> wrote:
>
> > > > On Oct 4, 10:05 pm, Manowar <r_marcanto... at netzero.net> wrote:
>
> > > > > I am new to pyton and have asked this question several times the
> > > > > answer is always not sure.
> > > > > Here is my question sekeltal animation ( bone animation) is it
> > > > > possible with python? What i want to develop is an aquarium in
> > > > > realtime, skeletal animation, all the movements will be from
> > > > > programming., no keyframes  let me know if it is possible with python
>
> > > > > Manowar
>
> > > > Depending on how much code you want to write, you'll probably want to
> > > > check out something like pygame or python-ogre
>
> > > Yeah, i know about those but i just really need to know if it is
> > > possible to do in python
> > > if it is what about some tutorials on bone animation?
>
> > It's possible.  I can't really recommend a tutorial because I don't
> > know where you are coming from, and it is a very complex subject.
> > What do know about 3D animation so far?  Have you done 3D animation in
> > other languages?  Have you done 3D mesh modeling with a tool like 3DS
> > Max or Blender?  What is your mathematical background (especially in
> > linear algrebra)?  Please help us help you by providing us details on
> > what you know already and what you want to do.  You won't get much
> > help by asking simple yes/no questions.
>
> > Carl Banks- Hide quoted text -
>
> > - Show quoted text -
>
> Let me tell you in more detail what i want maybe i am not explaining
> it correctly ( i will look at those links) I have been using Blender
> for years. I know animation but not an expert. If i make an aquarium i
> want the fish to move on their own with their own A.I. (Self-
> contained fish.) To make it clearer if i put a rock in it's path, the
> fish will move around the rock and if a predator comes into the scene
> the fish will scatter away at a high speed then return to normal when
> the predator goes. I know this can be done in C++ I won't go into why
> i am not using c++ just need to know if i can manipulate the bones in
> realtime with python. can't find any info on that but someone must
> know how to do it in python. Don't want keyframes just want true bone
> animation

Don't worry, I totally understand what you mean by "not using
keyframes".   Now that I'm a little better appraised of what you know
already now I can help better.  (See, if you were a newbie with no
programming experience who is asking "i wanna make fishies can mv
themslvs plz hlp" my advice would be a bit different....)

There are two ways to do what you want.  The first way is to represent
bones as OpenGL transformations.  Basically a joint deformation you'd
represent as a translation + rotation.  To rotate a bone you'd simply
update the rotation of that joint.  Then, when the proper
transformation is in place, just draw the mesh attached to the bone.
This can be done with simply with Python an OpenGL.  It's conceptually
simple but the details can be nasty.  Also it doesn't look very good.

The second way is skinning.  You have a big mesh and each vertex on
the mesh in influenced by any nearby bones.  This is more difficult
because a calculation is required for each vertex, and you can't take
advantage of OpenGL calcualtions(**), but it looks much better.  Also,
there is no way to do skinning calculations fast enough in Python.
You might be able to manage it with numpy.  However, what I do is to
use a C++ library called cal3d.  Yes, I had to write a wrapper, but
once I did that I could call everything from Python.  cal3d provides
keyframe animation, but it allows you to manipulate bones by hand if
you want.  (Given a bone you can call bone.setRotation.)

There's a third way, hardward skinning, but I think that's a fairly
recent development and you'd have to use a vertex shader.  Pretty
tough, but probably also the future.

Maybe harder than the actual drawing functions is to export a Blender
model in a format you can parse.  (There's a Blender cal3d exporter
out there, so if you were to use cal3d you could use that.)

So, tutorials.  Well I assume you are aware the PyOpenGL is a
relatively thin wrapper around C OpenGL, so you should be able to
follow a C OpenGL tutorial in Python as well.  Google for "skeletal
animation in OpenGL", you should find plenty, as it's a common, basic
technique.  Skinning is a more advanced so there is probably not as
many tutorials on that.  For exporting models, I think I would suggest
the studying the cal3d exporter.  Even if you don't use cal3d, it
should help you learn what you need to do to export skeletal models.
If you want to try hardware skinning you might look at lighthouse
opengl tutorials to learn GLSL first, then look for something on
hardware skinning.  That's hard as hell, though.


Carl Banks



More information about the Python-list mailing list