Skinned Mesh Animation on a header file? Why not!
Sat, 12 Jul 2014 14:06:19 +0100
I've recently updated my Collada parser so I can export skeleton animations and turn the whole thing (mesh with weights, animation matrices, skeleton) into a header file. I find this convenient for small projects where everything can be static.

When I made Snake on a Sphere I didn't want to invest time adding support for animation, so the original snake doesn't even open its mouth when eating That's why I hide the "action" with icon popups

I've just added animation to the engine, and with the help of the exporter, I can now import skinned models and animate them quite fast.

The skeleton tree is represented with a flat array structure, with array index pointers to the parent of each transform. When the parent is oneself, then it means the transform has no parent.

After export, the skeleton will look something like this (it's huge, so I just copy a few lines),

/**
 * @file monigote.h
 */
#ifndef MODEL_MONIGOTE_H_
#define MODEL_MONIGOTE_H_

static const vertexDataSkinned g_monigoteVertices[] = {
	{ {0.5323272f, 5.348835f, -1.007801f}, {0.1901608f, 0.07721179f, -0.9786981f}, {0.0f, 0.0f}, {0.5937652f, 0.3770943f, 0.02914047f}, {0, 5, 10, 0} }, 
	// etc
};

// rest of the data
// etc

// skeleton
static struct core::TreeNode g_monigoteJointTransformTree[] = {
	/*0: Control*/{0, math::Matrix4(-1.0f, 0.0f, -0.0f, 0.0f, 0.0f, 1.0f, -0.0f, -4.416751f, -0.0f, -0.0f, -1.0f, -0.0f, 0.0f, 0.0f, -0.0f, 1.0f)}, 
	/*1: Stomach*/{0, math::Matrix4(-0.9999999f, 8.74228e-08f, -7.10543e-15f, 0.0f, -4.84881e-09f, -0.05546403f, -0.9984608f, 4.62893f, -8.72882e-08f, -0.9984607f, 0.05546403f, 0.212178f, 0.0f, 0.0f, -0.0f, 1.0f)}, 
	// rest of the bones...
};

You can find the header files for reference in the Headerify project

If you find it useful, please let me know


◀️ Older | Newer ▶️

⏪ Previous year | Next year ⏩