/* ================== CG_animMapObj ================== */ void CG_AnimMapObj( centity_t *cent ) { refEntity_t ent; entityState_t *es; float scale; animation_t anim; es = ¢->currentState; // if set to invisible, skip if( !es->modelindex || ( es->eFlags & EF_NODRAW ) ) return; memset( &ent, 0, sizeof( ent ) ); VectorCopy( es->angles, cent->lerpAngles ); AnglesToAxis( cent->lerpAngles, ent.axis ); ent.hModel = cgs.gameModels[ es->modelindex ]; VectorCopy( cent->lerpOrigin, ent.origin); VectorCopy( cent->lerpOrigin, ent.oldorigin); ent.nonNormalizedAxes = false; //scale the model if( es->angles2[ 0 ] ) { scale = es->angles2[ 0 ]; VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] ); VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] ); VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] ); ent.nonNormalizedAxes = true; } //setup animation anim.firstFrame = es->powerups; anim.numFrames = es->weapon; anim.reversed = false; anim.flipflop = false; // if numFrames is negative the animation is reversed if( anim.numFrames < 0 ) { anim.numFrames = -anim.numFrames; anim.reversed = true; } anim.loopFrames = es->torsoAnim; if( !es->legsAnim ) { anim.frameLerp = 1000; anim.initialLerp = 1000; } else { anim.frameLerp = 1000 / es->legsAnim; anim.initialLerp = 1000 / es->legsAnim; } cent->lerpFrame.animation = &anim; //run animation CG_AMOAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); // add to refresh list trap_R_AddRefEntityToScene(&ent); }
/* ================== CG_animMapObj ================== */ void CG_AnimMapObj( centity_t *cent ) { static refEntity_t ent; // static for proper alignment in QVMs entityState_t *es; float scale; animation_t anim; es = ¢->currentState; // if set to invisible, skip if ( !es->modelindex || ( es->eFlags & EF_NODRAW ) ) { return; } memset( &ent, 0, sizeof( ent ) ); VectorCopy( es->angles, cent->lerpAngles ); AnglesToAxis( cent->lerpAngles, ent.axis ); ent.hModel = cgs.gameModels[ es->modelindex ]; VectorCopy( cent->lerpOrigin, ent.origin ); VectorCopy( cent->lerpOrigin, ent.oldorigin ); ent.nonNormalizedAxes = false; //scale the model if ( es->angles2[ 0 ] ) { scale = es->angles2[ 0 ]; VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] ); VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] ); VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] ); ent.nonNormalizedAxes = true; } //setup animation anim.firstFrame = es->misc; anim.numFrames = es->weapon; anim.reversed = false; anim.flipflop = false; // if numFrames is negative the animation is reversed if ( anim.numFrames < 0 ) { anim.numFrames = -anim.numFrames; anim.reversed = true; } anim.loopFrames = es->torsoAnim; if ( !es->legsAnim ) { anim.frameLerp = 1000; anim.initialLerp = 1000; } else { anim.frameLerp = 1000 / es->legsAnim; anim.initialLerp = 1000 / es->legsAnim; } cent->lerpFrame.animation = &anim; if ( !anim.loopFrames ) { // add one frame to allow the animation to play the last frame // add another to get it to stop playing at the first frame anim.numFrames += 2; if ( !cent->animInit ) { cent->animInit = true; cent->animPlaying = !( cent->currentState.eFlags & EF_MOVER_STOP ); } else { if ( cent->animLastState != !( cent->currentState.eFlags & EF_MOVER_STOP ) ) { cent->animPlaying = true; cent->lerpFrame.animationTime = cg.time; cent->lerpFrame.frameTime = cg.time; } } cent->animLastState = !( cent->currentState.eFlags & EF_MOVER_STOP ); } //run animation CG_AMOAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); // add to refresh list trap_R_AddRefEntityToScene( &ent ); }