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


C++ AudioListener::getOrientationUp方法代码示例

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


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

示例1:

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();
}
开发者ID:ArtProgrammer,项目名称:game-play,代码行数:11,代码来源:Audio3DTest.cpp

示例2: 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
    }
}
开发者ID:jsethi,项目名称:GamePlay,代码行数:82,代码来源:AudioController.cpp


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