Пример #1
0
void SSBoneFrame_CreateFromModel(ss_bone_frame_p bf, skeletal_model_p model)
{
    vec3_set_zero(bf->bb_min);
    vec3_set_zero(bf->bb_max);
    vec3_set_zero(bf->centre);
    vec3_set_zero(bf->pos);
    bf->transform = NULL;
    bf->flags = 0x0000;
    bf->bone_tag_count = 0;
    bf->bone_tags = NULL;
    
    SSBoneFrame_InitSSAnim(&bf->animations, model, ANIM_TYPE_BASE);
    bf->animations.model = model;
    if(model)
    {
        bf->bone_tag_count = model->mesh_count;
        bf->bone_tags = (ss_bone_tag_p)malloc(bf->bone_tag_count * sizeof(ss_bone_tag_t));
        bf->bone_tags[0].parent = NULL;                                         // root
        for(uint16_t i = 0; i < bf->bone_tag_count; i++)
        {
            ss_bone_tag_p b_tag = bf->bone_tags + i;
            b_tag->index = i;
            b_tag->is_hidden = 0x00;
            b_tag->is_targeted = 0x00;
            b_tag->is_axis_modded = 0x00;
            b_tag->mesh_base = model->mesh_tree[i].mesh_base;
            b_tag->mesh_replace = NULL;
            b_tag->mesh_skin = NULL;
            b_tag->mesh_slot = NULL;
            b_tag->skin_map = NULL;
            b_tag->alt_anim = NULL;
            b_tag->body_part = model->mesh_tree[i].body_part;

            vec3_copy(b_tag->offset, model->mesh_tree[i].offset);
            vec4_set_zero(b_tag->qrotate);
            Mat4_E_macro(b_tag->local_transform);
            Mat4_E_macro(b_tag->current_transform);

            vec3_set_zero(b_tag->mod.target_pos);
            vec4_set_zero_angle(b_tag->mod.current_q);
            b_tag->mod.bone_local_direction[0] = 0.0f;
            b_tag->mod.bone_local_direction[1] = 1.0f;
            b_tag->mod.bone_local_direction[2] = 0.0f;
            b_tag->mod.limit[0] = 0.0f;
            b_tag->mod.limit[1] = 1.0f;
            b_tag->mod.limit[2] = 0.0f;
            b_tag->mod.limit[3] =-1.0f;
            b_tag->mod.current_slerp = 1.0f;
            vec3_set_one(b_tag->mod.axis_mod);
            
            if(i > 0)
            {
                b_tag->parent = bf->bone_tags + model->mesh_tree[i].parent;
            }
        }
    }
}
Пример #2
0
struct ss_animation_s *SSBoneFrame_AddOverrideAnim(struct ss_bone_frame_s *bf, struct skeletal_model_s *sm, uint16_t anim_type_id)
{
    if(!sm || (sm->mesh_count == bf->bone_tag_count))
    {
        ss_animation_p ss_anim = (ss_animation_p)malloc(sizeof(ss_animation_t));
        SSBoneFrame_InitSSAnim(ss_anim, sm, anim_type_id);

        ss_anim->next = bf->animations.next;
        if(bf->animations.next)
        {
            bf->animations.next->prev = ss_anim;
        }
        bf->animations.next = ss_anim;
        
        return ss_anim;
    }

    return NULL;
}
Пример #3
0
void SSBoneFrame_CreateFromModel(ss_bone_frame_p bf, skeletal_model_p model)
{
    vec3_set_zero(bf->bb_min);
    vec3_set_zero(bf->bb_max);
    vec3_set_zero(bf->centre);
    vec3_set_zero(bf->pos);
    bf->transform = NULL;
    bf->bone_tag_count = 0;
    bf->bone_tags = NULL;
    
    SSBoneFrame_InitSSAnim(&bf->animations, ANIM_TYPE_BASE);
    bf->animations.model = model;
    if(model)
    {
        bf->bone_tag_count = model->mesh_count;
        bf->bone_tags = (ss_bone_tag_p)malloc(bf->bone_tag_count * sizeof(ss_bone_tag_t));
        bf->bone_tags[0].parent = NULL;                                         // root
        for(uint16_t i = 0; i < bf->bone_tag_count; i++)
        {
            bf->bone_tags[i].index = i;
            bf->bone_tags[i].mesh_base = model->mesh_tree[i].mesh_base;
            bf->bone_tags[i].mesh_skin = model->mesh_tree[i].mesh_skin;
            bf->bone_tags[i].mesh_slot = NULL;
            bf->bone_tags[i].alt_anim = NULL;
            bf->bone_tags[i].body_part = model->mesh_tree[i].body_part;

            vec3_copy(bf->bone_tags[i].offset, model->mesh_tree[i].offset);
            vec4_set_zero(bf->bone_tags[i].qrotate);
            Mat4_E_macro(bf->bone_tags[i].transform);
            Mat4_E_macro(bf->bone_tags[i].full_transform);

            if(i > 0)
            {
                bf->bone_tags[i].parent = bf->bone_tags + model->mesh_tree[i].parent;
            }
        }
    }
}