Support for animation

74 views
Skip to first unread message

Andrey Nechypurenko

unread,
Oct 7, 2012, 6:09:38 AM10/7/12
to pyco...@googlegroups.com
Hi Folks,

I am trying to extend the daeviewer example with support for animation and have some questions. I would really appreciate any help or tips from other pycollada users and developers.

What is typically necessary for animation is to change some transformation (for example, rotation) for certain primitive and redraw it. So my first question is where can I find a list of transformations defined for the primitive? I realized, that there is a "matrix" member variable used to create bounded primitives, but it seams like it represents combined transformation. However, what I think is necessary is the list of named transformations to make it easier to find target transformation based on the parameters defined in the animation. Is something like this already exists in pycollada?

Since pycollada reader already applies defined transformations to create bounded primitives, I thought that, as a first experiment I can access original primitive and apply transformation matrix myself. I've assumed, that I can treat this matrix as ModelView matrix (using OpenGL terminology) and can pass it to the shader as a parameter. For these purposes, I flatten the original matrix as following:

  transform_matrix = []
  for row in geom.matrix:
    transform_matrix.extend(row.tolist())

Then I modify the simplePhong vertex shader from daeview visualization example:

varying vec3 normal, lightDir0, eyeVec;
uniform mat4 mvMatrix;
uniform mat4 pMatrix;
void main()
{
  normal = gl_NormalMatrix * gl_Normal;
  vec4 vVertex = mvMatrix * gl_Vertex;
  lightDir0 = vec3(gl_LightSource[0].position.xyz - vVertex.xyz);
  eyeVec = -vVertex.xyz;
  gl_Position = pMatrix * vVertex;
}

where pMatrix is an OpenGL projection matrix and calculated as described here:

def createProjectionMatrix(fovY, aspect, zNear, zFar):
    """Creates perspective projection matrix. fovY should be in radians"""
    f = 1.0 / math.tan(fovY/2.0) #cotangent(fovY/2)
    dz = zNear - zFar
    m = []
    m.extend([f/aspect, 0.0,                 0.0,                       0.0])
    m.extend([0.0,        f,                 0.0,                       0.0])
    m.extend([0.0,      0.0, (zFar + zNear) / dz, (2.0 * zFar * zNear) / dz])
    m.extend([0.0,      0.0,                -1.0,                       0.0])
    return m

Despite all my attempts, with this approach I was unable to visualize the model as it should be. My best results were all primitives drawn at origin, which corresponds to the original primitive with all transformations ignored. So maybe there is some conceptual mistake in my approach and I would highly appreciate if someone experienced with pycollada can provide some comments on it.

Thank you,
Andrey.

Jeff Terrace

unread,
Dec 10, 2012, 1:22:57 PM12/10/12
to pyco...@googlegroups.com, Andrey Nechypurenko
Hey Andrey,

Sorry for the (really) late reply.

The current master branch of pycollada doesn't really handle animations at all. The controller class is unfinished, and the scene class just keeps a list of transformations without reading animations.

There's an animation branch where I started work on reading animation data, but it's in a very early stage. I was working on it in combination with meshtool, which uses the Panda3D graphics library. With Panda3D and pycollada, I think the animations might not be too difficult to get working.

Jeff




--
 
 

Andrey Nechypurenko

unread,
Dec 13, 2012, 7:02:50 AM12/13/12
to Jeff Terrace, pyco...@googlegroups.com
Hi Jeff,

> Sorry for the (really) late reply.

No problem. Better later than never :-) .

> There's an animation branch where I started work on reading animation data,
> but it's in a very early stage. I was working on it in combination with
> meshtool, which uses the Panda3D graphics library. With Panda3D and
> pycollada, I think the animations might not be too difficult to get working.

Sounds interesting. I am wondering, how tight are you going to couple
pycollada animation staff with Panda3D? Would it be also easily
possible to use all the animation-related stuff with other
visualization libraries then Panda3D?


Andrey.

siva sankar

unread,
May 15, 2015, 11:01:20 AM5/15/15
to pyco...@googlegroups.com, andre...@googlemail.com
Hi
Pycollada for great for static mesh. But my application needs mesh for animations.
Any progress on animation? I need to extract mesh file, skeletal transformations, move the bone and skin it. I am new to python and Collada. Any help would be very great. 
Reply all
Reply to author
Forward
0 new messages