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


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

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


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

示例1: 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;
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:34,代码来源:XFileAnimInstance.cpp

示例2: Setup

//-----------------------------------------------------------------------------
// Name: CTiny::Setup
// Desc: Initializes the class and readies it for animation
//-----------------------------------------------------------------------------
HRESULT CTiny::Setup(double dTimeCurrent, D3DXVECTOR3 pInitialPosition, CSoundManager *p_sound )
{
    HRESULT hr;
    WCHAR str[MAX_PATH];

    // set the current and prev time
    m_dTimeCurrent = m_dTimePrev = dTimeCurrent;

    hr = m_pMA->CreateNewInstance( &m_dwMultiAnimIdx );
    if( FAILED( hr ) )
        return E_OUTOFMEMORY;

    m_pAI = m_pMA->GetInstance( m_dwMultiAnimIdx );

    // set initial position
    m_vPos = pInitialPosition;

    m_fFacing = 0.0f;

    // set up anim indices
    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;

    // compute reorientation matrix based on default orientation and bounding radius
    D3DXMATRIX mx;
    float fScale = 1.f / m_pMA->GetBoundingRadius() / 2.5f;
    D3DXMatrixScaling( &mx, fScale, fScale, fScale );
    m_mxOrientation = mx;
    D3DXMatrixRotationX( &mx, -D3DX_PI / 2.0f );
    D3DXMatrixMultiply( &m_mxOrientation, &m_mxOrientation, &mx );
    D3DXMatrixRotationY( &mx, D3DX_PI / 2.0f );
    D3DXMatrixMultiply( &m_mxOrientation, &m_mxOrientation, &mx );

    // set track to idle
    SetIdleKey(false);

    LPD3DXANIMATIONCONTROLLER pAC;
    m_pAI->GetAnimController( &pAC );
    pAC->AdvanceTime( m_dTimeCurrent, NULL );
    pAC->Release();

    // Use D3DX to create a texture from a file based image
    DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"metalplate.wav" );
    // load the sound
    hr = p_sound->Create(&m_pSound,str,DSBCAPS_CTRLVOLUME);

    return S_OK;
}
开发者ID:benjcleveland,项目名称:UW-Game,代码行数:57,代码来源:Tiny.cpp

示例3: InitDeviceObjects

//-----------------------------------------------------------------------------
// Name: CBipedAnimInstance::InitDeviceObjects
// Desc: Initializes the class and readies it for animation
//-----------------------------------------------------------------------------
HRESULT CXFileAnimInstance::InitDeviceObjects()
{
    HRESULT hr;
    hr = m_pMA->CreateNewInstance( & m_dwMultiAnimIdx );
    if( FAILED( hr ) )
        return E_OUTOFMEMORY;

    m_pAI = m_pMA->GetInstance( m_dwMultiAnimIdx );

    // set up anim indices
	GetAnimationIndex();

	// set up footstep callbacks
    SetupCallbacksAndCompression();
    // compute reorientation matrix based on default orientation and bounding radius
    Matrix4 mx;
	// Set the raduis of the object as it appears in the scene to 1/7.0f units
	float fScale = 1.f / m_pMA->GetBoundingRadius() / 7.f;
	ParaMatrixScaling( & mx, fScale, fScale, fScale );
    m_mxOrientation = mx;

    // the following code is required by DirectX model trandsformation.
	ParaMatrixRotationX( & mx, -MATH_PI / 2.0f );
    ParaMatrixMultiply( & m_mxOrientation, & m_mxOrientation, & mx );
    ParaMatrixRotationY( & mx, MATH_PI / 2.0f );
    ParaMatrixMultiply( & m_mxOrientation, & m_mxOrientation, & mx );
	
    // default: play idle animation
	strcpy(m_szASNameTarget,"Loiter");

    //ComputeFacingTarget();
	PlayAnimation(false);	//force loading the first animation

    LPD3DXANIMATIONCONTROLLER pAC;
    m_pAI->GetAnimController( & pAC );
    pAC->AdvanceTime( m_dTimeCurrent, NULL );
    pAC->Release();

    return S_OK;
}
开发者ID:LiXizhi,项目名称:NPLRuntime,代码行数:44,代码来源:XFileAnimInstance.cpp

示例4: Setup


//.........这里部分代码省略.........
    HRESULT hr;
    hr = m_pMA->CreateNewInstance( &m_dwMultiAnimIdx );
    if( FAILED( hr ) )
        return E_OUTOFMEMORY;

    m_pAI = m_pMA->GetInstance( m_dwMultiAnimIdx );

    // set initial position
    bool bBlocked = true;
    DWORD dwAttempts;
    for( dwAttempts = 0; dwAttempts < 1000 && bBlocked; ++ dwAttempts )
    {
        ChooseNewLocation( &m_vPos );
        bBlocked = IsBlockedByCharacter( &m_vPos );
    }

    m_fFacing = 0.0f;

    // set up anim indices
    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;

    // set up callback key data
    m_CallbackData[ 0 ].m_dwFoot = 0;
    m_CallbackData[ 0 ].m_pvTinyPos = &m_vPos;
    m_CallbackData[ 1 ].m_dwFoot = 1;
    m_CallbackData[ 1 ].m_pvTinyPos = &m_vPos;

    // set up footstep callbacks
    SetupCallbacksAndCompression();
    m_pCallbackHandler = new CBHandlerTiny;
    if( m_pCallbackHandler == NULL )
        return E_OUTOFMEMORY;

    // set up footstep sounds
    WCHAR sPath[ MAX_PATH ];
    if( g_apSoundsTiny[ 0 ] == NULL )
    {
        hr = DXUTFindDXSDKMediaFileCch( sPath, MAX_PATH, FOOTFALLSOUND00 );
        if( FAILED( hr ) )
            wcscpy_s( sPath, MAX_PATH, FOOTFALLSOUND00 );

        hr = m_pSM->Create( &g_apSoundsTiny[ 0 ], sPath, DSBCAPS_CTRLVOLUME );
        if( FAILED( hr ) )
        {
            OutputDebugString( FOOTFALLSOUND00 L" not found; continuing without sound.\n" );
            m_bPlaySounds = false;
        }
    }

    if( g_apSoundsTiny[ 1 ] == NULL )
    {
        hr = DXUTFindDXSDKMediaFileCch( sPath, MAX_PATH, FOOTFALLSOUND01 );
        if( FAILED( hr ) )
            wcscpy_s( sPath, MAX_PATH, FOOTFALLSOUND01 );

        hr = m_pSM->Create( &g_apSoundsTiny[ 1 ], sPath, DSBCAPS_CTRLVOLUME );
        if( FAILED( hr ) )
        {
            OutputDebugString( FOOTFALLSOUND01 L" not found; continuing without sound.\n" );
            m_bPlaySounds = false;
        }
    }

    // compute reorientation matrix based on default orientation and bounding radius
    D3DXMATRIX mx;
    float fScale = 1.f / m_pMA->GetBoundingRadius() / 7.f;
    D3DXMatrixScaling( &mx, fScale, fScale, fScale );
    m_mxOrientation = mx;
    D3DXMatrixRotationX( &mx, -D3DX_PI / 2.0f );
    D3DXMatrixMultiply( &m_mxOrientation, &m_mxOrientation, &mx );
    D3DXMatrixRotationY( &mx, D3DX_PI / 2.0f );
    D3DXMatrixMultiply( &m_mxOrientation, &m_mxOrientation, &mx );

    // set starting target
    SetSeekingState();
    ComputeFacingTarget();

    LPD3DXANIMATIONCONTROLLER pAC;
    m_pAI->GetAnimController( &pAC );
    pAC->AdvanceTime( m_dTimeCurrent, NULL );
    pAC->Release();

    // Add this instance to the list
    try
    {
        pv_pChars->push_back( this );
    }
    catch( ... )
    {
        return E_OUTOFMEMORY;
    }

    return S_OK;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:101,代码来源:Tiny.cpp


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