Demo: Green Dragon

Articles with the tag: Skinning

Character skinning: finding rotation between vectors

Solving the angle problem: How to find the rotation between two vectors.

This solution is implemented in the Math class and will be invoked by the bezier curve-following IK method in the SkeletonNode class.

Given two normalised vectors, the cosine of the angle between them can be found using the dot product:

quat rotation(vec3 v1, vec3 v2)
    // v1 dot v2 = |v1| * |v2| * angle_cos
    // If the vectors are normalised, their magnitudes will be '1', and so:
    v1 = normalise(v1)
    v2 = normalise(v2)
    float angle_cos = dot(v1, v2)

The rotation axis can be found using the cross product of both vectors:

...rotation() cont'd...
vec3 axis = normalise(cross(v1, v2))

Optimal forms for creating quaternion:

Naive rotation() method (ignoring special cases such as angle=0):

...rotation() cont'd...
float angle = acos(angle_cos)
return quaternion_from_axisangle(angle, axis)

The quaternion_from_axisangle() function likely uses trigonometry (such as the cosine function) to convert the given ...

Read More »

New animated model format: COLLADA

RapidXML anyone?

[13/04/14 14:54]

Coded XML interpreter. Just need to extract animation pose matrices and turn them into quaternions and positions for keyframe interpolation.

Converting matrix to quaternion using GLM:

glm::quat new_quat = glm::toQuat(bone_mat2);

[13/04/14 16:11]

For simplicity, multiple COLLADA model files can be used for different animations. Still using JSON files for vertices, normals and UV information, but ResMan should at some point be able to gather everything solely from one COLLADA file.

Read More »

Armature animation: extracting bone rotation data

ASSIMP just won't read my COLLADA file. Manually entering values from XML to see if the bone matrix values do anything. If so, can use an XML parser instead of ASSIMP.

First (root) bone from COLLADA XML file:

<COLLADA xmlns="http://www.COLLADA.org/2005/11/COLLADASchema" version="1.4.1">
<source id="Armature_Bone_pose_matrix-output">
    <float_array id="Armature_Bone_pose_matrix-output-array" count="32">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0.9937479 -0.111412 0.007234246 0 0.111412 0.9853772 -0.1289153 0 0.007234247 0.1289153 0.9916292 0 0 0 0 1</float_array>
      <accessor source="#Armature_Bone_pose_matrix-output-array" count="2" stride="16">
        <param name="TRANSFORM" type="float4x4"/>

Whelp, you can't reverse-engineer an XYZ-rotation matrix. Can try to use it directly, but that removes quaternion SLERP rotation.

Turns out you can:

R = r11 r12 r13
    r21 r22 r23
    r31 ...

Read More »

Armature bind pose matrices

The Inverse Bind Matrix is only generated once and is based on the root bone.

The current pose matrices are converted to global matrices and THEN combined with the inverse bind matrix.

This can then be combined with the World Transformation matrix, but as the bone matrices will be weighted in the vertex shader, it can just as suitably combined with the shader's WVP matrix input.

I hope that is it.

Read More »

Building a skinning matrix palette for the shader

Since ogldev's example uses strange matrix addition for its vertex weighting combination, and multiplying said matrices by scalars (which on testing doesn't seem to do anything), other references are worth a look such as this page.

Each bone using a mat4 takes up a lot of GPU registers. If the model contains many bones, it might be better to use a quaternion-translation vector pair, taking up half the space of a mat4. This of course comes with more processing overhead. mat4 will be fine for the demo.

[26/03/14 14:51]

Weight combining shader code appears to work. Must generate bone matrices from skeleal hierarchy.

And then... animation.

[26/03/14 15:33]

Possibly inefficient (because the same global matrix is generated for parent nodes over and over again. For example, Pelvis * Root is calculated for every bone.) recursive method for finding global pone transformations:

// Base case ...

Read More »


Created SkinnedMesh for bones, vertex weights and skin indices.

Read More »

Page 1 / 2 Older »