本文整理汇总了C++中LPD3DXANIMATIONCONTROLLER::GetAnimationSet方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXANIMATIONCONTROLLER::GetAnimationSet方法的具体用法?C++ LPD3DXANIMATIONCONTROLLER::GetAnimationSet怎么用?C++ LPD3DXANIMATIONCONTROLLER::GetAnimationSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXANIMATIONCONTROLLER
的用法示例。
在下文中一共展示了LPD3DXANIMATIONCONTROLLER::GetAnimationSet方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetMoveKey
//-----------------------------------------------------------------------------
// Name: CTiny::SetMoveKey()
// 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).
//-----------------------------------------------------------------------------
void CTiny::SetMoveKey()
{
DWORD dwNewTrack = ( m_dwCurrentTrack == 0 ? 1 : 0 );
LPD3DXANIMATIONCONTROLLER pAC;
LPD3DXANIMATIONSET pAS;
m_pAI->GetAnimController( &pAC );
if( m_fSpeed == m_fSpeedWalk )
pAC->GetAnimationSet( m_dwAnimIdxWalk, &pAS );
else
pAC->GetAnimationSet( m_dwAnimIdxJog, &pAS );
pAC->SetTrackAnimationSet( dwNewTrack, pAS );
pAS->Release();
pAC->UnkeyAllTrackEvents( m_dwCurrentTrack );
pAC->UnkeyAllTrackEvents( dwNewTrack );
pAC->KeyTrackEnable( m_dwCurrentTrack, FALSE, m_dTimeCurrent + MOVE_TRANSITION_TIME );
pAC->KeyTrackSpeed( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
pAC->KeyTrackWeight( m_dwCurrentTrack, 0.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
pAC->SetTrackEnable( dwNewTrack, TRUE );
pAC->KeyTrackSpeed( dwNewTrack, 1.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
pAC->KeyTrackWeight( dwNewTrack, 1.0f, m_dTimeCurrent, MOVE_TRANSITION_TIME, D3DXTRANSITION_LINEAR );
m_dwCurrentTrack = dwNewTrack;
pAC->Release();
}
示例2: SmoothLoiter
//-----------------------------------------------------------------------------
// Name: CBipedAnimInstance::SmoothLoiter()
// Desc: If Biped is loitering, check if we have reached the end of animation.
// If so, set up a new track to play Loiter animation from the start and
// smoothly transition to the track, so that Biped can loiter more.
//-----------------------------------------------------------------------------
void CXFileAnimInstance::SmoothLoiter()
{
LPD3DXANIMATIONCONTROLLER pAC;
LPD3DXANIMATIONSET pASTrack, pASLoiter;
m_pAI->GetAnimController( & pAC );
// check if we're loitering
pAC->GetTrackAnimationSet( m_dwCurrentTrack, & pASTrack );
pAC->GetAnimationSet( m_dwAnimIdxLoiter, & pASLoiter );
if( pASTrack && pASTrack == pASLoiter )
{
D3DXTRACK_DESC td;
pAC->GetTrackDesc( m_dwCurrentTrack, & td );
if( td.Position > pASTrack->GetPeriod() - IDLE_TRANSITION_TIME ) // come within the change delta of the end
{
// play loiter animation again (from the beginning)
strcpy(m_szASNameTarget, "Loiter");
PlayAnimation(false);
}
}
SAFE_RELEASE( pASTrack );
SAFE_RELEASE( pASLoiter );
SAFE_RELEASE( pAC );
}
示例3: GetAnimIndex
//-----------------------------------------------------------------------------
// 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;
}
示例4: RestoreDeviceObjects
//-----------------------------------------------------------------------------
// Name: CBipedAnimInstance::RestoreDeviceObjects()
// Desc: Reinitialize necessary objects
//-----------------------------------------------------------------------------
HRESULT CXFileAnimInstance::RestoreDeviceObjects()
{
// Compress the animation sets in the new animation controller
SetupCallbacksAndCompression();
LPD3DXANIMATIONCONTROLLER pAC;
m_pAI->GetAnimController( & pAC );
pAC->ResetTime();
pAC->AdvanceTime( m_dTimeCurrent, NULL );
// Initialize current track
if( m_szASName[0] != '\0' )
{
DWORD dwActiveSet = GetAnimIndex( m_szASName );
LPD3DXANIMATIONSET pAS = NULL;
pAC->GetAnimationSet( dwActiveSet, &pAS );
pAC->SetTrackAnimationSet( m_dwCurrentTrack, pAS );
SAFE_RELEASE( pAS );
}
pAC->SetTrackEnable( m_dwCurrentTrack, TRUE );
pAC->SetTrackWeight( m_dwCurrentTrack, 1.0f );
pAC->SetTrackSpeed( m_dwCurrentTrack, 1.0f );
SAFE_RELEASE( pAC );
// Call animate to initialize the tracks.
Animate( 0.0 );
return S_OK;
}
示例5: 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();
}
示例6: SetupCallbacksAndCompression
//-----------------------------------------------------------------------------
// Name: CTiny::SetupCallbacksAndCompression()
// Desc: Add callback keys to the walking and jogging animation sets in the
// animation controller for playing footstepping sound. Then compress
// all animation sets in the animation controller.
//-----------------------------------------------------------------------------
HRESULT CTiny::SetupCallbacksAndCompression()
{
LPD3DXANIMATIONCONTROLLER pAC;
LPD3DXKEYFRAMEDANIMATIONSET pASLoiter, pASWalk, pASJog;
m_pAI->GetAnimController( &pAC );
pAC->GetAnimationSet( m_dwAnimIdxLoiter, ( LPD3DXANIMATIONSET* )&pASLoiter );
pAC->GetAnimationSet( m_dwAnimIdxWalk, ( LPD3DXANIMATIONSET* )&pASWalk );
pAC->GetAnimationSet( m_dwAnimIdxJog, ( LPD3DXANIMATIONSET* )&pASJog );
D3DXKEY_CALLBACK aKeysWalk[ 2 ];
aKeysWalk[ 0 ].Time = 0;
aKeysWalk[ 0 ].pCallbackData = &m_CallbackData[ 0 ];
aKeysWalk[ 1 ].Time = float( pASWalk->GetPeriod() / 2.0 * pASWalk->GetSourceTicksPerSecond() );
aKeysWalk[ 1 ].pCallbackData = &m_CallbackData[ 1 ];
D3DXKEY_CALLBACK aKeysJog[ 8 ];
for( int i = 0; i < 8; ++ i )
{
aKeysJog[ i ].Time = float( pASJog->GetPeriod() / 8 * ( double )i * pASWalk->GetSourceTicksPerSecond() );
aKeysJog[ i ].pCallbackData = &m_CallbackData[ ( i + 1 ) % 2 ];
}
AddCallbackKeysAndCompress( pAC, pASLoiter, 0, NULL, D3DXCOMPRESS_DEFAULT, .8f );
AddCallbackKeysAndCompress( pAC, pASWalk, 2, aKeysWalk, D3DXCOMPRESS_DEFAULT, .4f );
AddCallbackKeysAndCompress( pAC, pASJog, 8, aKeysJog, D3DXCOMPRESS_DEFAULT, .25f );
m_dwAnimIdxLoiter = GetAnimIndex( "Loiter" );
m_dwAnimIdxWalk = GetAnimIndex( "Walk" );
m_dwAnimIdxJog = GetAnimIndex( "Jog" );
if( m_dwAnimIdxLoiter == ANIMINDEX_FAIL ||
m_dwAnimIdxWalk == ANIMINDEX_FAIL ||
m_dwAnimIdxJog == ANIMINDEX_FAIL )
return E_FAIL;
pAC->Release();
return S_OK;
}
示例7: SmoothLoiter
//-----------------------------------------------------------------------------
// Name: CTiny::SmoothLoiter()
// Desc: If Tiny is loitering, check if we have reached the end of animation.
// If so, set up a new track to play Loiter animation from the start and
// smoothly transition to the track, so that Tiny can loiter more.
//-----------------------------------------------------------------------------
void CTiny::SmoothLoiter()
{
LPD3DXANIMATIONCONTROLLER pAC;
LPD3DXANIMATIONSET pASTrack, pASLoiter;
m_pAI->GetAnimController( &pAC );
// check if we're loitering
pAC->GetTrackAnimationSet( m_dwCurrentTrack, &pASTrack );
pAC->GetAnimationSet( m_dwAnimIdxLoiter, &pASLoiter );
if( pASTrack && pASTrack == pASLoiter )
{
D3DXTRACK_DESC td;
pAC->GetTrackDesc( m_dwCurrentTrack, &td );
if( td.Position > pASTrack->GetPeriod() - IDLE_TRANSITION_TIME ) // come within the change delta of the end
SetIdleKey( true );
}
SAFE_RELEASE( pASTrack );
SAFE_RELEASE( pASLoiter );
SAFE_RELEASE( pAC );
}
示例8: 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();
}
示例9: SetupCallbacksAndCompression
//-----------------------------------------------------------------------------
// Name: CBipedAnimInstance::SetupCallbacksAndCompression()
// Desc: 2004-5-5 LiXizhi
// Only compress, I have removed any callbacks. The old code is commented, which
// Adds callback keys to the walking and jogging animation sets in the
// animation controller for playing footstepping sound; Then compress
// all animation sets in the animation controller.
// you can change the input values of AddCallbackKeysAndCompress(..., .8f) to your desired ones.
// such as Compression Lossiness, which is Desired compression loss ratio, in the range from 0 to 1.
// currenly this value is set to 0.8f.
//-----------------------------------------------------------------------------
HRESULT CXFileAnimInstance::SetupCallbacksAndCompression()
{
LPD3DXANIMATIONCONTROLLER pAC;
LPD3DXKEYFRAMEDANIMATIONSET pASLoiter, pASWalk, pASJog;
m_pAI->GetAnimController( & pAC );
// -- compress Loiter animation
pAC->GetAnimationSet( m_dwAnimIdxLoiter, (LPD3DXANIMATIONSET *) & pASLoiter );
AddCallbackKeysAndCompress( pAC, pASLoiter, 0, NULL, D3DXCOMPRESS_DEFAULT, .8f );
// -- compress <removed:and set callback> for Walk animation
if(m_dwAnimIdxLoiter != m_dwAnimIdxWalk)
{
pAC->GetAnimationSet( m_dwAnimIdxWalk, (LPD3DXANIMATIONSET *) & pASWalk );
AddCallbackKeysAndCompress( pAC, pASWalk, 0, NULL, D3DXCOMPRESS_DEFAULT, .4f );
/*D3DXKEY_CALLBACK aKeysWalk[ 2 ];
aKeysWalk[ 0 ].Time = 0;
aKeysWalk[ 0 ].pCallbackData = & m_CallbackData[ 0 ];
aKeysWalk[ 1 ].Time = float( pASWalk->GetPeriod() / 2.0 * pASWalk->GetSourceTicksPerSecond() );
aKeysWalk[ 1 ].pCallbackData = & m_CallbackData[ 1 ];
AddCallbackKeysAndCompress( pAC, pASWalk, 2, aKeysWalk, D3DXCOMPRESS_DEFAULT, .4f );*/
// -- compress <removed: and set callback> for Jog animation
if(m_dwAnimIdxWalk != m_dwAnimIdxJog)
{
pAC->GetAnimationSet( m_dwAnimIdxJog, (LPD3DXANIMATIONSET *) & pASJog );
AddCallbackKeysAndCompress( pAC, pASJog, 0, NULL, D3DXCOMPRESS_DEFAULT, .25f );
/*D3DXKEY_CALLBACK aKeysJog[ 8 ];
for( int i = 0; i < 8; ++ i )
{
aKeysJog[ i ].Time = float( pASJog->GetPeriod() / 8 * (double) i * pASWalk->GetSourceTicksPerSecond() );
aKeysJog[ i ].pCallbackData = & m_CallbackData[ ( i + 1 ) % 2 ];
}
AddCallbackKeysAndCompress( pAC, pASJog, 8, aKeysJog, D3DXCOMPRESS_DEFAULT, .25f );*/
}
}
// -- compress and set callback for Action# animation
if(m_dwAnimIdxLoiter != m_dwAnimIdxAction[0])
{
LPD3DXKEYFRAMEDANIMATIONSET pASAction;
pAC->GetAnimationSet( m_dwAnimIdxAction[0], (LPD3DXANIMATIONSET *) & (pASAction) );
AddCallbackKeysAndCompress( pAC, pASAction, 0, NULL, D3DXCOMPRESS_DEFAULT, .8f );
// -- compress and set callback for Action1 animation
if(m_dwAnimIdxAction[0] != m_dwAnimIdxAction[1])
{
pAC->GetAnimationSet( m_dwAnimIdxAction[1], (LPD3DXANIMATIONSET *) & (pASAction) );
AddCallbackKeysAndCompress( pAC, pASAction, 0, NULL, D3DXCOMPRESS_DEFAULT, .8f );
// -- compress and set callback for Action2-5 animation
for(int i=2;i<=5;i++)
{
if(m_dwAnimIdxAction[1] != m_dwAnimIdxAction[i])
{
pAC->GetAnimationSet( m_dwAnimIdxAction[i], (LPD3DXANIMATIONSET *) & (pASAction) );
AddCallbackKeysAndCompress( pAC, pASAction, 0, NULL, D3DXCOMPRESS_DEFAULT, .8f );
}
}
}
// -- compress and set callback for Action6 animation
if(m_dwAnimIdxAction[0] != m_dwAnimIdxAction[6])
{
pAC->GetAnimationSet( m_dwAnimIdxAction[6], (LPD3DXANIMATIONSET *) & (pASAction) );
AddCallbackKeysAndCompress( pAC, pASAction, 0, NULL, D3DXCOMPRESS_DEFAULT, .8f );
// -- compress and set callback for Action7-10 animation
for(int i=7;i<=10;i++)
{
if(m_dwAnimIdxAction[6] != m_dwAnimIdxAction[i])
{
pAC->GetAnimationSet( m_dwAnimIdxAction[i], (LPD3DXANIMATIONSET *) & (pASAction) );
AddCallbackKeysAndCompress( pAC, pASAction, 0, NULL, D3DXCOMPRESS_DEFAULT, .8f );
}
}
}
}
GetAnimationIndex();
pAC->Release();
return S_OK;
}