reading an animation

52 views
Skip to first unread message

Riccardo Rossi

unread,
Apr 28, 2015, 3:26:21 PM4/28/15
to pyco...@googlegroups.com
Dear list,
I work in CFD and I am a newcomer in geometry handling.

For some reasons I would be interested in importing a collada skeletal animation. Essentially what I would like to know is the position of all of the nodes (I guess my nomenclature is different, I mean the position of the vertices of the triangles) in the skin at a given instant in time.

I shall say that I do not really understand the definition of the different reference systems. Ideally I would need this in the "real" space (not sure if it is the "world space in colladas naming)
Is this doable within pycollada?
Performance is not really a problem for now.

The in advance for any hint

Riccardo



Jeff Terrace

unread,
Apr 28, 2015, 3:43:42 PM4/28/15
to pyco...@googlegroups.com
pycollada master branch does not support animations. There is an animation branch that I started, but it is far from complete.

Jeff



Riccardo



--
You received this message because you are subscribed to the Google Groups "pycollada" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pycollada+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Riccardo Rossi

unread,
Apr 29, 2015, 1:07:59 AM4/29/15
to pyco...@googlegroups.com

I ll check it out over the next days.

My needs are extremely basic.

Is there an example anywhere?

Riccardo

You received this message because you are subscribed to a topic in the Google Groups "pycollada" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pycollada/AhOgIRI_NEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pycollada+...@googlegroups.com.

Riccardo Rossi

unread,
Apr 30, 2015, 5:21:19 AM4/30/15
to pyco...@googlegroups.com
Hi again,

i downloaded the "animation" branch. I see there is also "animation2" branch, did i choose the correct one?

having said this, could you give me any guidance on where to start for trying to need this?

essentially what i would love to do is to do something like

1  - at frame 100 (to say a number) find the position of the vertices that form the skin
2 - iterate over all of the vertices in the skin and get their position
3 - copy to my program (a FE code called "Kratos" www.cimne.com/kratos) the triangles that form the skin and the corresponding vertices updated positions

i would be very thankful if you could give me any orientation on this...

regards
Riccardo




On Wednesday, April 29, 2015 at 7:07:59 AM UTC+2, Riccardo Rossi wrote:

I ll check it out over the next days.

My needs are extremely basic.

Is there an example anywhere?

Riccardo

On 28 Apr 2015 21:43, "Jeff Terrace" <jter...@gmail.com> wrote:
pycollada master branch does not support animations. There is an animation branch that I started, but it is far from complete.

Jeff

On Tue, Apr 28, 2015 at 12:26 PM, Riccardo Rossi <roug...@gmail.com> wrote:
Dear list,
    I work in CFD and I am a newcomer in geometry handling.

For some reasons I would be interested in importing a collada skeletal animation. Essentially what I would like to know is the position of all of the nodes (I guess my nomenclature is different, I mean the position of the vertices of the triangles) in the skin at a given instant in time.

I shall say that I do not really understand the definition of the different reference systems. Ideally I would need this in the "real" space (not sure if it is the "world space in colladas naming)
Is this doable within pycollada?
Performance is not really a problem for now.

The in advance for any hint

Riccardo



--
You received this message because you are subscribed to the Google Groups "pycollada" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pycollada+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "pycollada" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pycollada/AhOgIRI_NEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pycollada+unsubscribe@googlegroups.com.

Jeff Terrace

unread,
Apr 30, 2015, 11:22:39 AM4/30/15
to pyco...@googlegroups.com
That's the right branch, but it was still in its very early stages when I stopped working on it in 2012. I'm not sure you're going to get any value out of it. You might try using OpenCOLLADA instead, since I think it has full animation support last I checked.

To unsubscribe from this group and stop receiving emails from it, send an email to pycollada+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "pycollada" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pycollada/AhOgIRI_NEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pycollada+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "pycollada" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pycollada+...@googlegroups.com.

Riccardo Rossi

unread,
May 4, 2015, 10:23:19 AM5/4/15
to pyco...@googlegroups.com
Hi Again,

sorry for being insistent with this, but i have the feeling there is a lot of stuff already within pycollada...and it is me
asking the wrong questions.

i am trying to open the "Astroboy_walk" dae example,

http://www.wazim.com/Downloads.htm


as i first step i merged the "animation.py" from the animation branch within the master branch (locally in my computer).
The only thing needed to have it running under python 3.4.3 is to change

 except DaeError , ex:   ---->  except DaeError as ex:

with this minor change it runs through the example file.

the point is that i don't have a clue to what to do next :-(




as of now i can succesfully open the examples in the master branch.

my wrapper is as follows:

from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7

# importing the Kratos Library ---> this is my program
#from KratosMultiphysics import *
#from KratosMultiphysics.IncompressibleFluidApplication import *
#from KratosMultiphysics.FluidDynamicsApplication import *
#CheckForPreviousImport()

#importing the collada library
import collada
import numpy

class ColladaImporter:
    def __init__(self,model_part, collada_filename):
        self.model_part = model_part
        self.collada_filename = str(collada_filename)
       
        #open and import the collada collada_file
        print("attempting to open ", self.collada_filename)
        f = open(self.collada_filename,'rb')
        print("line 21")
        self.collada_mesh = collada.Collada(f)
        f.close()
   
    def GenerateModelPartConditions(self, condition_name):
        #kratos auxiliaries
        nodeid = 1
        elid = 1
        prop = self.model_part.Properties[0]

           
        ##following block reads in a collada static file and generates the kratos database
        scene = self.collada_mesh.scene
        for mesh in scene.objects('geometry'):
            print("mesh = ",mesh)
            #first of all generate all of the kratos nodes for this mesh
            primitives_list = list(mesh.primitives())
            print(primitives_list)
            for triset in primitives_list:
                print("triset = ", type(triset) )
                if( type(triset) == collada.triangleset.BoundTriangleSet):
                   
               
                    #here we loop over all of the triangles
                    for tri_indices in triset.vertex_index:
                        node0_coords = triset.vertex[tri_indices][0]
                        node1_coords = triset.vertex[tri_indices][1]
                        node2_coords = triset.vertex[tri_indices][2]
                        #print("node0", node0_coords)
                        #print("node1", node1_coords)
                        #print("node2", node2_coords)
                       
                        ##here we shall generate the kratos node for each of those
                        elemental_ids = []
                        kratos_node0 = self.model_part.CreateNewNode( nodeid, float(node0_coords[0]), float(node0_coords[1]), float(node0_coords[2]))
                        elemental_ids.append(nodeid)
                        nodeid += 1
                       
                        kratos_node1 = self.model_part.CreateNewNode( nodeid, float(node1_coords[0]), float(node1_coords[1]), float(node1_coords[2]))
                        elemental_ids.append(nodeid)
                        nodeid += 1
                       
                        kratos_node2 = self.model_part.CreateNewNode( nodeid, float(node2_coords[0]), float(node2_coords[1]), float(node2_coords[2]))
                        elemental_ids.append(nodeid)
                        nodeid += 1
                       
                        ##here generate the conditions
                        self.model_part.CreateNewCondition(condition_name, elid,  elemental_ids, prop)
                        elid += 1
                       
                        ##we shall also keep this in a tuple for future use, maintaining the order of creation
                   
            
###################################### UNDER HERE I DON't KNOW WHAT TO DO      
            ##here i would wish to get the sheleton and the SKINNING information...
           
           
            ###here loop over the skins in needed
            #print("controller = ",self.collada_mesh.controllers)
            for skin in self.collada_mesh.controllers:
                print(skin)
                print("skin geometry",skin.joint_matrices)
               
            the point is that the skin contains quite a lot of information, i guess essentially everything that is needed for the next step, can you give me any hint on how to use it? without documentation it is very difficult for me to figure out anything :-(

for example the output of

         for skin in self.collada_mesh.controllers:
                print(skin)
                print("skin geometry",skin.joint_matrices)

returns somethng like

skin joint_matrices {'Bone12': array([[  1.69727996e-01,  -9.85490978e-01,   0.00000000e+00,
         -6.20919988e-02],
       [  6.23500021e-03,   1.07300002e-03,  -9.99979973e-01,
          4.26881981e+00],
       [  9.85471010e-01,   1.69724002e-01,   6.32699998e-03,
         -2.99811006e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00]], dtype=float32), 'Bone26': array([[  1.69724002e-01,   9.85491991e-01,   0.00000000e+00,
          6.20829985e-02],
       [  6.23500021e-03,  -1.07300002e-03,   9.99979973e-01,
         -4.26881981e+00],
       [  9.85472023e-01,  -1.69721007e-01,  -6.32699998e-03,
          2.99811006e+00],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00]], dtype=float32), 'Bone6': array([[  9.17199999e-03,  -9.99957979e-01,  -9.99999997e-07,
          2.81807005e-01],
       [ -2.01000003e-04,   0.00000000e+00,  -1.00000000e+00,
          4.34613991e+00],
       [  9.99957979e-01,   9.17199999e-03,  -2.01000003e-04,
         -3.10878009e-01],
       [  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
          1.00000000e+00]], dtype=float32), 'Bone1': array([[ 0.   


which suggests that the data is actually being loaded.

if you could tell me how to use this, i could write the morphing operation myself...

the point is that having this in python would be extremely convenient, particularly since also OpenCollada is without documentation...

regards
Riccardo

           
       
       
       
       
   
       
Reply all
Reply to author
Forward
0 new messages