예제 #1
0
 new void CommonInit()
 {
     world       = renderSystem.AllocRenderWorld();
     needsRender = true;
     lightOrigin = new Vector4(-128f, 0f, 0f, 1f);
     lightColor  = new Vector4(1f, 1f, 1f, 1f);
     modelOrigin.Zero();
     viewOffset      = new Vector4(-128f, 0f, 0f, 1f);
     modelAnim       = null;
     animLength      = 0;
     animEndTime     = -1;
     modelDef        = -1;
     updateAnimation = true;
 }
예제 #2
0
        // Called once each sound frame by the main thread from SoundWorldLocal::PlaceOrigin
        public void Spatialize(Vector3 listenerPos, int listenerArea, IRenderWorld rw)
        {
            // work out the maximum distance of all the playing channels
            maxDistance = 0;

            for (var i = 0; i < SoundSystemLocal.SOUND_MAX_CHANNELS; i++)
            {
                var chan = channels[i];
                if (!chan.triggerState)
                {
                    continue;
                }
                if (chan.parms.maxDistance > maxDistance)
                {
                    maxDistance = chan.parms.maxDistance;
                }
            }

            // work out where the sound comes from
            var realOrigin = origin * ISoundSystem.DOOM_TO_METERS;
            var len        = listenerPos - realOrigin;

            realDistance = len.LengthFast;

            // no way to possibly hear it
            if (realDistance >= maxDistance)
            {
                distance = realDistance; return;
            }

            // work out virtual origin and distance, which may be from a portal instead of the actual origin
            distance = maxDistance * ISoundSystem.METERS_TO_DOOM;
            // listener is outside the world
            if (listenerArea == -1)
            {
                return;
            }
            if (rw != null)
            {
                // we have a valid renderWorld
                var soundInArea = rw.PointInArea(origin);
                if (soundInArea == -1)
                {
                    // sound is outside the world
                    if (lastValidPortalArea == -1)
                    {
                        distance = realDistance; spatializedOrigin = origin; return;
                    }
                    soundInArea = lastValidPortalArea; // sound is in our area
                }
                lastValidPortalArea = soundInArea;
                if (soundInArea == listenerArea)
                {
                    distance = realDistance; spatializedOrigin = origin; return;
                }                                                                                                 // sound is in our area

                soundWorld.ResolveOrigin(0, null, soundInArea, 0f, origin, this);
                distance /= ISoundSystem.METERS_TO_DOOM;
            }
            // no portals available
            else
            {
                distance = realDistance; spatializedOrigin = origin;
            }                                                             // sound is in our area
        }
예제 #3
0
 public void SetIRenderWorld(IRenderWorld render_world)
 {
     m_render_world = render_world;
 }