示例#1
0
文件: anim.c 项目: jtsiomb/libanim
quat_t anm_get_rotation(struct anm_node *node, anm_time_t tm)
{
    quat_t rot, prot;
    rot = anm_get_node_rotation(node, tm);

    if(!node->parent) {
        return rot;
    }

    prot = anm_get_rotation(node->parent, tm);
    return quat_mul(prot, rot);
}
示例#2
0
文件: anim.c 项目: jtsiomb/libanim
void anm_get_node_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm)
{
    int i;
    mat4_t rmat;
    vec3_t pos, scale;
    quat_t rot;

    pos = anm_get_node_position(node, tm);
    rot = anm_get_node_rotation(node, tm);
    scale = anm_get_node_scaling(node, tm);

    m4_set_translation(mat, node->pivot.x, node->pivot.y, node->pivot.z);

    quat_to_mat4(rmat, rot);
    for(i=0; i<3; i++) {
        mat[i][0] = rmat[i][0];
        mat[i][1] = rmat[i][1];
        mat[i][2] = rmat[i][2];
    }
    /* this loop is equivalent to: m4_mult(mat, mat, rmat); */

    mat[0][0] *= scale.x;
    mat[0][1] *= scale.y;
    mat[0][2] *= scale.z;
    mat[0][3] += pos.x;
    mat[1][0] *= scale.x;
    mat[1][1] *= scale.y;
    mat[1][2] *= scale.z;
    mat[1][3] += pos.y;
    mat[2][0] *= scale.x;
    mat[2][1] *= scale.y;
    mat[2][2] *= scale.z;
    mat[2][3] += pos.z;

    m4_translate(mat, -node->pivot.x, -node->pivot.y, -node->pivot.z);

    /* that's basically: pivot * rotation * translation * scaling * -pivot */
}
示例#3
0
quat_t psys_get_rot(struct psys_emitter *em, float tm)
{
	return anm_get_node_rotation(&em->prs, ANM_SEC2TM(tm));
}