Skeletal animation

M

Manowar

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
 
T

TerryP

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
 
M

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? if you kno of
any

Manowar
 
A

alex23

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

I found this googling "python skeletal model animation", it sounds
like it would make a great point to start from:

http://croquetconsortium.org/index.php/Skeletal_Animation_Example

"The point of this project is to build a complete working example of
the UMN Skeletal Animation package which can be freely distributed
under the Croquet license. It appears that the biggest part of this
project is to create one or more model meshes, create one or more
animation sequences for the meshes, and export the meshes, all related
textures and materials, and all animations in the Ogre XML format.

"Blender3D version 2.44 will be used for this example. The Ogre Meshes
Exporter was chosen as it appears to be comprehensive and current.
This exporter requires Python 2.5 to be installed, not just the cut-
down version of Python included with Blender3D. While I was at it, I
also grabbed a download of Python-Ogre because it has lots of
interesting examples, although it will not be directly used by this
project. At least that was the original plan - actually the binary<-
XML translator program was used to translate a couple of free models
from Psionic. So now there are three rigged, skinned, and animated
models available; the Star model built during this project, and two
models made available by Psionic and translated to Ogre XML for this
project, with his permission."

This page also lists a number of packages with Python-bindings that
list "skeletal animation" amongst their feature sets:

http://www.worldforge.org/media/documents/docs3d/tools_3d_compare
 
C

Carl Banks

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
 
A

AK Eric

Building on what others have said and giving a +1 to Carl:
I work daily in Maya doing character setup and rigging. As far as
doing it straight in Python, again, like others, take a look at PyGame
or Blender. I think the main question is: Do you want skeletal
animation, or do you want skeletal animation specifically in Python?
While Python is heavily used in Blender, I'm not sure how much of the
foundation it actually makes. Take a look ta this PyGame:
http://www.pygame.org/project-StickyPy-1248-2254.html
Of course PyGame is just a wrapper for SDL
Joints and skeletons are abstract concepts that sure, you could do
with Python. The question is how you want to render that to the
screen, and that's where the other apps come in.
 
H

Hendrik van Rooyen

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

Sure - you can draw anything on a Tkinter canvas, and move it around.

Also look at pygame, and PIL

- Hendrik
 
M

Manowar

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

Manowar
 
C

Carl Banks

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
 
N

Nobody

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 main problem here is you have to have a separate mesh for each bone.
You can't make a bone affect part of a mesh; or rather, you can't make a
bone affect part of a polygon, i.e. you can't have one vertex attached to
one bone and another vertex of the same polygon attached to a different
bone. This limits it to rigid bodies (machines, robots, etc); you can't
use it for anything with a flexible skin.
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.

A numpy solution for one-bone-per-vertex (i.e. no blending) is quite
straightforward:

bone_xforms = np.empty((n_bones,3,3), dtype=float)
base_vertices = np.empty((n_verts,3), dtype=float)
vertex_bones = np.empty((n_verts,), dtype=int)
...
xform_vertices = add.reduce(bone_xforms[vertex_bones] * b[:,newaxis,:], axis=2)

[This can be extended to blending a fixed number of bones per vertex,
but is inefficient if the number of bones varies.]

This will be much quicker than doing the arithmetic in Python, but may
still be noticeably slower than a typical C/C++ solution due to copying
the matrices (i.e. bone_xforms[vertex_bones] will duplicate each 3*3 array
to create a n_verts*3*3 array in memory).

OTOH, there might be ways to improve upon this; you could try asking
on the numpy mailing list.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,189
Messages
2,571,016
Members
47,618
Latest member
Leemorton01

Latest Threads

Top