本文整理汇总了C++中LPDIRECTSOUND3DLISTENER::SetDistanceFactor方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTSOUND3DLISTENER::SetDistanceFactor方法的具体用法?C++ LPDIRECTSOUND3DLISTENER::SetDistanceFactor怎么用?C++ LPDIRECTSOUND3DLISTENER::SetDistanceFactor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTSOUND3DLISTENER
的用法示例。
在下文中一共展示了LPDIRECTSOUND3DLISTENER::SetDistanceFactor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UserSetParms
static void RLXAPI UserSetParms(V3XMATRIX *lpMAT, V3XVECTOR *lpVEL,
float*lpDistanceF, float*lpDopplerF, float*lpRolloffF)
{
HRESULT hr;
if (!g_lpDS3DListener)
return;
if (lpMAT)
{
V3XVECTOR *ps = &lpMAT->v.Pos;
hr = g_lpDS3DListener->SetPosition(ps->x, ps->y, ps->z, DS3D_DEFMODE);
g_lpDS3DListener->SetOrientation(
lpMAT->v.K.x, lpMAT->v.K.y, lpMAT->v.K.z, // 3D engine use a other orientation (right hand)
lpMAT->v.J.x, lpMAT->v.J.y, lpMAT->v.J.z,
DS3D_DEFMODE);
}
if (lpVEL)
g_lpDS3DListener->SetVelocity(lpVEL->x, lpVEL->y, lpVEL->z, DS3D_DEFMODE);
if (lpDistanceF)
g_lpDS3DListener->SetDistanceFactor(*lpDistanceF, DS3D_DEFMODE);
if (lpDopplerF)
g_lpDS3DListener->SetDopplerFactor( *lpDopplerF, DS3D_DEFMODE);
if (lpRolloffF)
g_lpDS3DListener->SetRolloffFactor( *lpRolloffF, DS3D_DEFMODE);
}
示例2: ds_SetAllListenerParameters
//-----------------------------------------------------------------------------
// Установка всех параметров слушателя
// на входе : listener - указатель на интерфейс слушателя
// data - указатель на структуру в которой содержатся
// параметры слушателя
// на выходе : успешность установки параметров слушателя
//-----------------------------------------------------------------------------
int ds_SetAllListenerParameters(LPDIRECTSOUND3DLISTENER listener,
LPDS3DLISTENER data, DWORD def)
{
int ret = false;
// проверка наличия слушателя
if (!listener)
return ret;
// установка позиции
ret = (listener->SetPosition(data->vPosition.x,
data->vPosition.y,
data->vPosition.z,
def) == DS_OK) ?
true :
false;
// установка скорости слушателя
if (ret)
ret = (listener->SetVelocity(data->vVelocity.x,
data->vVelocity.y,
data->vVelocity.z,
def) == DS_OK) ?
true :
false;
// установка ориентации
if (ret)
ret = (listener->SetOrientation(data->vOrientFront.x,
data->vOrientFront.y,
data->vOrientFront.z,
data->vOrientTop.x,
data->vOrientTop.y,
data->vOrientTop.z,
def) == DS_OK) ?
true :
false;
// установка дистанции
if (ret)
ret = (listener->SetDistanceFactor(data->flDistanceFactor, def) ==
DS_OK) ?
true :
false;
// установка фактора удаления
if (ret)
ret = (listener->SetRolloffFactor(data->flRolloffFactor, def) == DS_OK) ?
true :
false;
// установка эффекта допплера
if (ret)
ret = (listener->SetDopplerFactor(data->flDopplerFactor, def) == DS_OK) ?
true :
false;
return ret;
}
示例3: DS_Listener
//===========================================================================
// DS_Listener
// SFXLP_UNITS_PER_METER
// SFXLP_DOPPLER
// SFXLP_UPDATE
//===========================================================================
void DS_Listener(int property, float value)
{
if(!dsListener) return;
switch(property)
{
case SFXLP_UPDATE:
// Commit any deferred settings.
dsListener->CommitDeferredSettings();
EAXCommitDeferred();
break;
case SFXLP_UNITS_PER_METER:
dsListener->SetDistanceFactor(1/value, DS3D_IMMEDIATE);
break;
case SFXLP_DOPPLER:
dsListener->SetDopplerFactor(value, DS3D_IMMEDIATE);
break;
}
}
示例4: DS_Init
//.........这里部分代码省略.........
// Are we in verbose mode?
if((verbose = ArgExists("-verbose")))
Con_Message("DS_Init(Compat): Initializing sound driver...\n");
// Get Doomsday's window handle.
hWnd = (HWND) DD_GetInteger(DD_WINDOW_HANDLE);
hr = DS_OK;
if(ArgExists("-noeax")
|| FAILED(hr = EAXDirectSoundCreate(NULL, &dsound, NULL)))
{
// EAX can't be initialized. Use normal DS, then.
if(FAILED(hr)) Error("DS_Init", "EAX 2 couldn't be initialized.");
if(FAILED(hr = DirectSoundCreate(NULL, &dsound, NULL)))
{
Error("DS_Init", "Failed to create dsound interface.");
return false;
}
}
// Set the cooperative level.
if(FAILED(hr = dsound->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)))
{
Error("DS_Init", "Couldn't set dSound coop level.");
return false;
}
// Get the primary buffer and the listener.
primary = NULL;
memset(&desc, 0, sizeof(desc));
desc.dwSize = sizeof(desc);
desc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
dsListener = NULL;
if(SUCCEEDED(dsound->CreateSoundBuffer(&desc, &primary, NULL)))
{
// Query the listener interface.
primary->QueryInterface(IID_IDirectSound3DListener,
(void**) &dsListener);
}
else
{
// Failure; get a 2D primary buffer, then.
desc.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsound->CreateSoundBuffer(&desc, &primary, NULL);
}
// Start playing the primary buffer.
if(primary)
{
if(FAILED(hr = primary->Play(0, 0, DSBPLAY_LOOPING)))
Error("DS_Init", "Can't play primary buffer.");
}
// Try to get the EAX listener property set.
// Create a temporary secondary buffer for it.
eaxListener = NULL;
if(SUCCEEDED(CreateDSBuffer(DSBCAPS_STATIC | DSBCAPS_CTRL3D,
DSBSIZE_MIN, 22050, 8, 1, &bufTemp)))
{
// Now try to get the property set.
if(SUCCEEDED(hr = bufTemp->QueryInterface(IID_IKsPropertySet,
(void**) &eaxListener)))
{
DWORD support = 0, revsize = 0;
// Check for support.
if(FAILED(hr = eaxListener->QuerySupport(
DSPROPSETID_EAX_ListenerProperties,
DSPROPERTY_EAXLISTENER_ENVIRONMENT,
&support))
|| ((support & NEEDED_SUPPORT) != NEEDED_SUPPORT))
{
Error("DS_Init", "Sufficient EAX2 support not present.");
eaxListener->Release();
eaxListener = NULL;
}
else
{
// EAX is supported!
if(verbose) Con_Message("DS_Init(Compat): EAX2 is available.\n");
}
}
// Release the temporary buffer interface.
bufTemp->Release();
}
// Get the caps.
dsCaps.dwSize = sizeof(dsCaps);
dsound->GetCaps(&dsCaps);
if(verbose) Con_Message("DS_Init(Compat): Number of hardware 3D "
"buffers: %i\n", dsCaps.dwMaxHw3DAllBuffers);
// Configure the DS3D listener.
if(dsListener)
{
dsListener->SetDistanceFactor(1/36.0f, DS3D_DEFERRED);
dsListener->SetDopplerFactor(2, DS3D_DEFERRED);
}
// Success!
initOk = true;
return true;
}