Beispiel #1
0
        static client()
        {
            int kk;

            for (kk = 0; kk < MAX_EFRAGS; kk++)
            {
                cl_efrags[kk] = new render.efrag_t();
            }
            for (kk = 0; kk < quakedef.MAX_EDICTS; kk++)
            {
                cl_entities[kk] = new render.entity_t();
            }
            for (kk = 0; kk < MAX_STATIC_ENTITIES; kk++)
            {
                cl_static_entities[kk] = new render.entity_t();
            }
            for (kk = 0; kk < MAX_TEMP_ENTITIES; kk++)
            {
                cl_temp_entities[kk] = new render.entity_t();
            }
            for (kk = 0; kk < quakedef.MAX_LIGHTSTYLES; kk++)
            {
                cl_lightstyle[kk] = new lightstyle_t();
            }
            for (kk = 0; kk < MAX_DLIGHTS; kk++)
            {
                cl_dlights[kk] = new dlight_t();
            }
            for (kk = 0; kk < MAX_BEAMS; kk++)
            {
                cl_beams[kk] = new beam_t();
            }
        }
Beispiel #2
0
        public virtual void R_RenderDlight(dlight_t light)
        {
            var rad = light.intensity * 0.35F;

            Math3D.VectorSubtract(light.origin, r_origin, v);
            GL.Begin(PrimitiveType.TriangleFan);
            GL.Color3(light.color[0] * 0.2F, light.color[1] * 0.2F, light.color[2] * 0.2F);
            Int32 i;

            for (i = 0; i < 3; i++)
            {
                v[i] = light.origin[i] - vpn[i] * rad;
            }
            GL.Vertex3(v[0], v[1], v[2]);
            GL.Color3(0, 0, 0);
            Int32  j;
            Single a;

            for (i = 16; i >= 0; i--)
            {
                a = ( Single )(i / 16F * Math.PI * 2);
                for (j = 0; j < 3; j++)
                {
                    v[j] = ( Single )(light.origin[j] + vright[j] * Math.Cos(a) * rad + vup[j] * Math.Sin(a) * rad);
                }
                GL.Vertex3(v[0], v[1], v[2]);
            }

            GL.End();
        }
Beispiel #3
0
    public static void R_RenderDlights()
    {
        //int i;
        //dlight_t* l;

        if (gl_flashblend.value == 0)
        {
            return;
        }

        r_dlightframecount = r_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(BlendingFactorSrc.One, BlendingFactorDest.One);

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

            R_RenderDlight(l);
        }

        GL.Color3(1f, 1, 1);
        GL.Disable(EnableCap.Blend);
        GL.Enable(EnableCap.Texture2D);
        GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        GL.DepthMask(true);
    }
Beispiel #4
0
        /*
         * =============================================================================
         *
         * DYNAMIC LIGHTS
         *
         * =============================================================================
         */

        /*
         * ============= R_MarkLights =============
         */
        protected void R_MarkLights(dlight_t light, int bit, mnode_t node)
        {
            cplane_t   splitplane;
            float      dist;
            msurface_t surf;
            int        i;
            int        sidebit;

            if (node.contents != -1)
            {
                return;
            }

            splitplane = node.plane;
            dist       = Math3D.DotProduct(light.origin, splitplane.normal) - splitplane.dist;

            if (dist > light.intensity - OpenGLRenderApi.DLIGHT_CUTOFF)
            {
                this.R_MarkLights(light, bit, node.children[0]);

                return;
            }

            if (dist < -light.intensity + OpenGLRenderApi.DLIGHT_CUTOFF)
            {
                this.R_MarkLights(light, bit, node.children[1]);

                return;
            }

            // mark the polygons
            for (i = 0; i < node.numsurfaces; i++)
            {
                surf = this.r_worldmodel.surfaces[node.firstsurface + i];

                dist    = Math3D.DotProduct(light.origin, surf.plane.normal) - surf.plane.dist;
                sidebit = dist >= 0 ? 0 : Defines.SURF_PLANEBACK;

                if ((surf.flags & Defines.SURF_PLANEBACK) != sidebit)
                {
                    continue;
                }

                if (surf.dlightframe != this.r_dlightframecount)
                {
                    surf.dlightbits  = 0;
                    surf.dlightframe = this.r_dlightframecount;
                }

                surf.dlightbits |= bit;
            }

            this.R_MarkLights(light, bit, node.children[0]);
            this.R_MarkLights(light, bit, node.children[1]);
        }
Beispiel #5
0
    public static void CL_Init()
    {
        CL_InitInput();
        CL_InitTEnts();

        cl_name          = new cvar_t("_cl_name", "player", true);
        cl_color         = new cvar_t("_cl_color", "0", true);
        cl_shownet       = new cvar_t("cl_shownet", "0"); // can be 0, 1, or 2
        cl_nolerp        = new cvar_t("cl_nolerp", "0");
        lookspring       = new cvar_t("lookspring", "0", true);
        lookstrafe       = new cvar_t("lookstrafe", "0", true);
        sensitivity      = new cvar_t("sensitivity", "3", true);
        m_pitch          = new cvar_t("m_pitch", "0.022", true);
        m_yaw            = new cvar_t("m_yaw", "0.022", true);
        m_forward        = new cvar_t("m_forward", "1", true);
        m_side           = new cvar_t("m_side", "0.8", true);
        cl_upspeed       = new cvar_t("cl_upspeed", "200");
        cl_forwardspeed  = new cvar_t("cl_forwardspeed", "200", true);
        cl_backspeed     = new cvar_t("cl_backspeed", "200", true);
        cl_sidespeed     = new cvar_t("cl_sidespeed", "350");
        cl_movespeedkey  = new cvar_t("cl_movespeedkey", "2.0");
        cl_yawspeed      = new cvar_t("cl_yawspeed", "140");
        cl_pitchspeed    = new cvar_t("cl_pitchspeed", "150");
        cl_anglespeedkey = new cvar_t("cl_anglespeedkey", "1.5");

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

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

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

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

        //
        // register our commands
        //
        Cmd_AddCommand("entities", CL_PrintEntities_f);
        Cmd_AddCommand("disconnect", CL_Disconnect_f);
        Cmd_AddCommand("record", CL_Record_f);
        Cmd_AddCommand("stop", CL_Stop_f);
        Cmd_AddCommand("playdemo", CL_PlayDemo_f);
        Cmd_AddCommand("timedemo", CL_TimeDemo_f);
    }
Beispiel #6
0
 static client()
 {
     int kk;
     for (kk = 0; kk < MAX_EFRAGS; kk++) cl_efrags[kk] = new render.efrag_t();
     for (kk = 0; kk < quakedef.MAX_EDICTS; kk++) cl_entities[kk] = new render.entity_t();
     for (kk = 0; kk < MAX_STATIC_ENTITIES; kk++) cl_static_entities[kk] = new render.entity_t();
     for (kk = 0; kk < MAX_TEMP_ENTITIES; kk++) cl_temp_entities[kk] = new render.entity_t();
     for (kk = 0; kk < quakedef.MAX_LIGHTSTYLES; kk++) cl_lightstyle[kk] = new lightstyle_t();
     for (kk = 0; kk < MAX_DLIGHTS; kk++) cl_dlights[kk] = new dlight_t();
     for (kk = 0; kk < MAX_BEAMS; kk++) cl_beams[kk] = new beam_t();
 }
Beispiel #7
0
        /// <summary>
        /// R_RenderDlight
        /// </summary>
        private void RenderDlight(dlight_t light)
        {
            var rad = light.radius * 0.35f;
            var v   = light.origin - this.Origin;

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

            this.Host.Video.Device.Graphics.DrawDLight(light, this.ViewPn, this.ViewUp, this.ViewRight);
        }
Beispiel #8
0
        public override void R_MarkLights(dlight_t light, Int32 bit, mnode_t node)
        {
            cplane_t   splitplane;
            Single     dist;
            msurface_t surf;
            Int32      i;
            Int32      sidebit;

            if (node.contents != -1)
            {
                return;
            }
            splitplane = node.plane;
            dist       = Math3D.DotProduct(light.origin, splitplane.normal) - splitplane.dist;
            if (dist > light.intensity - DLIGHT_CUTOFF)
            {
                R_MarkLights(light, bit, node.children[0]);
                return;
            }

            if (dist < -light.intensity + DLIGHT_CUTOFF)
            {
                R_MarkLights(light, bit, node.children[1]);
                return;
            }

            for (i = 0; i < node.numsurfaces; i++)
            {
                surf    = r_worldmodel.surfaces[node.firstsurface + i];
                dist    = Math3D.DotProduct(light.origin, surf.plane.normal) - surf.plane.dist;
                sidebit = (dist >= 0) ? 0 : Defines.SURF_PLANEBACK;
                if ((surf.flags & Defines.SURF_PLANEBACK) != sidebit)
                {
                    continue;
                }
                if (surf.dlightframe != r_dlightframecount)
                {
                    surf.dlightbits  = 0;
                    surf.dlightframe = r_dlightframecount;
                }

                surf.dlightbits |= bit;
            }

            R_MarkLights(light, bit, node.children[0]);
            R_MarkLights(light, bit, node.children[1]);
        }
Beispiel #9
0
        public override void DrawDLight(dlight_t light, Vector3 viewProj, Vector3 viewUp, Vector3 viewRight)
        {
            var rad = light.radius * 0.35f;
            var v   = light.origin - viewProj * rad;

            GL.Begin(PrimitiveType.TriangleFan);
            GL.Color3(0.2f, 0.1f, 0);
            GL.Vertex3(v.X, v.Y, v.Z);
            GL.Color3(0, 0, 0);
            for (var i = 16; i >= 0; i--)
            {
                var a = i / 16.0 * Math.PI * 2;
                v = light.origin + viewRight * ( float )Math.Cos(a) * rad + viewUp * ( float )Math.Sin(a) * rad;
                GL.Vertex3(v.X, v.Y, v.Z);
            }
            GL.End( );
        }
Beispiel #10
0
    public static void CL_DecayLights()
    {
        float time = (float)(cl.time - cl.oldtime);

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

            dl.radius -= time * dl.decay;
            if (dl.radius < 0)
            {
                dl.radius = 0;
            }
        }
    }
Beispiel #11
0
    public static void R_PushDlights()
    {
        if (gl_flashblend.value != 0)
        {
            return;
        }

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

        for (int i = 0; i < q_shared.MAX_DLIGHTS; i++)
        {
            dlight_t l = cl_dlights[i];
            if (l.die < cl.time || l.radius == 0)
            {
                continue;
            }
            R_MarkLights(l, 1 << i, cl.worldmodel.nodes[0]);
        }
    }
Beispiel #12
0
        /*
         * =============================================================================
         *
         * DYNAMIC LIGHTS BLEND RENDERING
         *
         * =============================================================================
         */

        private void R_RenderDlight(dlight_t light)
        {
            int   i, j;
            float a;

            float[] v = { 0, 0, 0 };
            float   rad;

            rad = light.intensity * 0.35f;

            Math3D.VectorSubtract(light.origin, this.r_origin, v);

            this.gl.glBegin(OpenGL.GL_TRIANGLE_FAN);
            this.gl.glColor3f(light.color[0] * 0.2f, light.color[1] * 0.2f, light.color[2] * 0.2f);

            for (i = 0; i < 3; i++)
            {
                v[i] = light.origin[i] - this.vpn[i] * rad;
            }

            this.gl.glVertex3f(v[0], v[1], v[2]);
            this.gl.glColor3f(0, 0, 0);

            for (i = 16; i >= 0; i--)
            {
                a = (float)(i / 16.0f * Math.PI * 2);

                for (j = 0; j < 3; j++)
                {
                    v[j] = (float)(light.origin[j] + this.vright[j] * Math.Cos(a) * rad + this.vup[j] * Math.Sin(a) * rad);
                }

                this.gl.glVertex3f(v[0], v[1], v[2]);
            }

            this.gl.glEnd();
        }
Beispiel #13
0
    public static void R_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)
        {
            R_MarkLights(light, bit, n.children[0]);
            return;
        }
        if (dist < -light.radius)
        {
            R_MarkLights(light, bit, n.children[1]);
            return;
        }

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

        R_MarkLights(light, bit, n.children[0]);
        R_MarkLights(light, bit, n.children[1]);
    }
Beispiel #14
0
        /// <summary>
        /// R_MarkLights
        /// </summary>
        private void MarkLights(dlight_t light, int 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)
            {
                this.MarkLights(light, bit, n.children[0]);
                return;
            }
            if (dist < -light.radius)
            {
                this.MarkLights(light, bit, n.children[1]);
                return;
            }

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

            this.MarkLights(light, bit, n.children[0]);
            this.MarkLights(light, bit, n.children[1]);
        }
Beispiel #15
0
    public static void R_RenderDlight(dlight_t light)
    {
        float   rad = light.radius * 0.35f;
        Vector3 v   = light.origin - r_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 - vpn * 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 + vright * (float)Math.Cos(a) * rad + vup * (float)Math.Sin(a) * rad;
            GL.Vertex3(v);
        }
        GL.End();
    }
Beispiel #16
0
 public virtual void DrawDLight(dlight_t light, Vector3 viewProj, Vector3 viewUp, Vector3 viewRight)
 {
     throw new NotImplementedException( );
 }
Beispiel #17
0
    public static void R_DrawViewModel()
    {
        if (r_drawviewmodel.value == 0)
        {
            return;
        }

        if (chase_active.value != 0)
        {
            return;
        }

        if (envmap)
        {
            return;
        }

        if (r_drawentities.value == 0)
        {
            return;
        }

        if (cl.HasItems(q_shared.IT_INVISIBILITY))
        {
            return;
        }

        if (cl.stats[q_shared.STAT_HEALTH] <= 0)
        {
            return;
        }

        currententity = cl.viewent;
        if (currententity.model == null)
        {
            return;
        }

        int j = R_LightPoint(ref currententity.origin);

        if (j < 24)
        {
            j = 24;             // allways give some light on gun
        }
        ambientlight = j;
        shadelight   = j;

        // add dynamic lights
        for (int lnum = 0; lnum < q_shared.MAX_DLIGHTS; lnum++)
        {
            dlight_t dl = cl_dlights[lnum];
            if (dl.radius == 0)
            {
                continue;
            }
            if (dl.die < cl.time)
            {
                continue;
            }

            Vector3 dist = currententity.origin - dl.origin;
            float   add  = dl.radius - dist.Length;
            if (add > 0)
            {
                ambientlight += add;
            }
        }

        // hack the depth range to prevent view model from poking into walls
        GL.DepthRange(gldepthmin, gldepthmin + 0.3f * (gldepthmax - gldepthmin));
        R_DrawAliasModel(currententity);
        GL.DepthRange(gldepthmin, gldepthmax);
    }
Beispiel #18
0
 public abstract void R_MarkLights(dlight_t light, Int32 bit, mnode_t node);
Beispiel #19
0
    public static void CL_RelinkEntities()
    {
        // determine partial update time
        float frac = CL_LerpPoint();

        cl_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 = cl_entities[i];
            if (ent.model == null)
            {
                // empty slot
                if (ent.forcelink)
                {
                    R_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 & q_shared.EF_ROTATE) != 0)
            {
                ent.angles.Y = bobjrotate;
            }

            if ((ent.effects & q_shared.EF_BRIGHTFIELD) != 0)
            {
                R_EntityParticles(ent);
            }

            if ((ent.effects & q_shared.EF_MUZZLEFLASH) != 0)
            {
                dlight_t dl = CL_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 + (Random() & 31);
                dl.minlight = 32;
                dl.die      = (float)cl.time + 0.1f;
            }
            if ((ent.effects & q_shared.EF_BRIGHTLIGHT) != 0)
            {
                dlight_t dl = CL_AllocDlight(i);
                dl.origin    = ent.origin;
                dl.origin.Z += 16;
                dl.radius    = 400 + (Random() & 31);
                dl.die       = (float)cl.time + 0.001f;
            }
            if ((ent.effects & q_shared.EF_DIMLIGHT) != 0)
            {
                dlight_t dl = CL_AllocDlight(i);
                dl.origin = ent.origin;
                dl.radius = 200 + (Random() & 31);
                dl.die    = (float)cl.time + 0.001f;
            }

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

            ent.forcelink = false;

            if (i == cl.viewentity && chase_active.value == 0)
            {
                continue;
            }

            if (cl_numvisedicts < q_shared.MAX_VISEDICTS)
            {
                cl_visedicts[cl_numvisedicts] = ent;
                cl_numvisedicts++;
            }
        }
    }