当前位置: 首页>>代码示例>>C++>>正文


C++ LPD3DXANIMATIONCONTROLLER::SetTrackPosition方法代码示例

本文整理汇总了C++中LPD3DXANIMATIONCONTROLLER::SetTrackPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXANIMATIONCONTROLLER::SetTrackPosition方法的具体用法?C++ LPD3DXANIMATIONCONTROLLER::SetTrackPosition怎么用?C++ LPD3DXANIMATIONCONTROLLER::SetTrackPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPD3DXANIMATIONCONTROLLER的用法示例。


在下文中一共展示了LPD3DXANIMATIONCONTROLLER::SetTrackPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetIdleKey

//-----------------------------------------------------------------------------
// Name: CTiny::SetIdleKey()
// Desc: Initialize a new track in the animation controller for the idle
//       (loiter ) animation, and set up the smooth transition from the
//       movement animation (current track) to it (new track).
//
//       bResetPosition controls whether we start the Loiter animation from
//       its beginning or current position.
//-----------------------------------------------------------------------------
void CTiny::SetIdleKey( bool bResetPosition )
{
    DWORD dwNewTrack = ( m_dwCurrentTrack == 0 ? 1 : 0 );
    LPD3DXANIMATIONCONTROLLER pAC;
    LPD3DXANIMATIONSET pAS;
    m_pAI->GetAnimController( &pAC );

    pAC->GetAnimationSet( m_dwAnimIdxLoiter, &pAS );
    pAC->SetTrackAnimationSet( dwNewTrack, pAS );
    pAS->Release();

    pAC->UnkeyAllTrackEvents( m_dwCurrentTrack );
    pAC->UnkeyAllTrackEvents( dwNewTrack );

    pAC->KeyTrackEnable( m_dwCurrentTrack, FALSE, m_dTimeCurrent + IDLE_TRANSITION_TIME );
    pAC->KeyTrackSpeed( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
    pAC->KeyTrackWeight( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
    pAC->SetTrackEnable( dwNewTrack, TRUE );
    pAC->KeyTrackSpeed( dwNewTrack, 1.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
    pAC->KeyTrackWeight( dwNewTrack, 1.0f, m_dTimeCurrent, IDLE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
    if( bResetPosition )
        pAC->SetTrackPosition( dwNewTrack, 0.0 );

    m_dwCurrentTrack = dwNewTrack;

    pAC->Release();
}
开发者ID:KNeal,项目名称:Oculus,代码行数:36,代码来源:Tiny.cpp

示例2: PlayAnimation

//-----------------------------------------------------------------------------
// Name: CBipedAnimInstance::PlayAnimation()
// Desc: Initialize a new track in the animation controller for the movement
//       animation (run or walk), and set up the smooth transition from the idle
//       animation (current track) to it (new track).
// Params:  bContinue: If it's true,load new animation track only if sAnimName is 
//			different from the track that is being played
// note: m_szASNameTarget can be numbers, which is translated as index into the 
//		 model file's animation sets.
//-----------------------------------------------------------------------------
void CXFileAnimInstance::PlayAnimation(bool bContinue)
{
	// -- return if no new animation is specified
	if(bContinue && strcmp(m_szASNameTarget, m_szASName) == 0)
		return;
	strcpy(m_szASName, m_szASNameTarget);
	
	// -- create new track
	DWORD dwNewTrack = ( m_dwCurrentTrack == 0 ? 1 : 0 );
    LPD3DXANIMATIONCONTROLLER pAC;
    LPD3DXANIMATIONSET pAS;
    m_pAI->GetAnimController( & pAC );


	// TODO: use hash tablle to get the animation set
	// -- Get the animation set
	HRESULT hr;
    double dTransitionPeriod = MOVE_TRANSITION_TIME;
	if(strcmp(m_szASName, "Walk") == 0)
	{
		hr = pAC->GetAnimationSet( m_dwAnimIdxWalk, & pAS );
		dTransitionPeriod = MOVE_TRANSITION_TIME;
	}
	else if(strcmp(m_szASName, "Jog") == 0)
	{
        hr = pAC->GetAnimationSet( m_dwAnimIdxJog, & pAS );
		dTransitionPeriod = MOVE_TRANSITION_TIME;
	}
	else if( ('0'<= m_szASName[0]) && (m_szASName[0]<='9') ) 
	{// if it's a number from 0~99
		UINT nIndex = 0;
		if(('0'<= m_szASName[1]) && (m_szASName[1]<='9'))
			nIndex = (m_szASName[0] - '0')*10+m_szASName[1]-'0';
		else
			nIndex = (m_szASName[0] - '0');

        // use the name as the index of the animation set.
		hr = pAC->GetAnimationSet( nIndex, & pAS );
		dTransitionPeriod = MOVE_TRANSITION_TIME;
	}
	else //if(strcmp(m_szASName, "Loiter"))
	{
		hr = pAC->GetAnimationSet( m_dwAnimIdxLoiter, & pAS );
		dTransitionPeriod = IDLE_TRANSITION_TIME;
	}

	if( ! SUCCEEDED(hr) ) // failed to load
	{ 
		// TODO: Load default animation
		hr = pAC->GetAnimationSet( m_dwAnimIdxLoiter, & pAS );
		dTransitionPeriod = IDLE_TRANSITION_TIME;
		if( ! SUCCEEDED(hr) )// failed to load the default
			return;
	}

	// -- Enable new track and set transition weight
    pAC->SetTrackAnimationSet( dwNewTrack, pAS );
    pAS->Release();

    pAC->UnkeyAllTrackEvents( m_dwCurrentTrack );
    pAC->UnkeyAllTrackEvents( dwNewTrack );

    pAC->KeyTrackEnable( m_dwCurrentTrack, FALSE, m_dTimeCurrent + dTransitionPeriod );
    pAC->KeyTrackSpeed( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR );
    pAC->KeyTrackWeight( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR );
    pAC->SetTrackEnable( dwNewTrack, TRUE );
    pAC->KeyTrackSpeed( dwNewTrack, 1.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR );
    pAC->KeyTrackWeight( dwNewTrack, 1.0f, m_dTimeCurrent, dTransitionPeriod, D3DXTRANSITION_LINEAR );

	if(!bContinue) // restart
		pAC->SetTrackPosition( dwNewTrack, 0.0 );

    m_dwCurrentTrack = dwNewTrack;

    pAC->Release();
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:86,代码来源:XFileAnimInstance.cpp


注:本文中的LPD3DXANIMATIONCONTROLLER::SetTrackPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。