本文整理汇总了C++中AudioListener::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioListener::getPosition方法的具体用法?C++ AudioListener::getPosition怎么用?C++ AudioListener::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioListener
的用法示例。
在下文中一共展示了AudioListener::getPosition方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void AudioController::update(float elapsedTime)
{
AudioListener* listener = AudioListener::getInstance();
if (listener)
{
AL_CHECK( alListenerf(AL_GAIN, listener->getGain()) );
AL_CHECK( alListenerfv(AL_ORIENTATION, (ALfloat*)listener->getOrientation()) );
AL_CHECK( alListenerfv(AL_VELOCITY, (ALfloat*)&listener->getVelocity()) );
AL_CHECK( alListenerfv(AL_POSITION, (ALfloat*)&listener->getPosition()) );
}
}
示例2:
void Audio3DTest::drawDebugText(int x, int y)
{
_font->start();
static const int V_SPACE = 16;
AudioListener* audioListener = AudioListener::getInstance();
drawVector3("Listener Position", audioListener->getPosition(), x, y);
drawVector3("Listener Forward", audioListener->getOrientationForward(), x, y+=V_SPACE);
drawVector3("Listener Up", audioListener->getOrientationUp(), x, y+=V_SPACE);
drawVector3("Listener Velocity", audioListener->getVelocity(), x, y+=V_SPACE);
_font->finish();
}
示例3: update
void AudioController::update(long elapsedTime)
{
AudioListener* listener = AudioListener::getInstance();
if (listener)
{
#ifndef __ANDROID__
alListenerf(AL_GAIN, listener->getGain());
alListenerfv(AL_ORIENTATION, (ALfloat*)listener->getOrientation());
alListenerfv(AL_VELOCITY, (ALfloat*)&listener->getVelocity());
alListenerfv(AL_POSITION, (ALfloat*)&listener->getPosition());
#else
if (!_listenerObject)
{
const SLInterfaceID interfaces[3] = {SL_IID_3DDOPPLER, SL_IID_3DLOCATION};
const SLboolean required[3] = {SL_BOOLEAN_FALSE, SL_BOOLEAN_FALSE};
SLresult result = (*_engineEngine)->CreateListener(_engineEngine, &_listenerObject, 2, interfaces, required);
if (result != SL_RESULT_SUCCESS)
{
WARN_VARG("AudioController: failed to create listener (%u).", result);
return;
}
result = (*_listenerObject)->Realize(_listenerObject, SL_BOOLEAN_FALSE);
if (result != SL_RESULT_SUCCESS)
{
WARN("AudioController: failed to realize listener.");
return;
}
// Get the doppler interface in order to set the listener's velocity.
result = (*_listenerObject)->GetInterface(_listenerObject, SL_IID_3DDOPPLER, &_listenerDoppler);
if (result != SL_RESULT_SUCCESS)
{
WARN("AudioController: Unable to retrieve listener doppler interface.");
return;
}
// Get the location interface in order to set the listener's position and orientation.
result = (*_listenerObject)->GetInterface(_listenerObject, SL_IID_3DLOCATION, &_listenerLocation);
if (result != SL_RESULT_SUCCESS)
{
WARN("AudioController: Unable to retrieve listener location interface.");
return;
}
}
SLVec3D f;
f.x = listener->getOrientationForward().x;
f.y = listener->getOrientationForward().y;
f.z = listener->getOrientationForward().z;
SLVec3D a;
a.x = listener->getOrientationUp().x;
a.y = listener->getOrientationUp().y;
a.z = listener->getOrientationUp().z;
SLresult result = (*_listenerLocation)->SetOrientationVectors(_listenerLocation, &f, &a);
if (result != SL_RESULT_SUCCESS)
{
WARN("AudioController: Unable to set listener orientation.");
}
SLVec3D p;
p.x = listener->getPosition().x;
p.y = listener->getPosition().y;
p.z = listener->getPosition().z;
result = (*_listenerLocation)->SetLocationCartesian(_listenerLocation, &p);
if (result != SL_RESULT_SUCCESS)
{
WARN("AudioController: Unable to set listener location.");
}
SLVec3D v;
v.x = listener->getVelocity().x;
v.y = listener->getVelocity().y;
v.z = listener->getVelocity().z;
result = (*_listenerDoppler)->SetVelocityCartesian(_listenerDoppler, &v);
if (result != SL_RESULT_SUCCESS)
{
WARN("AudioController: Unable to set listener velocity.");
}
#endif
}
}