bool CDialogActorContext::DoFacialExpression(IEntity *pEntity, const string& expression, float weight, float fadeTime) { ICharacterInstance * pCharacter = pEntity->GetCharacter(0); if (!pCharacter) return false; IFacialInstance * pFacialInstance = pCharacter->GetFacialInstance(); if (!pFacialInstance) return false; IFacialModel * pFacialModel = pFacialInstance->GetFacialModel(); if (!pFacialModel) return false; IFacialEffectorsLibrary * pLibrary = pFacialModel->GetLibrary(); if (!pLibrary) return false; IFacialEffector *pEffector = 0; if (!expression.empty()) { pEffector = pLibrary->Find( expression.c_str() ); if (!pEffector) { GameWarning("[DIALOG] CDialogActorContext::DoFacialExpression: %s Cannot find '%s' for Entity '%s'", m_pSession->GetDebugName(), expression.c_str(), pEntity->GetName()); return false; } } if (m_currentEffectorChannelID != INVALID_FACIAL_CHANNEL_ID) { // we fade out with the same fadeTime as fade in pFacialInstance->StopEffectorChannel(m_currentEffectorChannelID, fadeTime); m_currentEffectorChannelID = INVALID_FACIAL_CHANNEL_ID; } if (pEffector) { m_currentEffectorChannelID = pFacialInstance->StartEffectorChannel(pEffector, weight, fadeTime); // facial instance wants ms } return true; }
virtual void ProcessEvent( EFlowEvent event, SActivationInfo* pActInfo ) { switch ( event ) { case eFE_Initialize: { } break; case eFE_Activate: { ICharacterInstance* pCharacter = NULL; IFacialInstance* pFacialInstance = NULL; IFacialModel* pFacialModel = NULL; IFacialEffectorsLibrary* pLibrary = NULL; IFacialEffector* pEffector = NULL; if ( IsPortActive( pActInfo, EIP_StopLast ) && pActInfo->pEntity ) { if ( m_nChannelId > 0 ) { if ( pActInfo->pEntity ) { pCharacter = pActInfo->pEntity->GetCharacter( 0 ); if ( pCharacter ) { pFacialInstance = pCharacter->GetFacialInstance(); if ( pFacialInstance ) { pFacialInstance->StopEffectorChannel( m_nChannelId, GetPortFloat( pActInfo, EIP_FadeTime ) ); m_nChannelId = -1; } } } } } if ( IsPortActive( pActInfo, EIP_Start ) && pActInfo->pEntity ) { string sEffector = GetPortString( pActInfo, EIP_Name ); if ( !sEffector.empty() ) { if ( sEffector.at( 0 ) == '#' ) { sEffector = sEffector.substr( 1 ); } } if ( pActInfo->pEntity && !sEffector.empty() ) { pCharacter = pActInfo->pEntity->GetCharacter( 0 ); if ( pCharacter ) { pFacialInstance = pCharacter->GetFacialInstance(); if ( pFacialInstance ) { pFacialModel = pFacialInstance->GetFacialModel(); if ( pFacialModel ) { pLibrary = pFacialModel->GetLibrary(); if ( pLibrary ) { pEffector = pLibrary->Find( sEffector ); if ( pEffector ) { m_nChannelId = pFacialInstance->StartEffectorChannel( pEffector, GetPortFloat( pActInfo, EIP_Weight ), GetPortFloat( pActInfo, EIP_FadeTime ), GetPortFloat( pActInfo, EIP_Duration ), GetPortInt( pActInfo, EIP_Repeat ) ); ActivateOutput<float>( pActInfo, EOP_Started, m_nChannelId ); } } } } } } } } break; } }