Example #1
0
void SetViseme::PhonemeToViseme( vector<string> phoneme, vector<int> duration, int speakOffset )
{
	TRACE("SetViseme::PhonemeToViseme( vector<string> &phoneme, vector<int> &duration )");
	
	m_viRstNo.clear();
	m_viRstDur.clear();
	
	int k = 0; //key-frame number
	
	// First step: 1ms の無音区間を生成
	m_viRstNo.push_back(0);
	//m_viRstDur.push_back(int(1000.0 / 30) * 3 + 1);
	m_viRstDur.push_back(1 + speakOffset);
	
#ifdef DEBUG_PHONEME_TO_VISEME
	fprintf(stderr, "Line No.00: --- First Silence ---  ...Viseme No.00\t%d [ms]\n", m_viRstDur[0]);
#endif
	
	k++;
	// VISEME No.とDulationの決定 全検索:要改善
	unsigned int i, j;
	
	for( i = 0; i < phoneme.size(); i++ ) {   
		for( j = 0; j < m_vsSrcName.size(); j++ ) {
			if( phoneme[i] == m_vsSrcName[j] ) {   	// 探索成功
				m_viRstNo.push_back( m_viSrcNo[j] );
				m_viRstDur.push_back( duration[i] );
#ifdef DEBUG_PHONEME_TO_VISEME
				fprintf( stderr, "Line No.%02d: [%s] ... Viseme No.%d:\t%d[ms]\n", 
					i+1, phoneme[i].c_str(), m_viRstNo[k], m_viRstDur[k] );
#endif
				k++;
				break;
			} 
		}
		if( j == m_vsSrcName.size() ) {           // 探索失敗    
			m_viRstNo.push_back(0);
			m_viRstDur.push_back( duration[i] );
#ifdef DEBUG_PHONEME_TO_VISEME
			fprintf(stderr, "Line No.%02d : [%s] ... ?No Match? ... Viseme No.00\t%d[ms]\n",
				i+1, m_viRstNo[k], m_viRstDur[k]);
#endif
			k++;
		}
		
	}
	
	// for Final Step: 1ms の無音区間を生成
	m_viRstNo.push_back(0);
	m_viRstDur.push_back(1);
#ifdef DEBUG_PHONEME_TO_VISEME
	fprintf(stderr, "Line No.%02d: --- Final Silence ---  ...Viseme No.00\t%d [ms]\n",
		m_viRstDur.size() - 1, m_viRstDur[m_viRstDur.size() - 1]);
#endif
	
	AddKeyFrame();
	MakeTable();
}
Example #2
0
void AnimationTrack::SetKeyFrame(unsigned index, const AnimationKeyFrame& keyFrame)
{
    if (index < keyFrames_.Size())
    {
        keyFrames_[index] = keyFrame;
        Urho3D::Sort(keyFrames_.Begin(), keyFrames_.End(), CompareKeyFrames);
    }
    else if (index == keyFrames_.Size())
        AddKeyFrame(keyFrame);
}
void KeyFrameAnimation::MakeOrbit(float segments, float timestep, float radius) {
    float start =     -glm::pi<float>() / 2.0f;
    float end   =  2 * glm::pi<float>() - glm::pi<float>() / 2.f;
    float step  = (2 * glm::pi<float>() / segments);
    
    int j = 0;
    for (float f = start; f < end; f += step) {
        float x = radius * glm::cos(f);
        float z = radius * glm::sin(f);
        
        AddKeyFrame(KeyFrame(glm::vec3(x, 25.0f + 2.0f * glm::sin(f), z), j * timestep));        

        j++;
    }

    KeyFrame final = keyFrames[0];
    final.time = keyFrames[KeyFrameCount() - 1].time + timestep;
Example #4
0
void CViewAngleAnimation::LoadViewAnimFile( const char *pKeyFrameFileName )
{
	DeleteKeyFrames();

	// load keyvalues from this file and stuff them in as keyframes
	KeyValues *pData = new KeyValues( pKeyFrameFileName );

	if ( false == pData->LoadFromFile( filesystem, pKeyFrameFileName, "GAME" ) )
	{
		Warning( "CViewAngleAnimation::LoadViewAnimFile failed to load script %s\n", pKeyFrameFileName );
		pData->deleteThis();
		return;
	}

	QAngle angles;
	float flTime;
	int iFlags;

	KeyValues *pKey = pData->GetFirstSubKey();

	while ( pKey )
	{
		// angles
		const char *pszAngles = pKey->GetString( "angles", "0 0 0" );
		sscanf( pszAngles, "%f %f %f", &angles[0], &angles[1], &angles[2] );

		// time
		flTime = pKey->GetFloat( "time", 0.001 );

		// flags
		iFlags = pKey->GetInt( "flags", 0 );

		AddKeyFrame( new CViewAngleKeyFrame( angles, flTime, iFlags ) );

		pKey = pKey->GetNextKey();
	}

	pData->deleteThis();
}