コード例 #1
0
static bool IsFlexTrackBeingUsed( CChoreoEvent *event, char const *trackName )
{
    int tc = event->GetNumFlexAnimationTracks();
    for ( int track = 0; track < tc; ++track )
    {
        CFlexAnimationTrack *t = event->GetFlexAnimationTrack( track );
        if ( !t->IsTrackActive() )
        {
            continue;
        }

        int sampleCountNormal = t->GetNumSamples( 0 );
        int sampleCountBalance = 0;
        if ( t->IsComboType() )
        {
            sampleCountBalance = t->GetNumSamples( 1 );
        }

        if ( !sampleCountNormal && !sampleCountBalance )
            continue;

        // Otherwise, see if the test track has this as an active track
        if ( !Q_stricmp( t->GetFlexControllerName(), trackName ) )
        {
            return true;
        }
    }
    return false;
}
コード例 #2
0
static bool EventCollidesWithRows( CUtlLinkedList< CChoreoEvent*, int >& list, CChoreoEvent *event, char *trackName, size_t trackNameLength )
{
    float st = event->GetStartTime();
    float ed = event->GetEndTime();

    for ( int i = list.Head(); i != list.InvalidIndex(); i = list.Next( i ) )
    {
        CChoreoEvent *test = list[ i ];

        float teststart = test->GetStartTime();
        float testend = test->GetEndTime();

        // See if spans overlap
        if ( teststart >= ed )
            continue;
        if ( testend <= st )
            continue;

        // Now see if they deal with the same flex controller
        int tc = event->GetNumFlexAnimationTracks();
        for ( int track = 0; track < tc; ++track )
        {
            CFlexAnimationTrack *t = event->GetFlexAnimationTrack( track );
            if ( !t->IsTrackActive() )
            {
                continue;
            }

            int sampleCountNormal = t->GetNumSamples( 0 );
            int sampleCountBalance = 0;
            if ( t->IsComboType() )
            {
                sampleCountBalance = t->GetNumSamples( 1 );
            }

            if ( !sampleCountNormal && !sampleCountBalance )
                continue;

            // Otherwise, see if the test track has this as an active track
            if ( IsFlexTrackBeingUsed( test, t->GetFlexControllerName() ) )
            {
                Q_strncpy( trackName, t->GetFlexControllerName(), trackNameLength );
                return true;
            }
        }
        return false;
    }

    return false;
}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *event - 
//-----------------------------------------------------------------------------
void CBaseFlex::AddFlexAnimation( CExpressionInfo *info )
{
	if ( !info )
		return;

	CChoreoEvent *event = info->m_pEvent;
	if ( !event )
		return;

	CChoreoScene *scene = info->m_pScene;
	if ( !scene )
		return;

	if ( !event->GetTrackLookupSet() )
	{
		// Create lookup data
		for ( int i = 0; i < event->GetNumFlexAnimationTracks(); i++ )
		{
			CFlexAnimationTrack *track = event->GetFlexAnimationTrack( i );
			if ( !track )
				continue;

			if ( track->IsComboType() )
			{
				char name[ 512 ];
				Q_strncpy( name, "right_" ,sizeof(name));
				strcat( name, track->GetFlexControllerName() );

				track->SetFlexControllerIndex( 0, FindFlexController( name ), 0 );

				Q_strncpy( name, "left_" ,sizeof(name));
				strcat( name, track->GetFlexControllerName() );

				track->SetFlexControllerIndex( 0, FindFlexController( name ), 1 );
			}
			else
			{
				track->SetFlexControllerIndex( 0, FindFlexController( (char *)track->GetFlexControllerName() ) );
			}
		}

		event->SetTrackLookupSet( true );
	}

	float scenetime = scene->GetTime();

	float weight = event->GetIntensity( scenetime );

	// Compute intensity for each track in animation and apply
	// Iterate animation tracks
	for ( int i = 0; i < event->GetNumFlexAnimationTracks(); i++ )
	{
		CFlexAnimationTrack *track = event->GetFlexAnimationTrack( i );
		if ( !track )
			continue;

		// Disabled
		if ( !track->IsTrackActive() )
			continue;

		// Map track flex controller to global name
		if ( track->IsComboType() )
		{
			for ( int side = 0; side < 2; side++ )
			{
				int controller = track->GetFlexControllerIndex( side );

				// Get spline intensity for controller
				float flIntensity = track->GetIntensity( scenetime, side );
				if ( controller >= 0 )
				{
					float orig = GetFlexWeight( controller );
					SetFlexWeight( controller, orig * (1 - weight) + flIntensity * weight );
				}
			}
		}
		else
		{
			int controller = track->GetFlexControllerIndex( 0 );

			// Get spline intensity for controller
			float flIntensity = track->GetIntensity( scenetime, 0 );
			if ( controller >= 0 )
			{
				float orig = GetFlexWeight( controller );
				SetFlexWeight( controller, orig * (1 - weight) + flIntensity * weight );
			}
		}
	}

	info->m_bStarted = true;
}