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


C++ AudioListener类代码示例

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


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

示例1: SAFE_RELEASE

void Scene::setActiveCamera(Camera* camera)
{
    // Make sure we don't release the camera if the same camera is set twice.
    if (_activeCamera != camera)
    {
        AudioListener* audioListener = AudioListener::getInstance();

        if (_activeCamera)
        {
            // Unbind the active camera from the audio listener
            if (audioListener && (audioListener->getCamera() == _activeCamera))
            {
                audioListener->setCamera(NULL);
            }

            SAFE_RELEASE(_activeCamera);
        }

        _activeCamera = camera;

        if (_activeCamera)
        {
            _activeCamera->addRef();

            if (audioListener && _bindAudioListenerToCamera)
            {
                audioListener->setCamera(_activeCamera);
            }
        }
    }
}
开发者ID:1timmy,项目名称:GamePlay,代码行数:31,代码来源:Scene.cpp

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

示例3:

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

示例4: VERIFY

void LevelLoader::createCamera() {
	GameObject* shadyCamObj = PrefabLoader::InstantiateGameObjectFromPrefab(FRAMEWORK->GetFileSystemUtils()->GetDevicePrefabsResourcesPath() + "ShadyCamera" + PREFAB_EXTENSION, ENGINE->GetSceneGraph3D());
	Camera* cam = shadyCamObj->GetComponent<Camera>();
	VERIFY(cam != nullptr, "Game camera object has Camera component");
	ENGINE->GetSceneGraph3D()->SetMainCameraId(shadyCamObj->GetId());
	SINGLETONS->GetGridManager()->SetShadyCamera((ShadyCamera*)cam);

	AudioListener* listener = shadyCamObj->GetComponent<AudioListener>();
	ASSERT(listener != nullptr, "Game camera object has AudioListener component");
	if (listener != nullptr) {
		listener->SetAsActiveListener();
	}
}
开发者ID:VajraFramework,项目名称:Vajra,代码行数:13,代码来源:LevelLoader.cpp

示例5: removeAllNodes

Scene::~Scene()
{
    // Unbind our active camera from the audio listener
    if (_activeCamera)
    {
        AudioListener* audioListener = AudioListener::getInstance();
        if (audioListener && (audioListener->getCamera() == _activeCamera))
        {
            audioListener->setCamera(NULL);
        }

        SAFE_RELEASE(_activeCamera);
    }

    // Remove all nodes from the scene
    removeAllNodes();
}
开发者ID:Jaegermeiste,项目名称:GamePlay,代码行数:17,代码来源:Scene.cpp

示例6: Vector3

void CSoundManager::move(Vector3 ePos, int instance, int index) {
    if(index == -1)
        index = m_nLastPlayedSound;

    if(instance == -1)
        instance = m_nLastPlayedInstance;

    Vector3 v = Vector3(g_nScreenWidth/2.0f, g_nScreenHeight/2.0f, 0);

    AudioListener listener;
    AudioEmitter emitter;
    const float SCALE = 500.0f;

    listener.SetPosition(v/SCALE);
    emitter.SetPosition(ePos/SCALE);

    if(instance >= 0 && instance < m_nInstanceCount[index])
        m_pInstance[index][instance]->Apply3D(listener, emitter);
} //move
开发者ID:zaclolz,项目名称:Blood-Crystals,代码行数:19,代码来源:Sound.cpp

示例7: removeAllNodes

Scene::~Scene()
{
    // Unbind our active camera from the audio listener
    if (_activeCamera)
    {
        AudioListener* audioListener = AudioListener::getInstance();
        if (audioListener && (audioListener->getCamera() == _activeCamera))
        {
            audioListener->setCamera(NULL);
        }

        SAFE_RELEASE(_activeCamera);
    }

    // Remove all nodes from the scene
    removeAllNodes();

    // Remove the scene from global list
    std::vector<Scene*>::iterator itr = std::find(__sceneList.begin(), __sceneList.end(), this);
    if (itr != __sceneList.end())
        __sceneList.erase(itr);
}
开发者ID:1timmy,项目名称:GamePlay,代码行数:22,代码来源:Scene.cpp

示例8: Context

float
PannerNode::ComputeDopplerShift()
{
  double dopplerShift = 1.0; // Initialize to default value

  AudioListener* listener = Context()->Listener();

  if (listener->DopplerFactor() > 0) {
    // Don't bother if both source and listener have no velocity.
    if (!mVelocity.IsZero() || !listener->Velocity().IsZero()) {
      // Calculate the source to listener vector.
      ThreeDPoint sourceToListener = mPosition - listener->Velocity();

      double sourceListenerMagnitude = sourceToListener.Magnitude();

      double listenerProjection = sourceToListener.DotProduct(listener->Velocity()) / sourceListenerMagnitude;
      double sourceProjection = sourceToListener.DotProduct(mVelocity) / sourceListenerMagnitude;

      listenerProjection = -listenerProjection;
      sourceProjection = -sourceProjection;

      double scaledSpeedOfSound = listener->DopplerFactor() / listener->DopplerFactor();
      listenerProjection = min(listenerProjection, scaledSpeedOfSound);
      sourceProjection = min(sourceProjection, scaledSpeedOfSound);

      dopplerShift = ((listener->SpeedOfSound() - listener->DopplerFactor() * listenerProjection) / (listener->SpeedOfSound() - listener->DopplerFactor() * sourceProjection));

      WebAudioUtils::FixNaN(dopplerShift); // Avoid illegal values

      // Limit the pitch shifting to 4 octaves up and 3 octaves down.
      dopplerShift = min(dopplerShift, 16.);
      dopplerShift = max(dopplerShift, 0.125);
    }
  }

  return dopplerShift;
}
开发者ID:PinZhang,项目名称:up-central,代码行数:37,代码来源:PannerNode.cpp

示例9: Entity

	Movable *Level::createMovable (XmlFile *file, int type, std::string name, Movable *parent, XMLElement *element, bool createNow)
	{
		Movable *objObject = 0;

		if (type == GOT_ENTITY)
		{
			Entity *eEntity = new Entity (name);

			if (element != 0)
				eEntity->parseXML (file, element, parent);

			if (createNow == true)
				eEntity->create (parent);

			objObject = eEntity;
		}

		if (type == GOT_CAMERA)
		{
			Camera *cCamera = new Camera (name);

			if (element != 0)
				cCamera->parseXML (file, element, parent);

			if (createNow == true)
				cCamera->create (0, parent);

			objObject = cCamera;
		}

		if (type == GOT_PARTICLE_SYSTEM)
		{
			ParticleSystem *psSystem = new ParticleSystem (name);

			if (element != 0)
				psSystem->parseXML (file, element, parent);

			if (createNow == true)
				psSystem->create (parent);

			objObject = psSystem;
		}

		if (type == GOT_LIGHT)
		{
			Light *lLight = new Light (name);

			if (element != 0)
				lLight->parseXML (file, element, parent);

			if (createNow == true)
				lLight->create (parent);

			objObject = lLight;
		}

		if (type == GOT_ANIMATION_TRACK)
		{
			AnimationTrackObject *atoObject = new AnimationTrackObject (name);

			if (element != 0)
				atoObject->parseXML (file, element, parent);

			if (createNow == true)
				atoObject->create (parent);

			objObject = atoObject;
			aryAnimations.push_back (atoObject);
		}

		if (type == GOT_AUDIO_LISTENER)
		{
			AudioListener *alListener = new AudioListener (name);

			if (element != 0)
				alListener->parseXML (file, element, parent);

			if (createNow == true)
				alListener->create (parent);

			objObject = alListener;
		}

		if (type == GOT_SOUND)
		{
			Sound *sSound = new Sound (name);

			if (element != 0)
				sSound->parseXML (file, element, parent);

			if (createNow == true)
				sSound->create (parent);

			objObject = sSound;
		}

		if (type == GOT_OVERLAY)
		{
			Overlay *oOverlay = new Overlay (name);

//.........这里部分代码省略.........
开发者ID:qeensh,项目名称:RadXML,代码行数:101,代码来源:RadXmlLevel.cpp

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