Implement R_IQMGetLerpedFrames().

Like R_AliasGetLerpedFrames, but for IQM. It calcualtes the current frame
number and blend between the previous and current frames.
This commit is contained in:
Bill Currie 2012-05-11 21:22:10 +09:00
parent 8387d987e2
commit c2e0674d50
4 changed files with 73 additions and 4 deletions

View file

@ -28,10 +28,11 @@
#ifndef _R_LOCAL_H
#define _R_LOCAL_H
#include "QF/iqm.h"
#include "QF/mathlib.h"
#include "QF/vid.h"
#include "QF/model.h"
#include "QF/render.h"
#include "QF/vid.h"
#include "r_shared.h"
#define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
@ -162,6 +163,7 @@ void R_AliasDrawModel (alight_t *plighting);
maliasskindesc_t *R_AliasGetSkindesc (int skinnum, aliashdr_t *hdr);
maliasframedesc_t *R_AliasGetFramedesc (int framenum, aliashdr_t *hdr);
float R_AliasGetLerpedFrames (entity_t *ent, aliashdr_t *hdr);
float R_IQMGetLerpedFrames (entity_t *ent, iqm_t *hdr);
float R_EntityBlend (entity_t *ent, int pose, float interval);
void R_BeginEdgeFrame (void);
void R_ScanEdges (void);

View file

@ -20,8 +20,8 @@ EXTRA_LTLIBRARIES= \
common_sources= \
crosshair.c noisetextures.c r_alias.c r_bsp.c r_cvar.c r_dyn_textures.c \
r_efrag.c r_ent.c r_graph.c r_light.c r_main.c r_part.c r_screen.c \
vid_common.c
r_efrag.c r_ent.c r_graph.c r_iqm.c r_light.c r_main.c r_part.c \
r_screen.c vid_common.c
renderer_libs= \
@vid_render_static_plugin_libs@ \

View file

@ -210,7 +210,7 @@ glsl_R_DrawIQM (void)
VectorCopy (ent->transform + 8, norm_mat + 6);
Mat4Mult (iqm_vp, ent->transform, mvp_mat);
blend = R_EntityBlend (ent, ent->frame, 0.1);
blend = R_IQMGetLerpedFrames (ent, iqm);
frame = malloc (iqm->num_joints * sizeof (iqmframe_t));
for (i = 0; i < iqm->num_joints; i++) {

View file

@ -0,0 +1,67 @@
/*
r_iqm.c
Shared IQM rendering support
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
Date: 2012/5/11
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include "QF/cvar.h"
#include "QF/render.h"
#include "QF/skin.h"
#include "QF/sys.h"
#include "r_internal.h"
float
R_IQMGetLerpedFrames (entity_t *ent, iqm_t *iqm)
{
int frame = ent->frame;
float time, fullinterval;
iqmanim *anim;
if (frame >= iqm->num_anims || frame < 0) {
Sys_MaskPrintf (SYS_DEV, "R_IQMGetLerpedFrames: no such frame %d\n",
frame);
frame = 0;
}
anim = &iqm->anims[frame];
fullinterval = anim->num_frames / anim->framerate;
time = vr_data.realtime + currententity->syncbase;
time -= ((int) (time / fullinterval)) * fullinterval;
frame = (int) (time * anim->framerate) + anim->first_frame;
return R_EntityBlend (ent, frame, anim->framerate);
}