Beispiel #1
0
        /// <summary>
        /// R_RenderDlights
        /// </summary>
        private static void RenderDlights()
        {
            //int i;
            //dlight_t* l;

            if (_glFlashBlend.Value == 0)
            {
                return;
            }

            _DlightFrameCount = _FrameCount + 1;        // because the count hasn't advanced yet for this frame

            GL.DepthMask(false);
            GL.Disable(EnableCap.Texture2D);
            GL.ShadeModel(ShadingModel.Smooth);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.One, BlendingFactor.One);

            for (int i = 0; i < client.MAX_DLIGHTS; i++)
            {
                dlight_t l = client.DLights[i];
                if (l.die < client.cl.time || l.radius == 0)
                {
                    continue;
                }

                RenderDlight(l);
            }

            GL.Color3(1f, 1, 1);
            GL.Disable(EnableCap.Blend);
            GL.Enable(EnableCap.Texture2D);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL.DepthMask(true);
        }
Beispiel #2
0
        // CL_Init
        public void Initialise( )
        {
            InitInput(Host);
            InitTempEntities();

            if (Host.Cvars.Name == null)
            {
                Host.Cvars.Name           = Host.CVars.Add("_cl_name", "player", ClientVariableFlags.Archive);
                Host.Cvars.Color          = Host.CVars.Add("_cl_color", 0f, ClientVariableFlags.Archive);
                Host.Cvars.ShowNet        = Host.CVars.Add("cl_shownet", 0); // can be 0, 1, or 2
                Host.Cvars.NoLerp         = Host.CVars.Add("cl_nolerp", false);
                Host.Cvars.LookSpring     = Host.CVars.Add("lookspring", false, ClientVariableFlags.Archive);
                Host.Cvars.LookStrafe     = Host.CVars.Add("lookstrafe", false, ClientVariableFlags.Archive);
                Host.Cvars.Sensitivity    = Host.CVars.Add("sensitivity", 3f, ClientVariableFlags.Archive);
                Host.Cvars.MPitch         = Host.CVars.Add("m_pitch", 0.022f, ClientVariableFlags.Archive);
                Host.Cvars.MYaw           = Host.CVars.Add("m_yaw", 0.022f, ClientVariableFlags.Archive);
                Host.Cvars.MForward       = Host.CVars.Add("m_forward", 1f, ClientVariableFlags.Archive);
                Host.Cvars.MSide          = Host.CVars.Add("m_side", 0.8f, ClientVariableFlags.Archive);
                Host.Cvars.UpSpeed        = Host.CVars.Add("cl_upspeed", 200f);
                Host.Cvars.ForwardSpeed   = Host.CVars.Add("cl_forwardspeed", 200f, ClientVariableFlags.Archive);
                Host.Cvars.BackSpeed      = Host.CVars.Add("cl_backspeed", 200f, ClientVariableFlags.Archive);
                Host.Cvars.SideSpeed      = Host.CVars.Add("cl_sidespeed", 350f);
                Host.Cvars.MoveSpeedKey   = Host.CVars.Add("cl_movespeedkey", 2.0f);
                Host.Cvars.YawSpeed       = Host.CVars.Add("cl_yawspeed", 140f);
                Host.Cvars.PitchSpeed     = Host.CVars.Add("cl_pitchspeed", 150f);
                Host.Cvars.AngleSpeedKey  = Host.CVars.Add("cl_anglespeedkey", 1.5f);
                Host.Cvars.AnimationBlend = Host.CVars.Add("cl_animationblend", false);
            }

            for (var i = 0; i < _EFrags.Length; i++)
            {
                _EFrags[i] = new EFrag();
            }

            for (var i = 0; i < _Entities.Length; i++)
            {
                _Entities[i] = new Entity();
            }

            for (var i = 0; i < _StaticEntities.Length; i++)
            {
                _StaticEntities[i] = new Entity();
            }

            for (var i = 0; i < _DLights.Length; i++)
            {
                _DLights[i] = new dlight_t();
            }

            //
            // register our commands
            //
            Host.Commands.Add("cmd", ForwardToServer_f);
            Host.Commands.Add("entities", PrintEntities_f);
            Host.Commands.Add("disconnect", Disconnect_f);
            Host.Commands.Add("record", Record_f);
            Host.Commands.Add("stop", Stop_f);
            Host.Commands.Add("playdemo", PlayDemo_f);
            Host.Commands.Add("timedemo", TimeDemo_f);
        }
Beispiel #3
0
        // CL_Init
        public static void Init()
        {
            InitInput();
            InitTempEntities();

            if (_Name == null)
            {
                _Name          = new cvar("_cl_name", "player", true);
                _Color         = new cvar("_cl_color", "0", true);
                _ShowNet       = new cvar("cl_shownet", "0");   // can be 0, 1, or 2
                _NoLerp        = new cvar("cl_nolerp", "0");
                _LookSpring    = new cvar("lookspring", "0", true);
                _LookStrafe    = new cvar("lookstrafe", "0", true);
                _Sensitivity   = new cvar("sensitivity", "3", true);
                _MPitch        = new cvar("m_pitch", "0.022", true);
                _MYaw          = new cvar("m_yaw", "0.022", true);
                _MForward      = new cvar("m_forward", "1", true);
                _MSide         = new cvar("m_side", "0.8", true);
                _UpSpeed       = new cvar("cl_upspeed", "200");
                _ForwardSpeed  = new cvar("cl_forwardspeed", "200", true);
                _BackSpeed     = new cvar("cl_backspeed", "200", true);
                _SideSpeed     = new cvar("cl_sidespeed", "350");
                _MoveSpeedKey  = new cvar("cl_movespeedkey", "2.0");
                _YawSpeed      = new cvar("cl_yawspeed", "140");
                _PitchSpeed    = new cvar("cl_pitchspeed", "150");
                _AngleSpeedKey = new cvar("cl_anglespeedkey", "1.5");
            }

            for (int i = 0; i < _EFrags.Length; i++)
            {
                _EFrags[i] = new efrag_t();
            }

            for (int i = 0; i < _Entities.Length; i++)
            {
                _Entities[i] = new entity_t();
            }

            for (int i = 0; i < _StaticEntities.Length; i++)
            {
                _StaticEntities[i] = new entity_t();
            }

            for (int i = 0; i < _DLights.Length; i++)
            {
                _DLights[i] = new dlight_t();
            }

            //
            // register our commands
            //
            cmd.Add("entities", PrintEntities_f);
            cmd.Add("disconnect", Disconnect_f);
            cmd.Add("record", Record_f);
            cmd.Add("stop", Stop_f);
            cmd.Add("playdemo", PlayDemo_f);
            cmd.Add("timedemo", TimeDemo_f);
        }
Beispiel #4
0
        /// <summary>
        /// R_RenderDlight
        /// </summary>
        private void RenderDlight(dlight_t light)
        {
            var rad = light.radius * 0.35f;
            var v   = light.origin - Origin;

            if (v.Length < rad)
            {               // view is inside the dlight
                AddLightBlend(1, 0.5f, 0, light.radius * 0.0003f);
                return;
            }

            Host.Video.Device.Graphics.DrawDLight(light, ViewPn, ViewUp, ViewRight);
        }
Beispiel #5
0
        private static mplane_t _LightPlane;  // lightplane

        /// <summary>
        /// R_PushDlights
        /// </summary>
        public static void PushDlights()
        {
            if (_glFlashBlend.Value != 0)
            {
                return;
            }

            _DlightFrameCount = _FrameCount + 1;        // because the count hasn't advanced yet for this frame

            for (int i = 0; i < client.MAX_DLIGHTS; i++)
            {
                dlight_t l = client.DLights[i];
                if (l.die < client.cl.time || l.radius == 0)
                {
                    continue;
                }
                render.MarkLights(l, 1 << i, client.cl.worldmodel.nodes[0]);
            }
        }
Beispiel #6
0
        /// <summary>
        /// CL_DecayLights
        /// </summary>
        public static void DecayLights()
        {
            float time = (float)(cl.time - cl.oldtime);

            for (int i = 0; i < MAX_DLIGHTS; i++)
            {
                dlight_t dl = _DLights[i];
                if (dl.die < cl.time || dl.radius == 0)
                {
                    continue;
                }

                dl.radius -= time * dl.decay;
                if (dl.radius < 0)
                {
                    dl.radius = 0;
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// R_MarkLights
        /// </summary>
        private static void MarkLights(dlight_t light, int bit, mnodebase_t node)
        {
            if (node.contents < 0)
            {
                return;
            }

            mnode_t  n          = (mnode_t)node;
            mplane_t splitplane = n.plane;
            float    dist       = Vector3.Dot(light.origin, splitplane.normal) - splitplane.dist;

            if (dist > light.radius)
            {
                MarkLights(light, bit, n.children[0]);
                return;
            }
            if (dist < -light.radius)
            {
                MarkLights(light, bit, n.children[1]);
                return;
            }

            // mark the polygons
            for (int i = 0; i < n.numsurfaces; i++)
            {
                msurface_t surf = client.cl.worldmodel.surfaces[n.firstsurface + i];
                if (surf.dlightframe != _DlightFrameCount)
                {
                    surf.dlightbits  = 0;
                    surf.dlightframe = _DlightFrameCount;
                }
                surf.dlightbits |= bit;
            }

            MarkLights(light, bit, n.children[0]);
            MarkLights(light, bit, n.children[1]);
        }
Beispiel #8
0
        /// <summary>
        /// R_MarkLights
        /// </summary>
        private void MarkLights(dlight_t light, Int32 bit, MemoryNodeBase node)
        {
            if (node.contents < 0)
            {
                return;
            }

            var n          = ( MemoryNode )node;
            var splitplane = n.plane;
            var dist       = Vector3.Dot(light.origin, splitplane.normal) - splitplane.dist;

            if (dist > light.radius)
            {
                MarkLights(light, bit, n.children[0]);
                return;
            }
            if (dist < -light.radius)
            {
                MarkLights(light, bit, n.children[1]);
                return;
            }

            // mark the polygons
            for (var i = 0; i < n.numsurfaces; i++)
            {
                var surf = Host.Client.cl.worldmodel.Surfaces[n.firstsurface + i];
                if (surf.dlightframe != _DlightFrameCount)
                {
                    surf.dlightbits  = 0;
                    surf.dlightframe = _DlightFrameCount;
                }
                surf.dlightbits |= bit;
            }

            MarkLights(light, bit, n.children[0]);
            MarkLights(light, bit, n.children[1]);
        }
Beispiel #9
0
        /// <summary>
        /// R_RenderDlight
        /// </summary>
        private static void RenderDlight(dlight_t light)
        {
            float   rad = light.radius * 0.35f;
            Vector3 v   = light.origin - render.Origin;

            if (v.Length < rad)
            {   // view is inside the dlight
                AddLightBlend(1, 0.5f, 0, light.radius * 0.0003f);
                return;
            }

            GL.Begin(PrimitiveType.TriangleFan);
            GL.Color3(0.2f, 0.1f, 0);
            v = light.origin - render.ViewPn * rad;
            GL.Vertex3(v);
            GL.Color3(0, 0, 0);
            for (int i = 16; i >= 0; i--)
            {
                double a = i / 16.0 * Math.PI * 2;
                v = light.origin + render.ViewRight * (float)Math.Cos(a) * rad + render.ViewUp * (float)Math.Sin(a) * rad;
                GL.Vertex3(v);
            }
            GL.End();
        }
Beispiel #10
0
        /// <summary>
        /// R_RenderDlight
        /// </summary>
        static void RenderDlight(dlight_t light)
        {
            float rad = light.radius * 0.35f;
            Vector3 v = light.origin - Render.Origin;
            if (v.Length < rad)
            {	// view is inside the dlight
                AddLightBlend(1, 0.5f, 0, light.radius * 0.0003f);
                return;
            }

            GL.Begin(BeginMode.TriangleFan);
            GL.Color3(0.2f, 0.1f, 0);
            v = light.origin - Render.ViewPn * rad;
            GL.Vertex3(v);
            GL.Color3(0, 0, 0);
            for (int i = 16; i >= 0; i--)
            {
                double a = i / 16.0 * Math.PI * 2;
                v = light.origin + Render.ViewRight * (float)Math.Cos(a) * rad + Render.ViewUp * (float)Math.Sin(a) * rad;
                GL.Vertex3(v);
            }
            GL.End();
        }
Beispiel #11
0
        /// <summary>
        /// R_MarkLights
        /// </summary>
        static void MarkLights(dlight_t light, int bit, mnodebase_t node)
        {
            if (node.contents < 0)
                return;

            mnode_t n = (mnode_t)node;
            mplane_t splitplane = n.plane;
            float dist = Vector3.Dot(light.origin, splitplane.normal) - splitplane.dist;

            if (dist > light.radius)
            {
                MarkLights(light, bit, n.children[0]);
                return;
            }
            if (dist < -light.radius)
            {
                MarkLights(light, bit, n.children[1]);
                return;
            }

            // mark the polygons
            for (int i = 0; i < n.numsurfaces; i++)
            {
                msurface_t surf = Client.cl.worldmodel.surfaces[n.firstsurface + i];
                if (surf.dlightframe != _DlightFrameCount)
                {
                    surf.dlightbits = 0;
                    surf.dlightframe = _DlightFrameCount;
                }
                surf.dlightbits |= bit;
            }

            MarkLights(light, bit, n.children[0]);
            MarkLights(light, bit, n.children[1]);
        }
Beispiel #12
0
        // CL_Init
        public static void Init()
        {
            InitInput();
            InitTempEntities();

            if (_Name == null)
            {
                _Name = new Cvar("_cl_name", "player", true);
                _Color = new Cvar("_cl_color", "0", true);
                _ShowNet = new Cvar("cl_shownet", "0");	// can be 0, 1, or 2
                _NoLerp = new Cvar("cl_nolerp", "0");
                _LookSpring = new Cvar("lookspring", "0", true);
                _LookStrafe = new Cvar("lookstrafe", "0", true);
                _Sensitivity = new Cvar("sensitivity", "3", true);
                _MPitch = new Cvar("m_pitch", "0.022", true);
                _MYaw = new Cvar("m_yaw", "0.022", true);
                _MForward = new Cvar("m_forward", "1", true);
                _MSide = new Cvar("m_side", "0.8", true);
                _UpSpeed = new Cvar("cl_upspeed", "200");
                _ForwardSpeed = new Cvar("cl_forwardspeed", "200", true);
                _BackSpeed = new Cvar("cl_backspeed", "200", true);
                _SideSpeed = new Cvar("cl_sidespeed", "350");
                _MoveSpeedKey = new Cvar("cl_movespeedkey", "2.0");
                _YawSpeed = new Cvar("cl_yawspeed", "140");
                _PitchSpeed = new Cvar("cl_pitchspeed", "150");
                _AngleSpeedKey = new Cvar("cl_anglespeedkey", "1.5");
            }

            for (int i = 0; i < _EFrags.Length; i++)
                _EFrags[i] = new efrag_t();

            for (int i = 0; i < _Entities.Length; i++)
                _Entities[i] = new entity_t();

            for (int i = 0; i < _StaticEntities.Length; i++)
                _StaticEntities[i] = new entity_t();

            for (int i = 0; i < _DLights.Length; i++)
                _DLights[i] = new dlight_t();

            //
            // register our commands
            //
            Cmd.Add("entities", PrintEntities_f);
            Cmd.Add("disconnect", Disconnect_f);
            Cmd.Add("record", Record_f);
            Cmd.Add("stop", Stop_f);
            Cmd.Add("playdemo", PlayDemo_f);
            Cmd.Add("timedemo", TimeDemo_f);
        }
Beispiel #13
0
        /// <summary>
        /// CL_RelinkEntities
        /// </summary>
        private static void RelinkEntities()
        {
            // determine partial update time
            float frac = LerpPoint();

            NumVisEdicts = 0;

            //
            // interpolate player info
            //
            cl.velocity = cl.mvelocity[1] + frac * (cl.mvelocity[0] - cl.mvelocity[1]);

            if (cls.demoplayback)
            {
                // interpolate the angles
                Vector3 angleDelta = cl.mviewangles[0] - cl.mviewangles[1];
                mathlib.CorrectAngles180(ref angleDelta);
                cl.viewangles = cl.mviewangles[1] + frac * angleDelta;
            }

            float bobjrotate = mathlib.AngleMod(100 * cl.time);

            // start on the entity after the world
            for (int i = 1; i < cl.num_entities; i++)
            {
                entity_t ent = _Entities[i];
                if (ent.model == null)
                {
                    // empty slot
                    if (ent.forcelink)
                    {
                        render.RemoveEfrags(ent);       // just became empty
                    }
                    continue;
                }

                // if the object wasn't included in the last packet, remove it
                if (ent.msgtime != cl.mtime[0])
                {
                    ent.model = null;
                    continue;
                }

                Vector3 oldorg = ent.origin;

                if (ent.forcelink)
                {
                    // the entity was not updated in the last message
                    // so move to the final spot
                    ent.origin = ent.msg_origins[0];
                    ent.angles = ent.msg_angles[0];
                }
                else
                {
                    // if the delta is large, assume a teleport and don't lerp
                    float   f     = frac;
                    Vector3 delta = ent.msg_origins[0] - ent.msg_origins[1];
                    if (Math.Abs(delta.X) > 100 || Math.Abs(delta.Y) > 100 || Math.Abs(delta.Z) > 100)
                    {
                        f = 1; // assume a teleportation, not a motion
                    }
                    // interpolate the origin and angles
                    ent.origin = ent.msg_origins[1] + f * delta;
                    Vector3 angleDelta = ent.msg_angles[0] - ent.msg_angles[1];
                    mathlib.CorrectAngles180(ref angleDelta);
                    ent.angles = ent.msg_angles[1] + f * angleDelta;
                }

                // rotate binary objects locally
                if ((ent.model.flags & EF.EF_ROTATE) != 0)
                {
                    ent.angles.Y = bobjrotate;
                }

                if ((ent.effects & EntityEffects.EF_BRIGHTFIELD) != 0)
                {
                    render.EntityParticles(ent);
                }

                if ((ent.effects & EntityEffects.EF_MUZZLEFLASH) != 0)
                {
                    dlight_t dl = AllocDlight(i);
                    dl.origin    = ent.origin;
                    dl.origin.Z += 16;
                    Vector3 fv, rv, uv;
                    mathlib.AngleVectors(ref ent.angles, out fv, out rv, out uv);
                    dl.origin  += fv * 18;
                    dl.radius   = 200 + (sys.Random() & 31);
                    dl.minlight = 32;
                    dl.die      = (float)cl.time + 0.1f;
                }
                if ((ent.effects & EntityEffects.EF_BRIGHTLIGHT) != 0)
                {
                    dlight_t dl = AllocDlight(i);
                    dl.origin    = ent.origin;
                    dl.origin.Z += 16;
                    dl.radius    = 400 + (sys.Random() & 31);
                    dl.die       = (float)cl.time + 0.001f;
                }
                if ((ent.effects & EntityEffects.EF_DIMLIGHT) != 0)
                {
                    dlight_t dl = AllocDlight(i);
                    dl.origin = ent.origin;
                    dl.radius = 200 + (sys.Random() & 31);
                    dl.die    = (float)cl.time + 0.001f;
                }

                if ((ent.model.flags & EF.EF_GIB) != 0)
                {
                    render.RocketTrail(ref oldorg, ref ent.origin, 2);
                }
                else if ((ent.model.flags & EF.EF_ZOMGIB) != 0)
                {
                    render.RocketTrail(ref oldorg, ref ent.origin, 4);
                }
                else if ((ent.model.flags & EF.EF_TRACER) != 0)
                {
                    render.RocketTrail(ref oldorg, ref ent.origin, 3);
                }
                else if ((ent.model.flags & EF.EF_TRACER2) != 0)
                {
                    render.RocketTrail(ref oldorg, ref ent.origin, 5);
                }
                else if ((ent.model.flags & EF.EF_ROCKET) != 0)
                {
                    render.RocketTrail(ref oldorg, ref ent.origin, 0);
                    dlight_t dl = AllocDlight(i);
                    dl.origin = ent.origin;
                    dl.radius = 200;
                    dl.die    = (float)cl.time + 0.01f;
                }
                else if ((ent.model.flags & EF.EF_GRENADE) != 0)
                {
                    render.RocketTrail(ref oldorg, ref ent.origin, 1);
                }
                else if ((ent.model.flags & EF.EF_TRACER3) != 0)
                {
                    render.RocketTrail(ref oldorg, ref ent.origin, 6);
                }

                ent.forcelink = false;

                if (i == cl.viewentity && !chase.IsActive)
                {
                    continue;
                }

                if (NumVisEdicts < MAX_VISEDICTS)
                {
                    _VisEdicts[NumVisEdicts] = ent;
                    NumVisEdicts++;
                }
            }
        }