コード例 #1
0
    public void updateSystem(bool force3DSet)
    {
        FMOD.RESULT result = FMOD.RESULT.OK;

        if (m_eventSystem != null && m_eventSystemWasInit)
        {
            if (getAudioListener() != null &&
                (force3DSet || (Time.timeSinceLevelLoad - m_previousListenerUpdateTime) > 0.001f))
            {
                FMOD.VECTOR pos     = new FMOD.VECTOR();
                FMOD.VECTOR vel     = new FMOD.VECTOR();
                FMOD.VECTOR forward = new FMOD.VECTOR();
                FMOD.VECTOR up      = new FMOD.VECTOR();

                pos.x = m_audioListener.transform.position.x;
                pos.y = m_audioListener.transform.position.y;
                pos.z = m_audioListener.transform.position.z;
                if (Time.timeSinceLevelLoad - m_previousListenerUpdateTime > 0)
                {
                    vel.x = (pos.x - m_previousListenerPos.x) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime);
                    vel.y = (pos.y - m_previousListenerPos.y) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime);
                    vel.z = (pos.z - m_previousListenerPos.z) / (Time.timeSinceLevelLoad - m_previousListenerUpdateTime);
                }
                forward.x = m_audioListener.transform.forward.x;
                forward.y = m_audioListener.transform.forward.y;
                forward.z = m_audioListener.transform.forward.z;
                up.x      = m_audioListener.transform.up.x;
                up.y      = m_audioListener.transform.up.y;
                up.z      = m_audioListener.transform.up.z;

                result = m_eventSystem.set3DListenerAttributes(0, ref pos, ref vel, ref forward, ref up);
                ERRCHECK(result);
                result = m_system.set3DListenerAttributes(0, ref pos, ref vel, ref forward, ref up);
                ERRCHECK(result);


                m_previousListenerPos = m_audioListener.transform.position;
//					m_previousListenerForward = m_audioListener.transform.forward;
//					m_previousListenerUp = m_audioListener.transform.up;
                m_previousListenerUpdateTime = Time.timeSinceLevelLoad;
            }
            result = m_eventSystem.update();
            ERRCHECK(result);
            result = m_system.update();
            ERRCHECK(result);
        }
    }