![]() 图7声源运动的轨迹 |
| void CDsound3DPlayDemoDlg::OnTimer(UINT nIDEvent ) { FLOAT fXScale; FLOAT fYScale; fXScale = (((CSliderCtrl*)GetDlgItem(IDC_HORIZONTAL_SLIDER ))->GetPos())/100.0f; fYScale = (((CSliderCtrl*)GetDlgItem(IDC_VERTICAL_SLIDER ))->GetPos())/100.0f; FLOAT t = timeGetTime()/1000.0f; // Move the sound object around the listener. The maximum radius of the // orbit is 27.5 units. D3DVECTOR vPosition; vPosition.x = ORBIT_MAX_RADIUS * fXScale * (FLOAT)sin(t); vPosition.y = 0.0f; vPosition.z = ORBIT_MAX_RADIUS * fYScale * (FLOAT)cos(t); D3DVECTOR vVelocity; vVelocity.x = ORBIT_MAX_RADIUS * fXScale * (FLOAT)sin(t+0.05f); vVelocity.y = 0.0f; vVelocity.z = ORBIT_MAX_RADIUS * fYScale * (FLOAT)cos(t+0.05f); memcpy( &g_dsBufferParams.vPosition, &vPosition, sizeof(D3DVECTOR) ); memcpy( &g_dsBufferParams.vVelocity, &vVelocity, sizeof(D3DVECTOR) ); UpdateGrid( vPosition.x, vPosition.z ); if( g_pDS3DBuffer ) g_pDS3DBuffer->SetAllParameters( &g_dsBufferParams, DS3D_IMMEDIATE ); //随着模拟buffer的运动,我们要不断地改变3Dbuffer的参数。 } |
关注此文的读者还看过: