localplayer.id_wheel_r = skeleton_bone_id( sk, "wheel.R" );
localplayer.id_ik_knee_l = skeleton_bone_id( sk, "knee.L" );
localplayer.id_ik_knee_r = skeleton_bone_id( sk, "knee.R" );
+ localplayer.id_eyes = skeleton_bone_id( sk, "eyes" );
setup_ragdoll_from_skeleton( sk, &localplayer.ragdoll );
/* TODO: Standard model load */
static void dynamic_model_load( mdl_context *ctx,
- struct dynamic_model_1texture *mdl,
- const char *path ){
+ struct dynamic_model_1texture *mdl,
+ const char *path, u32 *fixup_table ){
if( !mdl_arrcount( &ctx->textures ) )
vg_fatal_error( "No texture in model" );
VG_TEX2D_NEAREST|VG_TEX2D_CLAMP,
&mdl->texture );
- mdl_async_load_glmesh( ctx, &mdl->mesh );
+ mdl_async_load_glmesh( ctx, &mdl->mesh, fixup_table );
}
static void dynamic_model_unload( struct dynamic_model_1texture *mdl ){
mdl_open( &ctx, path, vg_mem.scratch );
mdl_load_metadata_block( &ctx, vg_mem.scratch );
- dynamic_model_load( &ctx, &board->mdl, path );
+ dynamic_model_load( &ctx, &board->mdl, path, NULL );
mdl_array_ptr markers;
MDL_LOAD_ARRAY( &ctx, &markers, ent_marker, vg_mem.scratch );
mdl_open( &ctx, path, vg_mem.scratch );
mdl_load_metadata_block( &ctx, vg_mem.scratch );
- dynamic_model_load( &ctx, &board->mdl, path );
+ if( !ctx.armatures.count )
+ vg_fatal_error( "No armature in playermodel\n" );
+ mdl_armature *armature = mdl_arritm( &ctx.armatures, 0 );
+
+ u32 fixup_table[ armature->bone_count+1 ];
+ for( u32 i=0; i<armature->bone_count+1; i ++ )
+ fixup_table[i] = 0;
+
+ for( u32 i=1; i<localplayer.skeleton.bone_count; i ++ ){
+ struct skeleton_bone *sb = &localplayer.skeleton.bones[i];
+ u32 hash = vg_strdjb2( sb->name );
+
+ for( u32 j=1; j<armature->bone_count; j ++ ){
+ mdl_bone *bone = mdl_arritm( &ctx.bones, armature->bone_start+j );
+
+ if( mdl_pstreq( &ctx, bone->pstr_name, sb->name, hash ) ){
+ fixup_table[j+1] = i;
+ break;
+ }
+ }
+ }
+
+ dynamic_model_load( &ctx, &board->mdl, path, fixup_table );
mdl_close( &ctx );
}
localplayer.holdout_time -= vg.time_frame_delta * 2.0f;
}
+ v3_fill( pose->keyframes[ localplayer.id_eyes-1 ].co, sinf(vg.time) );
+
apply_full_skeleton_pose( sk, &localplayer.pose, localplayer.final_mtx );
skeleton_debug( sk, localplayer.final_mtx );