/** * @brief Appends a new animation to the current running one * @sa R_AnimGet * @sa R_AnimChange * @sa R_AnimRun * @sa R_AnimGetName * @param[in,out] as The animation state to append the new animation to * @param[in] mod The model to append the animation for * @param[in] name The animation name (from the *.anm file) to append */ void R_AnimAppend (animState_t * as, const model_t * mod, const char *name) { const mAliasAnim_t *anim; if (!mod || !mod->alias.num_anims) return; /* get animation */ anim = R_AnimGet(mod, name); if (!anim) return; if (as->lcur == as->ladd) { /* first animation */ as->oldframe = anim->from; if (anim->to > anim->from) as->frame = anim->from + 1; else as->frame = anim->from; as->backlerp = 0.0; as->time = anim->time; as->dt = 0; as->change = qtrue; } R_AnimAdd(as, mod, anim); }
/** * @brief Changes the animation for md2 models * @sa R_AnimGet * @sa R_AnimAppend * @sa R_AnimRun * @sa R_AnimGetName * @param[in,out] as Client side animation state of the model * @param[in] mod Model structure to change the animation for * @param[in] name Animation state name to switch to */ void R_AnimChange (animState_t * as, const model_t * mod, const char *name) { const mAliasAnim_t *anim; if (!mod) { Com_Printf("R_AnimChange: No model given (%s)\n", name); return; } if (!mod->alias.num_anims) { Com_Printf("R_AnimChange: Model with no animations (%s) (model: %s)\n", name, mod->name); return; } /* get animation */ anim = R_AnimGet(mod, name); if (!anim) { Com_Printf("R_AnimChange: No such animation: %s (model: %s)\n", name, mod->name); return; } if (as->lcur == as->ladd) { /* first animation */ as->oldframe = anim->from; if (anim->to > anim->from) as->frame = anim->from + 1; else as->frame = anim->from; as->backlerp = 1.0; as->time = anim->time; as->dt = 0; as->change = qtrue; } else { /* next animation */ as->ladd = LOOPNEXT(as->lcur); if (anim->time < as->time) as->time = anim->time; /* don't change to the same animation */ if (anim != R_AnimGetAliasAnim(mod, as)) as->change = qtrue; } R_AnimAdd(as, mod, anim); }
/** * @brief Appends a new animation to the current running one * @sa R_AnimGet * @sa R_AnimChange * @sa R_AnimRun * @sa R_AnimGetName * @param[in,out] as The animation state to append the new animation to * @param[in] mod The model to append the animation for * @param[in] name The animation name (from the *.anm file) to append */ void R_AnimAppend (animState_t *as, const model_t *mod, const char *name) { const mAliasAnim_t *anim; if (!mod) { Com_Printf("R_AnimAppend: No model given (%s)\n", name); return; } if (!mod->alias.num_anims) { Com_Printf("R_AnimAppend: Model with no animations (%s) (model: %s)\n", name, mod->name); return; } /* get animation */ anim = R_AnimGet(mod, name); if (!anim) { Com_Printf("R_AnimAppend: No such animation: %s (model: %s)\n", name, mod->name); return; } if (as->lcur == as->ladd) { /* first animation */ as->oldframe = anim->from; if (anim->to > anim->from) as->frame = anim->from + 1; else as->frame = anim->from; as->backlerp = 0.0; as->time = anim->time; as->dt = 0; as->change = true; } R_AnimAdd(as, mod, anim); }