Esempio n. 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->animations.type = ANIM_TYPE_BASE;
    bf->animations.anim_frame_flags = 0x0000;
    bf->animations.anim_ext_flags = 0x0000;
    bf->animations.frame_time = 0.0;
    bf->animations.period = 1.0 / 30.0;
    bf->animations.next_state = 0;
    bf->animations.lerp = 0.0;
    bf->animations.current_animation = 0;
    bf->animations.current_frame = 0;
    bf->animations.next_animation = 0;
    bf->animations.next_frame = 0;
    vec3_set_zero(bf->animations.target);
    bf->animations.bone_direction[0] = 0.0f;
    bf->animations.bone_direction[1] = 1.0f;
    bf->animations.bone_direction[2] = 0.0f;
    bf->animations.targeting_limit[0] = 0.0f;
    bf->animations.targeting_limit[1] = 1.0f;
    bf->animations.targeting_limit[2] = 0.0f;
    bf->animations.targeting_limit[3] =-1.0f;
    vec3_set_one(bf->animations.targeting_axis_mod);
    bf->animations.targeting_bone = 0x00;
    bf->animations.targeting_flags = 0x0000;

    vec4_set_zero_angle(bf->animations.current_mod);
    bf->animations.next = NULL;
    bf->animations.onFrame = NULL;
    bf->animations.onEndFrame = NULL;
    bf->transform = NULL;
    bf->animations.model = 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;
        }
    }
}
Esempio n. 2
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;
            }
        }
    }
}
Esempio n. 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;
            }
        }
    }
}