示例#1
0
        public void SetPosition(float posx, float posy)
        {
            FMOD.RESULT result;

            mListenerPos.x = posx;
            mListenerPos.y = posy;
            mListenerPos.z = 0;

            result = mSystem.set3DListenerAttributes(0, ref mListenerPos, ref mVel, ref mForward, ref mUp);
            VirtualVoices.ERRCHECK(result);
        }
示例#2
0
        public void Update(FMOD.System fmod)
        {
            FMOD.RESULT result;

            //Trace.TraceError("setting ListenerPosition: " + listenerPosition.x.ToString() + ", " +
            //    listenerPosition.y.ToString() + ", " + listenerPosition.z.ToString());

            result = fmod.set3DListenerAttributes(0, ref listenerPosition, ref listenerVelocity, ref listenerForward, ref listenerUp);
            CheckRetCode(result);

            result = fmod.update();
            LogResults(result);
        }
示例#3
0
        public void Set3DListenerAttributes(int listenerId, Vector3 location, Vector3 velocity, Vector3 forward, Vector3 up)
        {
            //Vectors here are changed into fmod's one so that in future it will be easier to modify them
            FMOD.VECTOR FMODPos = SoundPlayer.FMODVectorFromVector3(location);

            FMOD.VECTOR FMODvel = SoundPlayer.FMODVectorFromVector3(velocity);

            FMOD.VECTOR FMODForw = SoundPlayer.FMODVectorFromVector3(forward);

            FMOD.VECTOR FMODUp = SoundPlayer.FMODVectorFromVector3(up);

            //Matrix.CreateTranslation(location).Up

            FMOD.RESULT res = soundSystem.set3DListenerAttributes(listenerId, ref FMODPos, ref FMODvel, ref FMODForw, ref FMODUp);
            if (res != FMOD.RESULT.OK)
            {
                throw new Exceptions.LoadFailException(FMOD.Error.String(res));
            }
        }
        private void timer_Tick(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;

            // ==========================================================================================
            // UPDATE THE LISTENER
            // ==========================================================================================

            FMOD.VECTOR forward = new FMOD.VECTOR();
            forward.x = 0.0f; forward.y = 0.0f; forward.z = 1.0f;

            FMOD.VECTOR up = new FMOD.VECTOR();
            up.x = 0.0f; up.y = 1.0f; up.z = 0.0f;

            FMOD.VECTOR vel = new FMOD.VECTOR();

            if (listenerflag)
            {
                listenerpos.x          = ((float)Math.Sin(t * 0.05f) * 33.0f * DISTANCEFACTOR); // left right pingpong
                trackBarPosition.Value = (int)listenerpos.x;
            }

            // ********* NOTE ******* READ NEXT COMMENT!!!!!
            // vel = how far we moved last FRAME (m/f), then time compensate it to SECONDS (m/s).
            vel.x = (listenerpos.x - lastpos.x) * (1000 / INTERFACE_UPDATETIME);
            vel.y = (listenerpos.y - lastpos.y) * (1000 / INTERFACE_UPDATETIME);
            vel.z = (listenerpos.z - lastpos.z) * (1000 / INTERFACE_UPDATETIME);

            // store pos for next time
            lastpos = listenerpos;

            result = system.set3DListenerAttributes(0, ref listenerpos, ref vel, ref forward, ref up);
            ERRCHECK(result);

            t += (30 * (1.0f / (float)INTERFACE_UPDATETIME));    // t is just a time value .. it increments in 30m/s steps in this example

            if (system != null)
            {
                system.update();
            }
        }
示例#5
0
        public bool Update(float updatetime)
        {
            pos.x = m_position.x;
            pos.y = m_position.y;
            pos.z = m_position.z;

            vel.x = (pos.x - lastPos.x) * (1 / updatetime);
            vel.y = (pos.y - lastPos.y) * (1 / updatetime);
            vel.z = (pos.z - lastPos.z) * (1 / updatetime);

            //Update listener attributes
            m_system.set3DListenerAttributes(0, ref pos, ref vel, ref forward, ref up);

            m_position.x = pos.x;
            m_position.y = pos.y;
            m_position.z = pos.z;

            lastPos = pos;

            m_system.update();
            return(true);
        }