예제 #1
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : int
//-----------------------------------------------------------------------------
int	CBaseAnimatingOverlay::AddLayeredSequence( int sequence, int iPriority )
{
	int i = AllocateLayer( iPriority );
	// No room?
	if ( IsValidLayer( i ) )
	{
		m_AnimOverlay[i].m_flCycle = 0;
		m_AnimOverlay[i].m_flPrevCycle = 0;
		m_AnimOverlay[i].m_flPlaybackRate = 1.0;
		m_AnimOverlay[i].m_nActivity = ACT_INVALID;
		m_AnimOverlay[i].m_nSequence = sequence;
		m_AnimOverlay[i].m_flWeight = 1.0f;
		m_AnimOverlay[i].m_flBlendIn = 0.0f;
		m_AnimOverlay[i].m_flBlendOut = 0.0f;
		m_AnimOverlay[i].m_bSequenceFinished = false;
		m_AnimOverlay[i].m_flLastEventCheck = 0;
		m_AnimOverlay[i].m_bLooping = ((GetSequenceFlags( GetModelPtr(), sequence ) & STUDIO_LOOPING) != 0);
		if (ai_sequence_debug.GetBool() == true && m_debugOverlays & OVERLAY_NPC_SELECTED_BIT)
		{
			Msg("%5.3f : adding %d (%d): %s : %5.3f (%.3f)\n", gpGlobals->curtime, i, m_AnimOverlay[ i ].m_nOrder.Get(), GetSequenceName( m_AnimOverlay[ i ].m_nSequence ), m_AnimOverlay[ i ].m_flCycle.Get(), m_AnimOverlay[ i ].m_flWeight.Get() );
		}
	}

	return i;
}
예제 #2
0
void CAnimating::ResetSequenceInfo()
{
	if (GetSequence() == -1)
	{
		// This shouldn't happen.  Setting m_nSequence blindly is a horrible coding practice.
		SetSequence( 0 );
	}

	CStudioHdr *pStudioHdr = GetModelPtr();
	m_flGroundSpeed = GetSequenceGroundSpeed( pStudioHdr, GetSequence() );
	m_bSequenceLoops = ((GetSequenceFlags( pStudioHdr, GetSequence() ) & STUDIO_LOOPING) != 0);
	// m_flAnimTime = gpGlobals->time;
	m_flPlaybackRate = 1.0;
	m_bSequenceFinished = false;
	m_flLastEventCheck = 0;

	m_nNewSequenceParity = ( *(m_nNewSequenceParity)+1 ) & EF_PARITY_MASK;
	m_nResetEventsParity = ( *(m_nResetEventsParity)+1 ) & EF_PARITY_MASK;

	// FIXME: why is this called here?  Nothing should have changed to make this nessesary
	if ( pStudioHdr )
	{
		SetEventIndexForSequence( pStudioHdr->pSeqdesc( GetSequence() ) );
	}
}
/*
==============================
SetupClientAnimation

Called to set up local player's animation values
==============================
*/
void CGameStudioModelRenderer::SetupClientAnimation(entity_state_t *pplayer)
{
	static double oldtime;
	double        curtime, dt;

	client_anim_state_t *st;
	float                fr, gs;

	cl_entity_t *ent = IEngineStudio.GetCurrentEntity();
	assert(ent);
	if(!ent)
		return;

	curtime = gEngfuncs.GetClientTime();
	dt      = curtime - oldtime;
	dt      = min(1.0, max(0.0, dt));

	oldtime = curtime;
	st      = &g_clientstate;

	st->framerate = 1.0;

	int oldseq = st->sequence;
	Game_GetSequence(&st->sequence, &st->gaitsequence); //CVAR_GET_FLOAT( "sequence" );
	Game_GetOrientation((float *)&st->origin, (float *)&st->angles);
	st->realangles = st->angles;

	if(st->sequence != oldseq)
	{
		st->frame           = 0.0;
		st->lv.prevsequence = oldseq;
		st->lv.sequencetime = st->animtime;

		memcpy(st->lv.prevseqblending, st->blending, 2);
		memcpy(st->lv.prevcontroller, st->controller, 4);
	}

	void *pmodel = (studiohdr_t *)IEngineStudio.Mod_Extradata(ent->model);

	GetSequenceInfo(pmodel, st, &fr, &gs);
	st->m_fSequenceLoops = ((GetSequenceFlags(pmodel, st) & STUDIO_LOOPING) != 0);
	StudioFrameAdvance(st, fr, dt);

	//	gEngfuncs.Con_Printf( "gs %i frame %f\n", st->gaitsequence, st->frame );

	ent->angles          = st->realangles;
	ent->curstate.angles = st->angles;
	ent->curstate.origin = st->origin;

	ent->curstate.sequence  = st->sequence;
	pplayer->gaitsequence   = st->gaitsequence;
	ent->curstate.animtime  = st->animtime;
	ent->curstate.frame     = st->frame;
	ent->curstate.framerate = st->framerate;
	memcpy(ent->curstate.blending, st->blending, 2);
	memcpy(ent->curstate.controller, st->controller, 4);

	ent->latched = st->lv;
}
예제 #4
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : iSequence - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool StudioModel::GetSequenceLoops( int iSequence )
{
	CStudioHdr *pStudioHdr = GetStudioHdr();
	if ( !pStudioHdr )
		return false;

	int flags = GetSequenceFlags( pStudioHdr, iSequence );
	bool looping = flags & STUDIO_LOOPING ? true : false;
	return looping;
}
예제 #5
0
//=========================================================
//=========================================================
void CBaseAnimating::ResetSequenceInfo()
{
	void *pmodel = GET_MODEL_PTR( ENT( pev ) );

	GetSequenceInfo( pmodel, pev, m_flFrameRate, m_flGroundSpeed );
	m_fSequenceLoops = ( ( GetSequenceFlags() & STUDIO_LOOPING ) != 0 );
	pev->animtime = gpGlobals->time;
	pev->framerate = 1.0;
	m_fSequenceFinished = false;
	m_flLastEventCheck = gpGlobals->time;
}
예제 #6
0
파일: hl_weapons.cpp 프로젝트: Skumek/hlsdk
/*
==============================
ResetSequenceInfo

==============================
*/
void CBaseAnimating :: ResetSequenceInfo ( )
{
	cl_entity_t *current;

	current = gEngfuncs.GetLocalPlayer();
	if ( !current || !current->model )
		return;

	void *pmodel = (studiohdr_t *)IEngineStudio.Mod_Extradata( current->model );

	GetSequenceInfo( pmodel, pev, &m_flFrameRate, &m_flGroundSpeed );
	m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0);
	pev->animtime = gpGlobals->time;
	pev->framerate = 1.0;
	m_fSequenceFinished = FALSE;
	m_flLastEventCheck = gpGlobals->time;
}
예제 #7
0
//-----------------------------------------------------------------------------
// Purpose: Add string indexed scene/expression/duration to list of active expressions
// Input  : scenefile - 
//			expression - 
//			duration - 
//-----------------------------------------------------------------------------
void CBaseFlex::AddSceneEvent( CChoreoScene *scene, CChoreoEvent *event )
{
	if ( !scene || !event )
	{
		Msg( "CBaseFlex::AddExpression:  scene or event was NULL!!!\n" );
		return;
	}


	CExpressionInfo info;

	info.m_pEvent		= event;
	info.m_pScene		= scene;
	info.m_bStarted	= false;

	switch ( event->GetType() )
	{
	case CChoreoEvent::SEQUENCE: 
		{
			info.m_nSequence = LookupSequence( event->GetParameters() );
			info.m_iLayer = -1;

			if (info.m_nSequence >= 0)
			{
				info.m_iLayer = AddLayeredSequence( info.m_nSequence, scene->GetChannelIndex( event->GetChannel()) );
				SetLayerWeight( info.m_iLayer, 0.0 );
				info.m_flStartAnim = m_flAnimTime; // ??
			}
		}
		break;
	case CChoreoEvent::GESTURE:
		{
			info.m_nSequence = LookupSequence( event->GetParameters() );
			info.m_iLayer = -1;

			if (info.m_nSequence >= 0)
			{
				// this happens before StudioFrameAdvance()
				info.m_iLayer = AddLayeredSequence( info.m_nSequence, scene->GetChannelIndex( event->GetChannel()) );
				SetLayerDuration( info.m_iLayer, event->GetDuration() );
				SetLayerWeight( info.m_iLayer, 0.0 );

				bool looping = ((GetSequenceFlags( info.m_nSequence ) & STUDIO_LOOPING) != 0);
				if ( looping )
				{
					DevMsg( 1, "vcd error, gesture %s of model %s is marked as STUDIO_LOOPING!\n", 
						event->GetParameters(), GetModelName() );
				}

				SetLayerLooping( info.m_iLayer, false ); // force to not loop

				// figure out the animtime when this was frame 0
				float dt =  scene->GetTime() - event->GetStartTime();
				info.m_flStartAnim = m_flAnimTime - dt; // ??
				float flCycle = 0;

				// assuming anim time is going to advance 0.1 seconds, what should our new cycle be?
				float duration = event->GetDuration( );
				float orig_duration = SequenceDuration( info.m_nSequence );
				SetLayerCycle( info.m_iLayer, 0.0 );
				float flNextCycle = event->GetShiftedTimeFromReferenceTime( (m_flAnimTime - info.m_flStartAnim + 0.1) / duration );

				float rate = (flNextCycle - flCycle) * orig_duration / 0.1;
				SetLayerPlaybackRate( info.m_iLayer, rate );
			}
		}
		break;
	}

	m_Expressions.AddToTail( info );
}