예제 #1
0
//-----------------------------------------------------------------------------
// Name: CTiny::RestoreDeviceObjects()
// Desc: Free D3D objects so that the device can be reset.
//-----------------------------------------------------------------------------
HRESULT CTiny::InvalidateDeviceObjects()
{
    // Save the current track's animation set name
    // so we can reset it again in RestoreDeviceObjects later.
    LPD3DXANIMATIONCONTROLLER pAC = NULL;
    m_pAI->GetAnimController( &pAC );
    if( pAC )
    {
        LPD3DXANIMATIONSET pAS = NULL;
        pAC->GetTrackAnimationSet( m_dwCurrentTrack, &pAS );
        if( pAS )
        {
            if( pAS->GetName() )
                strcpy_s( m_szASName, 64, pAS->GetName() );
            SAFE_RELEASE( pAS );
        }
        SAFE_RELEASE( pAC );
    }

    CMultiAnimAllocateHierarchy AH;
    AH.SetMA( m_pMA );
    m_pMA->Cleanup( &AH );

    return S_OK;
}
예제 #2
0
//-----------------------------------------------------------------------------
// Name: CBipedAnimInstance::GetAnimIndex()
// Desc: Returns the index of an animation set within this animation instance's
//       animation controller given an animation set name.
//-----------------------------------------------------------------------------
DWORD CXFileAnimInstance::GetAnimIndex( char sString[] )
{
    HRESULT hr;
    LPD3DXANIMATIONCONTROLLER pAC;
    LPD3DXANIMATIONSET pAS;
    DWORD dwRet = ANIMINDEX_FAIL;

    m_pAI->GetAnimController( & pAC );

    for( DWORD i = 0; i < pAC->GetNumAnimationSets(); ++ i )
    {
        hr = pAC->GetAnimationSet( i, & pAS );
        if( FAILED( hr ) )
            continue;

        if( pAS->GetName() &&
            !strncmp( pAS->GetName(), sString, min( strlen( pAS->GetName() ), strlen( sString ) ) ) )
        {
            dwRet = i;
            pAS->Release();
            break;
        }

        pAS->Release();
    }

    pAC->Release();

    return dwRet;
}
예제 #3
0
bool MoonSkinmesh::SetAnimByName(const char *strAnimName)
{
	if(_pAnimController == NULL)
		return false;
	UINT nAnimSet;
	string strAnim = strAnimName;
	if(strAnim == _strAnimName)
		return true;
	_strAnimName = strAnim;
	string strTemp;
	nAnimSet = _pAnimController->GetMaxNumAnimationSets();
	LPD3DXANIMATIONSET pAnimSet;

	for(UINT i = 0; i < nAnimSet; i++)
	{
		_pAnimController->GetAnimationSet(i,&pAnimSet);
		strTemp = pAnimSet->GetName();
		if(strTemp == strAnim)
		{
			/*_currentTrack++;*/
			_pAnimController->SetTrackAnimationSet(0,pAnimSet);
			_pAnimController->ResetTime();
			/*_pAnimController->SetTrackEnable((_currentTrack+1)%2, FALSE);
			_pAnimController->SetTrackEnable(_currentTrack%2, TRUE);*/
			return true;
		}
	}
	return false;
}
예제 #4
0
//-----------------------------------------------------------------------------
// Name: CBipedAnimInstance::InvalidateDeviceObjects()
// Desc: Free D3D objects so that the device can be reset.
//-----------------------------------------------------------------------------
HRESULT CXFileAnimInstance::InvalidateDeviceObjects()
{
    // Save the current track's animation set name
    // so we can reset it again in RestoreDeviceObjects later.
    LPD3DXANIMATIONCONTROLLER pAC = NULL;
    m_pAI->GetAnimController( & pAC );
    if( pAC )
    {
        LPD3DXANIMATIONSET pAS = NULL;
        pAC->GetTrackAnimationSet( m_dwCurrentTrack, &pAS );
        if( pAS )
        {
            if( pAS->GetName() )
                strcpy( m_szASName, pAS->GetName() );
            SAFE_RELEASE( pAS );
        }
        SAFE_RELEASE( pAC );
    }

    return S_OK;
}
예제 #5
0
DWORD CAnimationInstance::GetAnimationIndex(const char * szAnimationName)
{
	HRESULT hr;
	
	LPD3DXANIMATIONSET pAnimSet;
	DWORD dwReturnIndex = ANIM_INDEX_FAIL;

	for( DWORD i = 0; i < m_pAnimationController->GetNumAnimationSets(); ++i)
	{
		hr = m_pAnimationController->GetAnimationSet( i, &pAnimSet);
		if( FAILED( hr))
			continue;

		if( pAnimSet->GetName() && !strncmp( pAnimSet->GetName(), szAnimationName, min( strlen( pAnimSet->GetName() ), strlen( szAnimationName))))
		{
			dwReturnIndex = i;
			pAnimSet->Release();
			break;
		}

		pAnimSet->Release();
	}
	return dwReturnIndex;
}
예제 #6
0
/**
 * \brief Get the name of the animation
 * Note: altered 24/09/07 to solve a D3DX memory leak caused because I was not releasing the set after getting it
 * \param index - the animation set index
 * \return the name
 * \author Keith Ditchburn \date 18 July 2005
*/
std::string CXFileEntity::GetAnimationSetName(unsigned int index)
{
	if (index>=m_numAnimationSets)
		return "Error: No set exists";

	// Get the animation set
	LPD3DXANIMATIONSET set;
	m_animController->GetAnimationSet(m_currentAnimationSet, &set );

	std::string nameString(set->GetName());

	set->Release();

	return nameString;
}
예제 #7
0
	/**
	 * @brief
	 * 引数に渡された名前と一致する
	 * アニメーションセットのインデックスを返す
	 * 
	 */
	UINT AnimationManager::getAnimationSetIndex(const std::string& animationSetName)
	{
		LPD3DXANIMATIONSET pAnimationSet = 0;

		for (UINT i = 0; i < m_pAnimationController->GetNumAnimationSets(); ++i) {
			V_THROW(m_pAnimationController->GetAnimationSet(i, &pAnimationSet));

			if (animationSetName == std::string(pAnimationSet->GetName())) {
				pAnimationSet->Release();
				return i;
			}

			pAnimationSet->Release();
		}

		return 0xffffff;
	}
예제 #8
0
파일: Tiny.cpp 프로젝트: KNeal/Oculus
//-----------------------------------------------------------------------------
// Name: CTiny::Report()
// Desc: Add to the vector of strings, v_sReport, with useful information
//       about this instance of CTiny.
//-----------------------------------------------------------------------------
void CTiny::Report( vector <String>& v_sReport )
{
    WCHAR s[ 256 ];

    try
    {
        swprintf_s( s, 256, L"Pos: %f, %f", m_vPos.x, m_vPos.z );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"Facing: %f", m_fFacing );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"Local time: %f", m_dTimeCurrent );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"Pos Target: %f, %f", m_vPosTarget.x, m_vPosTarget.z );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"Facing Target: %f", m_fFacingTarget );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"Status: %s", m_bIdle ? L"Idle" : ( m_bWaiting ? L"Waiting" : L"Moving" ) );
        v_sReport.push_back( String( s ) );

        // report track data
        LPD3DXANIMATIONCONTROLLER pAC;
        LPD3DXANIMATIONSET pAS;
        D3DXTRACK_DESC td;
        m_pAI->GetAnimController( &pAC );

        pAC->GetTrackAnimationSet( 0, &pAS );
        WCHAR wstr[256];
        MultiByteToWideChar( CP_ACP, 0, pAS->GetName(), -1, wstr, 256 );
        swprintf_s( s, 256, L"Track 0: %s%s", wstr, m_dwCurrentTrack == 0 ? L" (current)" : L"" );
        v_sReport.push_back( String( s ) );
        pAS->Release();

        pAC->GetTrackDesc( 0, &td );
        swprintf_s( s, 256, L"  Weight: %f", td.Weight );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"  Speed: %f", td.Speed );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"  Position: %f", td.Position );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"  Enable: %s", td.Enable ? L"true" : L"false" );
        v_sReport.push_back( String( s ) );

        pAC->GetTrackAnimationSet( 1, &pAS );
        if( pAS )
        {
            MultiByteToWideChar( CP_ACP, 0, pAS->GetName(), -1, wstr, 256 );
            pAS->Release();
        }
        else
        {
            swprintf_s( wstr, 256, L"n/a" );
        }
        swprintf_s( s, 256, L"Track 1: %s%s", wstr, m_dwCurrentTrack == 1 ? L" (current)" : L"" );
        v_sReport.push_back( String( s ) );

        pAC->GetTrackDesc( 1, &td );
        swprintf_s( s, 256, L"  Weight: %f", td.Weight );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"  Speed: %f", td.Speed );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"  Position: %f", td.Position );
        v_sReport.push_back( String( s ) );
        swprintf_s( s, 256, L"  Enable: %s", td.Enable ? L"true" : L"false" );
        v_sReport.push_back( String( s ) );

        if( m_bUserControl )
        {
            swprintf_s( s, 256, L"Control: USER" );
            v_sReport.push_back( String( s ) );
        }
        else
        {
            swprintf_s( s, 256, L"Control: AUTO" );
            v_sReport.push_back( String( s ) );
        }

        pAC->Release();
    }
    catch( ... )
    {
    }
}