How would I load a collada file's skinning information?

I am trying to implement a COLLADA file loader to render in opengl.

Currently, I can load the basic mesh data and texture data, as well as vertex weights for each vertex. However, I am unsure how to get and use skinning data.

First of all, I am unsure of the exact terminology, specifically what the bind pose and inverse bind pose are, and what I need them for.

Second, I am unsure where to find these matrices. I think the inverse bind pose is found in a <source> tag in the file, labelled with a attribute with “bind_poses” at the end. I will show a sample tag below:


<source id="Armature_Cube-skin-bind_poses">
          <float_array id="Armature_Cube-skin-bind_poses-array" count="32">1 0 0 0.05214607 0 0 1 0.07466715 0 -1 0 -0.01507818 0 0 0 1 -0.9893552 0.1241412 0.0759291 -0.1199789 -0.0462982 -0.763187 0.644517 -0.6103146 0.1379593 0.6341408 0.7608106 -0.6872473 0 0 0 1</float_array>
          <technique_common>
            <accessor source="#Armature_Cube-skin-bind_poses-array" count="2" stride="16">
              <param name="TRANSFORM" type="float4x4"/>
            </accessor>
          </technique_common>
        </source>

Like I said, I am not sure how to use the matrices that I load from this tag.

Do note that I am trying not to animate the model (yet), just add bones that I can manually manipulate in my code.

Sorry if my question is hard to understand; I am completely lost on what terminology to use and what to do in general.

Thanks in advance.

[QUOTE=aparker314159;1287268]I am unsure how to get and use skinning data.
First of all, I am unsure of the exact terminology, specifically what the bind pose and inverse bind pose are, and what I need them for.

Sorry if my question is hard to understand; I am completely lost on what terminology to use and what to do in general.[/QUOTE]

I remember being where you are a few years ago. Skeletal isn’t hard, but a little background reading from a few good sources will pay big dividends for you. Here are my recommendations:

Really briefly to your specific questions… You know what a MODELING transform is, right (object-space -to- world-space transform)?

The BIND POSE transform is like a MODELING transform, except that it transforms you from: joint-space -to- object-space for a joint in the bind pose mesh. The inverse of the BIND POSE transform of course does the opposite.

The bind pose mesh is just the stored skeletal model, modeled in the “bind pose” – that is, the pose in which the skeleton was bound to the model by an animator.

hi PI parker :wink:

i’m not sure how you load the file, i’m using assimp for that, it’s relatively easy to use
http://assimp.sourceforge.net/lib_html/index.html
http://assimp.sourceforge.net/lib_html/data.html

here’s another article that describes that topic in principle
https://www.gamedev.net/resources/_/technical/graphics-programming-and-theory/skinned-mesh-animation-using-matrices-r3577

what you have to do is:
– give each vertex of your meshes several “float weights” and “uint indices”
– send them to the vertexshader (as vertex attributes), use these to compute the final vertex position:

uniform mat4 bonearray[MAX_BONES]; // computed on the cpu using animation keyframes

for each vertex you do:
----------------------------
mat4 Animation()
{
   mat4 animation = mat4(0);
   for each "weight-index" pair ...
      animation += bonearray[index] * weight;
   return animation;
} 

once you have the mat4 animation:

gl_Position = Projection * View * Model * animation * vertex;

usually 4 “weight-index” pairs are sufficient, so you can specify them like this:

in vec4 weights;
in uvec4 indices;

if a vertex for some reaon uses less the 4 bones, use a certain index (example: 0) mat4(1) to specify “no rotation/transformation”
if a vertex for some reason needs more then 4 bones, you’ll have to use more then 1 vertex attribute per “indices” and “weights” each