int CBaseAnimatingOverlay::AddGesture( Activity activity, float flDuration, bool autokill /*= true*/ ) { int iLayer = AddGesture( activity, autokill ); SetLayerDuration( iLayer, flDuration ); return iLayer; }
//----------------------------------------------------------------------------- // 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 ); }