OK, I'm starting to get my head around the bone movements. I've realised that you pretty much have to define the bone centers as per how they are in blender, then set the bone position as the same if you want to get static rotation from the bone center.
Code: Select all
function pose(seconds) {
var statue_index = 0;
var bone_count = 9;
var a = 0.5*(Math.sin(seconds * 2)+1);
var b = 250
var bone_centers = [ -1.5, 0.8, 0, 1.5, 0.8, 0, -0.4, 0.8, 0, 0.4, 0.8, 0, 0, -3.8, 0, 0, -3.8, 0, 0, -0.9, 0, 0, -0.9, 0, 0, 0, 0 ];
var bone_positions = [ -1.5, -0.5*a+0.8, 0, 1.5, -0.5*a+0.8, 0, -0.4, -0.5*a+0.8, 0, 0.4, -0.5*a+0.8, 0, 0, -3.8, 0, 0, -3.8, 0, 0, -0.5*a-0.9, 0, 0, -0.5*a-0.9, 0, 0, -0.5*a, 0 ];
var bone_rotations = [
Math.cos(a*Math.PI/8), -Math.sin(a*Math.PI/8), 0,
Math.sin(a*Math.PI/8), Math.cos(a*Math.PI/8), 0,
0, 0, 1,
Math.cos(-a*Math.PI/8), -Math.sin(-a*Math.PI/8), 0,
Math.sin(-a*Math.PI/8), Math.cos(-a*Math.PI/8), 0,
0, 0, 1,
1, 0, 0,
0, 1, 0,
0, 0, 1,
1, 0, 0,
0, 1, 0,
0, 0, 1,
1, 0, 0,
0, Math.cos(a*Math.PI/8), -Math.sin(a*Math.PI/8),
0, Math.sin(a*Math.PI/8), Math.cos(a*Math.PI/8),
1, 0, 0,
0, Math.cos(a*Math.PI/8), -Math.sin(a*Math.PI/8),
0, Math.sin(a*Math.PI/8), Math.cos(a*Math.PI/8),
1, 0, 0,
0, Math.cos(-a*Math.PI/6), -Math.sin(-a*Math.PI/6),
0, Math.sin(-a*Math.PI/6), Math.cos(-a*Math.PI/6),
1, 0, 0,
0, Math.cos(-a*Math.PI/6), -Math.sin(-a*Math.PI/6),
0, Math.sin(-a*Math.PI/6), Math.cos(-a*Math.PI/6),
1, 0, 0,
0, 1, 0,
0, 0, 1
];
mx.pose_statue(statue_index, bone_count, bone_centers, bone_positions, bone_rotations);
}