X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_model.h;h=8d5dd80efc7ac3c2ff8c59d244267dcccca2e54a;hb=4eccfd7252f8ff165670842df537441afae5458b;hp=20e5c0a46c4d8e0d80d35279b70f7d09ade974d6;hpb=d00b1df8f80e4714dc2f9aa2189d242bb4d09a2f;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_model.h b/player_model.h index 20e5c0a..8d5dd80 100644 --- a/player_model.h +++ b/player_model.h @@ -2,123 +2,9 @@ * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved */ -#ifndef CHARACTER_H -#define CHARACTER_H - -#include "player.h" +#pragma once +#include "model.h" +#include "skeleton.h" #include "player_ragdoll.h" -#include "shaders/viewchar.h" - -vg_tex2d tex_characters = { .path = "textures/ch_gradient.qoi" }; - -static void player_model_init(void) -{ - shader_viewchar_register(); - vg_acquire_thread_sync(); - { - vg_tex2d_init( (vg_tex2d *[]){ &tex_characters }, 1 ); - } - vg_release_thread_sync(); -} - -static void player_model_free(void *_) -{ - mesh_free( &player.mdl.mesh ); - vg_tex2d_free( (vg_tex2d *[]){ &tex_characters }, 1 ); -} - -/* - * Load model from file (.mdl) - */ -static void player_load_model( const char *name ) -{ - char buf[64]; - - snprintf( buf, sizeof(buf)-1, "models/%s.mdl", name ); - mdl_header *src = mdl_load( buf ); - - if( !src ) - { - vg_error( "Could not load model\n" ); - return; - } - - struct player_model temp; - - mdl_unpack_glmesh( src, &temp.mesh ); - skeleton_setup( &temp.sk, src ); - - /* - * Link animations - */ - struct _load_anim - { - const char *name; - struct skeleton_anim **anim; - } - anims[] = { - { "pose_stand", &temp.anim_stand }, - { "pose_highg", &temp.anim_highg }, - { "pose_slide", &temp.anim_slide }, - { "pose_air", &temp.anim_air }, - { "push", &temp.anim_push }, - { "push_reverse", &temp.anim_push_reverse }, - { "ollie", &temp.anim_ollie }, - { "ollie_reverse",&temp.anim_ollie_reverse }, - { "grabs", &temp.anim_grabs }, - { "walk", &temp.anim_walk }, - { "run", &temp.anim_run }, - { "idle_cycle", &temp.anim_idle } - }; - - for( int i=0; i