Exemple #1
0
        public virtual void R_RenderView(refdef_t fd)
        {
            if (r_norefresh.value != 0F)
            {
                return;
            }
            r_newrefdef = fd;
            if (r_newrefdef == null)
            {
                Com.Error(Defines.ERR_DROP, "R_RenderView: refdef_t fd is null");
            }

            if (r_worldmodel == null && (r_newrefdef.rdflags & Defines.RDF_NOWORLDMODEL) == 0)
            {
                Com.Error(Defines.ERR_DROP, "R_RenderView: NULL worldmodel");
            }
            if (r_speeds.value != 0F)
            {
                c_brush_polys = 0;
                c_alias_polys = 0;
            }

            R_PushDlights();
            if (gl_finish.value != 0F)
            {
                GL.Finish();
            }
            R_SetupFrame();
            R_SetFrustum();
            R_SetupGL();
            R_MarkLeaves();
            R_DrawWorld();
            R_DrawEntitiesOnList();
            R_RenderDlights();
            R_DrawParticles();
            R_DrawAlphaSurfaces();
            R_Flash();
            if (r_speeds.value != 0F)
            {
                VID.Printf(Defines.PRINT_ALL, "%4i wpoly %4i epoly %i tex %i lmaps\\n", c_brush_polys, c_alias_polys, c_visible_textures, c_visible_lightmaps);
            }
        }
Exemple #2
0
        private void TestMap()
        {
            if (refdef == null)
            {
                refdef               = new refdef_t();
                refdef.x             = 0;
                refdef.y             = 0;
                refdef.width         = viddef.GetWidth();
                refdef.height        = viddef.GetHeight();
                refdef.fov_x         = fov_x;
                refdef.fov_y         = CalcFov(fov_x, refdef.width - 10, refdef.height - 10);
                refdef.vieworg       = new float[] { 0, 0, 0 };
                refdef.viewangles[0] = 0;
                refdef.viewangles[1] = 90;
                refdef.viewangles[2] = 0;
                refdef.blend         = new float[] { 0F, 0F, 0F, 0F };
                refdef.areabits      = null;
                refdef.num_entities  = 0;
                refdef.entities      = null;
                lightstyle_t light = new lightstyle_t();
                light.rgb          = new float[] { 1F, 1F, 1F };
                light.white        = 3F;
                refdef.lightstyles = new lightstyle_t[Defines.MAX_LIGHTSTYLES];
                for (int i = 0; i < Defines.MAX_LIGHTSTYLES; i++)
                {
                    refdef.lightstyles[i]       = new lightstyle_t();
                    refdef.lightstyles[i].rgb   = new float[] { 1F, 1F, 1F };
                    refdef.lightstyles[i].white = 3F;
                }
            }

            refdef.time           = Time() * 0.001F;
            refdef.viewangles[0] += KBD.my * 0.1F;
            refdef.viewangles[1] -= KBD.mx * 0.1F;
            refdef.vieworg[0]     = 0;
            refdef.vieworg[1]     = -79;
            refdef.vieworg[2]     = -131;
            refdef.vieworg[0]    += 1F / 16;
            refdef.vieworg[1]    += 1F / 16;
            refdef.vieworg[2]    += 1F / 16;
            re.RenderFrame(refdef);
        }
Exemple #3
0
    static void V_CalcViewRoll()
    {
        refdef_t rdef = r_refdef;
        float    side = V_CalcRoll(ref cl_entities[cl.viewentity].angles, ref cl.velocity);

        rdef.viewangles.Z += side;

        if (v_dmg_time > 0)
        {
            rdef.viewangles.Z += v_dmg_time / v_kicktime.value * v_dmg_roll;
            rdef.viewangles.X += v_dmg_time / v_kicktime.value * v_dmg_pitch;
            v_dmg_time        -= (float)host_framtime;
        }

        if (cl.stats[q_shared.STAT_HEALTH] <= 0)
        {
            rdef.viewangles.Z = 80;     // dead view angle
            return;
        }
    }
Exemple #4
0
        // V_CalcViewRoll
        //
        // Roll is induced by movement and damage
        private static void CalcViewRoll()
        {
            client_state_t cl   = client.cl;
            refdef_t       rdef = render.RefDef;
            float          side = CalcRoll(ref client.ViewEntity.angles, ref cl.velocity);

            rdef.viewangles.Z += side;

            if (_DmgTime > 0)
            {
                rdef.viewangles.Z += _DmgTime / _KickTime.Value * _DmgRoll;
                rdef.viewangles.X += _DmgTime / _KickTime.Value * _DmgPitch;
                _DmgTime          -= (float)host.FrameTime;
            }

            if (cl.stats[QStats.STAT_HEALTH] <= 0)
            {
                rdef.viewangles.Z = 80; // dead view angle
                return;
            }
        }
    public static void SCR_TileClear()
    {
        refdef_t rdef = r_refdef;

        if (rdef.vrect.x > 0)
        {
            // left
            Draw_TileClear(0, 0, rdef.vrect.x, vid.height - sb_lines);
            // right
            Draw_TileClear(rdef.vrect.x + rdef.vrect.width, 0,
                           vid.width - rdef.vrect.x + rdef.vrect.width,
                           vid.height - sb_lines);
        }
        if (rdef.vrect.y > 0)
        {
            // top
            Draw_TileClear(rdef.vrect.x, 0, rdef.vrect.x + rdef.vrect.width, rdef.vrect.y);
            // bottom
            Draw_TileClear(rdef.vrect.x, rdef.vrect.y + rdef.vrect.height,
                           rdef.vrect.width, vid.height - sb_lines - (rdef.vrect.height + rdef.vrect.y));
        }
    }
Exemple #6
0
        private void TestParticles()
        {
            r_numparticles = 0;
            if (active_particles.Count == 0)
            {
                if (explode)
                {
                    Explosion(target);
                }
                else
                {
                    target = new float[] { 150 + Lib.Crand() * 80, Lib.Crand() * 40, Lib.Crand() * 40 };
                    RailTrail(new float[] { 30, -20, -20 }, target);
                }

                explode = !explode;
            }

            refdef_t refdef = new refdef_t();

            refdef.x      = viddef.GetWidth() / 2;
            refdef.y      = viddef.GetHeight() / 2 - 72;
            refdef.width  = 400;
            refdef.height = 400;
            refdef.fov_x  = 50;
            refdef.fov_y  = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height);
            refdef.time   = 1F * 0.001F;
            AnimateParticles();
            DrawString(refdef.x, refdef.y - 20, "active particles: " + r_numparticles);
            refdef.num_particles = r_numparticles;
            refdef.areabits      = null;
            refdef.num_entities  = 0;
            refdef.entities      = null;
            refdef.lightstyles   = null;
            refdef.rdflags       = Defines.RDF_NOWORLDMODEL;
            M_DrawTextBox((int)((refdef.x) * (320F / viddef.GetWidth()) - 8), (int)((viddef.GetHeight() / 2) * (240F / viddef.GetHeight()) - 77), refdef.width / 8, refdef.height / 8);
            refdef.height += 4;
            re.RenderFrame(refdef);
        }
Exemple #7
0
        // SCR_TileClear
        private static void TileClear()
        {
            refdef_t rdef = Render.RefDef;

            if (rdef.vrect.x > 0)
            {
                // left
                Drawer.TileClear(0, 0, rdef.vrect.x, _VidDef.height - Sbar.Lines);
                // right
                Drawer.TileClear(rdef.vrect.x + rdef.vrect.width, 0,
                                 _VidDef.width - rdef.vrect.x + rdef.vrect.width,
                                 _VidDef.height - Sbar.Lines);
            }
            if (rdef.vrect.y > 0)
            {
                // top
                Drawer.TileClear(rdef.vrect.x, 0, rdef.vrect.x + rdef.vrect.width, rdef.vrect.y);
                // bottom
                Drawer.TileClear(rdef.vrect.x, rdef.vrect.y + rdef.vrect.height,
                                 rdef.vrect.width, _VidDef.height - Sbar.Lines - (rdef.vrect.height + rdef.vrect.y));
            }
        }
Exemple #8
0
        private void TestBeam()
        {
            refdef_t refdef = new refdef_t();

            refdef.x      = viddef.GetWidth() / 2;
            refdef.y      = viddef.GetHeight() / 2 - 72;
            refdef.width  = 144 * 2;
            refdef.height = 168 * 2;
            refdef.fov_x  = 40;
            refdef.fov_y  = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height);
            refdef.time   = 1F * 0.001F;
            entity_t entity = new entity_t();

            DrawString(refdef.x, refdef.y - 20, "Beam Test");
            entity.flags        = Defines.RF_BEAM;
            entity.origin[0]    = 200;
            entity.origin[1]    = 0 + (float)(80 * Math.Sin(4 * Math.ToRadians(framecount)));
            entity.origin[2]    = 20 + (float)(40 * Math.Cos(4 * Math.ToRadians(framecount)));
            entity.oldorigin[0] = 20;
            entity.oldorigin[1] = 0;
            entity.oldorigin[2] = -20;
            entity.frame        = 3;
            entity.oldframe     = 0;
            entity.backlerp     = 0F;
            entity.alpha        = 0.6F;
            int[] color = new[] { 0xd0, 0xd1, 0xe0, 0xb0 };
            entity.skinnum      = color[framecount / 2 % 4];
            entity.model        = null;
            refdef.areabits     = null;
            refdef.num_entities = 1;
            refdef.entities     = new entity_t[] { entity };
            refdef.lightstyles  = null;
            refdef.rdflags      = Defines.RDF_NOWORLDMODEL;
            M_DrawTextBox((int)((refdef.x) * (320F / viddef.GetWidth()) - 8), (int)((viddef.GetHeight() / 2) * (240F / viddef.GetHeight()) - 77), refdef.width / 8, refdef.height / 8);
            refdef.height += 4;
            re.RenderFrame(refdef);
        }
 public void RenderFrame(refdef_t fd)
 {
     this.impl.R_RenderFrame(fd);
 }
 public void RenderFrame(refdef_t fd)
 {
 }
Exemple #11
0
        /// <summary>
        /// CalcGunAngle
        /// </summary>
        private static void CalcGunAngle()
        {
            refdef_t rdef  = render.RefDef;
            float    yaw   = rdef.viewangles.Y;
            float    pitch = -rdef.viewangles.X;

            yaw = AngleDelta(yaw - rdef.viewangles.Y) * 0.4f;
            if (yaw > 10)
            {
                yaw = 10;
            }
            if (yaw < -10)
            {
                yaw = -10;
            }
            pitch = AngleDelta(-pitch - rdef.viewangles.X) * 0.4f;
            if (pitch > 10)
            {
                pitch = 10;
            }
            if (pitch < -10)
            {
                pitch = -10;
            }
            float move = (float)host.FrameTime * 20;

            if (yaw > _OldYaw)
            {
                if (_OldYaw + move < yaw)
                {
                    yaw = _OldYaw + move;
                }
            }
            else
            {
                if (_OldYaw - move > yaw)
                {
                    yaw = _OldYaw - move;
                }
            }

            if (pitch > _OldPitch)
            {
                if (_OldPitch + move < pitch)
                {
                    pitch = _OldPitch + move;
                }
            }
            else
            {
                if (_OldPitch - move > pitch)
                {
                    pitch = _OldPitch - move;
                }
            }

            _OldYaw   = yaw;
            _OldPitch = pitch;

            client_state_t cl = client.cl;

            cl.viewent.angles.Y = rdef.viewangles.Y + yaw;
            cl.viewent.angles.X = -(rdef.viewangles.X + pitch);

            float idleScale = _IdleScale.Value;

            cl.viewent.angles.Z -= (float)(idleScale * Math.Sin(cl.time * _IRollCycle.Value) * _IRollLevel.Value);
            cl.viewent.angles.X -= (float)(idleScale * Math.Sin(cl.time * _IPitchCycle.Value) * _IPitchLevel.Value);
            cl.viewent.angles.Y -= (float)(idleScale * Math.Sin(cl.time * _IYawCycle.Value) * _IYawLevel.Value);
        }
Exemple #12
0
        /// <summary>
        /// V_RenderView
        /// The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
        /// the entity origin, so any view position inside that will be valid
        /// </summary>
        public static void RenderView()
        {
            if (Con.ForcedUp)
            {
                return;
            }

            // don't allow cheats in multiplayer
            if (client.cl.maxclients > 1)
            {
                cvar.Set("scr_ofsx", "0");
                cvar.Set("scr_ofsy", "0");
                cvar.Set("scr_ofsz", "0");
            }

            if (client.cl.intermission > 0)
            {
                // intermission / finale rendering
                CalcIntermissionRefDef();
            }
            else if (!client.cl.paused)
            {
                CalcRefDef();
            }

            render.PushDlights();

            if (_LcdX.Value != 0)
            {
                //
                // render two interleaved views
                //
                viddef_t vid  = Scr.vid;
                refdef_t rdef = render.RefDef;

                vid.rowbytes <<= 1;
                vid.aspect    *= 0.5f;

                rdef.viewangles.Y -= _LcdYaw.Value;
                rdef.vieworg      -= _Right * _LcdX.Value;

                render.RenderView();

                // ???????? vid.buffer += vid.rowbytes>>1;

                render.PushDlights();

                rdef.viewangles.Y += _LcdYaw.Value * 2;
                rdef.vieworg      += _Right * _LcdX.Value * 2;

                render.RenderView();

                // ????????? vid.buffer -= vid.rowbytes>>1;

                rdef.vrect.height <<= 1;

                vid.rowbytes >>= 1;
                vid.aspect    *= 2;
            }
            else
            {
                render.RenderView();
            }
        }
Exemple #13
0
        // V_CalcRefdef
        private static void CalcRefDef()
        {
            DriftPitch();

            // ent is the player model (visible when out of body)
            entity_t ent = client.ViewEntity;
            // view is the weapon model (only visible from inside body)
            entity_t view = client.ViewEnt;

            // transform the view offset by the model's matrix to get the offset from
            // model origin for the view
            ent.angles.Y = client.cl.viewangles.Y;      // the model should face the view dir
            ent.angles.X = -client.cl.viewangles.X;     // the model should face the view dir

            float bob = CalcBob();

            refdef_t       rdef = render.RefDef;
            client_state_t cl   = client.cl;

            // refresh position
            rdef.vieworg    = ent.origin;
            rdef.vieworg.Z += cl.viewheight + bob;

            // never let it sit exactly on a node line, because a water plane can
            // dissapear when viewed with the eye exactly on it.
            // the server protocol only specifies to 1/16 pixel, so add 1/32 in each axis
            rdef.vieworg   += SmallOffset;
            rdef.viewangles = cl.viewangles;

            CalcViewRoll();
            AddIdle(_IdleScale.Value);

            // offsets
            Vector3 angles = ent.angles;

            angles.X = -angles.X; // because entity pitches are actually backward

            Vector3 forward, right, up;

            mathlib.AngleVectors(ref angles, out forward, out right, out up);

            rdef.vieworg += forward * _ScrOfsX.Value + right * _ScrOfsY.Value + up * _ScrOfsZ.Value;

            BoundOffsets();

            // set up gun position
            view.angles = cl.viewangles;

            CalcGunAngle();

            view.origin    = ent.origin;
            view.origin.Z += cl.viewheight;
            view.origin   += forward * bob * 0.4f;
            view.origin.Z += bob;

            // fudge position around to keep amount of weapon visible
            // roughly equal with different FOV
            float viewSize = Scr.ViewSize.Value; // scr_viewsize

            if (viewSize == 110)
            {
                view.origin.Z += 1;
            }
            else if (viewSize == 100)
            {
                view.origin.Z += 2;
            }
            else if (viewSize == 90)
            {
                view.origin.Z += 1;
            }
            else if (viewSize == 80)
            {
                view.origin.Z += 0.5f;
            }

            view.model    = cl.model_precache[cl.stats[QStats.STAT_WEAPON]];
            view.frame    = cl.stats[QStats.STAT_WEAPONFRAME];
            view.colormap = Scr.vid.colormap;

            // set up the refresh position
            rdef.viewangles += cl.punchangle;

            // smooth out stair step ups
            if (cl.onground && ent.origin.Z - _OldZ > 0)
            {
                float steptime = (float)(cl.time - cl.oldtime);
                if (steptime < 0)
                {
                    steptime = 0;
                }

                _OldZ += steptime * 80;
                if (_OldZ > ent.origin.Z)
                {
                    _OldZ = ent.origin.Z;
                }
                if (ent.origin.Z - _OldZ > 12)
                {
                    _OldZ = ent.origin.Z - 12;
                }
                rdef.vieworg.Z += _OldZ - ent.origin.Z;
                view.origin.Z  += _OldZ - ent.origin.Z;
            }
            else
            {
                _OldZ = ent.origin.Z;
            }

            if (chase.IsActive)
            {
                chase.Update();
            }
        }
Exemple #14
0
        private void RunTest()
        {
            if (refdef == null)
            {
                refdef            = new refdef_t();
                refdef.x          = 0;
                refdef.y          = 0;
                refdef.width      = viddef.GetWidth();
                refdef.height     = viddef.GetHeight();
                refdef.fov_x      = (Globals.fov == null) ? this.fov_x : Globals.fov.value;
                refdef.fov_x      = this.fov_x;
                refdef.fov_y      = Math3D.CalcFov(refdef.fov_x, refdef.width, refdef.height);
                refdef.vieworg    = new float[] { 140, -140, 50 };
                refdef.viewangles = new float[] { 0, 0, 0 };
                refdef.blend      = new float[] { 0F, 0F, 0F, 0F };
                refdef.areabits   = null;
                ent = new entity_t();
                model_t weapon     = re.RegisterModel("models/monsters/soldier/tris.md2");
                image_t weaponSkin = re.RegisterSkin("models/monsters/soldier/skin.pcx");
                ent.model  = weapon;
                ent.skin   = weaponSkin;
                ent.origin = new float[] { -60, 80, 25 };
                Math3D.VectorCopy(ent.origin, ent.oldorigin);
                ent.angles          = new float[] { 0, 300, 0 };
                refdef.entities     = new entity_t[] { ent };
                refdef.num_entities = refdef.entities.Length;
                lightstyle_t light = new lightstyle_t();
                light.rgb          = new float[] { 1F, 1F, 1F };
                light.white        = 3F;
                refdef.lightstyles = new lightstyle_t[Defines.MAX_LIGHTSTYLES];
                for (int i = 0; i < Defines.MAX_LIGHTSTYLES; i++)
                {
                    refdef.lightstyles[i]       = new lightstyle_t();
                    refdef.lightstyles[i].rgb   = new float[] { 1F, 1F, 1F };
                    refdef.lightstyles[i].white = 3F;
                }

                refdef.viewangles[1] = 130;
                refdef.time          = Time() * 0.001F;
            }

            refdef.viewangles[0] += KBD.my * 0.1F;
            refdef.viewangles[1] -= KBD.mx * 0.1F;
            float dt = Time() * 0.001F - refdef.time;

            if (movePlayer != 0)
            {
                float velocity = 150F * dt;
                Math3D.AngleVectors(refdef.viewangles, vpn, vright, vup);
                if ((movePlayer & FORWARD_MASK) != 0)
                {
                    Math3D.VectorMA(refdef.vieworg, -velocity, vpn, refdef.vieworg);
                }
                if ((movePlayer & BACKWARD_MASK) != 0)
                {
                    Math3D.VectorMA(refdef.vieworg, velocity, vpn, refdef.vieworg);
                }
                if ((movePlayer & LEFT_MASK) != 0)
                {
                    Math3D.VectorMA(refdef.vieworg, velocity, vright, refdef.vieworg);
                }
                if ((movePlayer & RIGHT_MASK) != 0)
                {
                    Math3D.VectorMA(refdef.vieworg, -velocity, vright, refdef.vieworg);
                }
                refdef.vieworg[0] += 1F / 16;
                refdef.vieworg[1] += 1F / 16;
                refdef.vieworg[2] += 1F / 16;
            }

            refdef.time    = Time() * 0.001F;
            r_numparticles = 0;
            float[] diff = new float[] { 0, 0, 0 };
            Math3D.VectorSubtract(refdef.vieworg, ent.origin, diff);
            if (Math3D.VectorLength(diff) < 250 && active_particles.Size() == 0)
            {
                RailTrail(ent.origin, refdef.vieworg);
            }
            else
            {
                if (active_particles.Size() > 0)
                {
                    ent.frame = (int)((Time() * 0.013F) % 15);
                    Math3D.VectorNormalize(diff);
                    Math3D.Vectoangles(diff, ent.angles);
                    AnimateParticles();
                    refdef.num_particles = r_numparticles;
                }
                else
                {
                    ent.frame            = 0;
                    refdef.num_particles = 0;
                }
            }

            refdef.num_dlights = 0;
            re.RenderFrame(refdef);
        }
Exemple #15
0
        public override void Setup3DScene(bool cull, refdef_t renderDef, bool isEnvMap)
        {
            //
            // set up viewpoint
            //
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity( );
            var x  = renderDef.vrect.x * this.Desc.ActualWidth / this.Desc.Width;
            var x2 = (renderDef.vrect.x + renderDef.vrect.width) * this.Desc.ActualWidth / this.Desc.Width;
            var y  = (this.Desc.Height - renderDef.vrect.y) * this.Desc.ActualHeight / this.Desc.Height;
            var y2 = (this.Desc.Height - (renderDef.vrect.y + renderDef.vrect.height)) * this.Desc.ActualHeight / this.Desc.Height;

            // fudge around because of frac screen scale
            if (x > 0)
            {
                x--;
            }
            if (x2 < this.Desc.ActualWidth)
            {
                x2++;
            }
            if (y2 < 0)
            {
                y2--;
            }
            if (y < this.Desc.ActualHeight)
            {
                y++;
            }

            var w = x2 - x;
            var h = y - y2;

            if (isEnvMap)
            {
                x = y2 = 0;
                w = h = 256;
            }

            GL.Viewport(x, y2, w, h);

            var screenaspect = ( float )renderDef.vrect.width / renderDef.vrect.height;

            this.MYgluPerspective(renderDef.fov_y, screenaspect, 4, 4096);

            GL.CullFace(CullFaceMode.Front);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity( );

            GL.Rotate(-90f, 1, 0, 0);       // put Z going up
            GL.Rotate(90f, 0, 0, 1);        // put Z going up
            GL.Rotate(-renderDef.viewangles.Z, 1, 0, 0);
            GL.Rotate(-renderDef.viewangles.X, 0, 1, 0);
            GL.Rotate(-renderDef.viewangles.Y, 0, 0, 1);
            GL.Translate(-renderDef.vieworg.X, -renderDef.vieworg.Y, -renderDef.vieworg.Z);

            GL.GetFloat(GetPName.ModelviewMatrix, out Matrix4 m);
            this.WorldMatrix = new(
                m.M11, m.M12, m.M13, m.M14,
                m.M21, m.M22, m.M23, m.M24,
                m.M31, m.M32, m.M33, m.M34,
                m.M41, m.M42, m.M43, m.M44
                );

            //
            // set drawing parms
            //
            if (cull)
            {
                GL.Enable(EnableCap.CullFace);
            }
            else
            {
                GL.Disable(EnableCap.CullFace);
            }

            GL.Disable(EnableCap.Blend);
            GL.Disable(EnableCap.AlphaTest);
            GL.Enable(EnableCap.DepthTest);
        }
Exemple #16
0
 public virtual void RenderFrame(refdef_t fd)
 {
 }
Exemple #17
0
        // SCR_CalcRefdef
        //
        // Must be called whenever vid changes
        // Internal use only
        private static void CalcRefdef()
        {
            Scr.FullUpdate        = 0; // force a background redraw
            _VidDef.recalc_refdef = false;

            // force the status bar to redraw
            Sbar.Changed();

            // bound viewsize
            if (_ViewSize.Value < 30)
            {
                Cvar.Set("viewsize", "30");
            }
            if (_ViewSize.Value > 120)
            {
                Cvar.Set("viewsize", "120");
            }

            // bound field of view
            if (_Fov.Value < 10)
            {
                Cvar.Set("fov", "10");
            }
            if (_Fov.Value > 170)
            {
                Cvar.Set("fov", "170");
            }

            // intermission is always full screen
            float size;

            if (Client.cl.intermission > 0)
            {
                size = 120;
            }
            else
            {
                size = _ViewSize.Value;
            }

            if (size >= 120)
            {
                Sbar.Lines = 0; // no status bar at all
            }
            else if (size >= 110)
            {
                Sbar.Lines = 24; // no inventory
            }
            else
            {
                Sbar.Lines = 24 + 16 + 8;
            }

            bool full = false;

            if (_ViewSize.Value >= 100.0)
            {
                full = true;
                size = 100.0f;
            }
            else
            {
                size = _ViewSize.Value;
            }

            if (Client.cl.intermission > 0)
            {
                full       = true;
                size       = 100;
                Sbar.Lines = 0;
            }
            size /= 100.0f;

            int h = _VidDef.height - Sbar.Lines;

            refdef_t rdef = Render.RefDef;

            rdef.vrect.width = (int)(_VidDef.width * size);
            if (rdef.vrect.width < 96)
            {
                size             = 96.0f / rdef.vrect.width;
                rdef.vrect.width = 96;  // min for icons
            }

            rdef.vrect.height = (int)(_VidDef.height * size);
            if (rdef.vrect.height > _VidDef.height - Sbar.Lines)
            {
                rdef.vrect.height = _VidDef.height - Sbar.Lines;
            }
            if (rdef.vrect.height > _VidDef.height)
            {
                rdef.vrect.height = _VidDef.height;
            }
            rdef.vrect.x = (_VidDef.width - rdef.vrect.width) / 2;
            if (full)
            {
                rdef.vrect.y = 0;
            }
            else
            {
                rdef.vrect.y = (h - rdef.vrect.height) / 2;
            }

            rdef.fov_x = _Fov.Value;
            rdef.fov_y = CalcFov(rdef.fov_x, rdef.vrect.width, rdef.vrect.height);

            _VRect = rdef.vrect;
        }
Exemple #18
0
 public override void R_RenderFrame(refdef_t fd)
 {
     R_RenderView(fd);
     R_SetLightLevel();
     R_SetGL2D();
 }
    public static void SCR_CalcRefdef()
    {
        scr_fullupdate    = 0; // force a background redraw
        vid.recalc_refdef = false;

        // force the status bar to redraw
        Sbar_Changed();

        // bound viewsize
        if (scr_viewsize.value < 30)
        {
            Cvar.Cvar_Set("viewsize", "30");
        }
        if (scr_viewsize.value > 120)
        {
            Cvar.Cvar_Set("viewsize", "120");
        }

        // bound field of view
        if (scr_fov.value < 10)
        {
            Cvar.Cvar_Set("fov", "10");
        }
        if (scr_fov.value > 170)
        {
            Cvar.Cvar_Set("fov", "170");
        }

        // intermission is always full screen
        float size;

        if (cl.intermission > 0)
        {
            size = 120;
        }
        else
        {
            size = scr_viewsize.value;
        }

        if (size >= 120)
        {
            sb_lines = 0; // no status bar at all
        }
        else if (size >= 110)
        {
            sb_lines = 24; // no inventory
        }
        else
        {
            sb_lines = 24 + 16 + 8;
        }

        bool full = false;

        if (scr_viewsize.value >= 100.0)
        {
            full = true;
            size = 100.0f;
        }
        else
        {
            size = scr_viewsize.value;
        }

        if (cl.intermission > 0)
        {
            full     = true;
            size     = 100;
            sb_lines = 0;
        }
        size /= 100.0f;

        int h = vid.height - sb_lines;

        refdef_t rdef = r_refdef;

        rdef.vrect.width = (int)(vid.width * size);
        if (rdef.vrect.width < 96)
        {
            size             = 96.0f / rdef.vrect.width;
            rdef.vrect.width = 96;  // min for icons
        }

        rdef.vrect.height = (int)(vid.height * size);
        if (rdef.vrect.height > vid.height - sb_lines)
        {
            rdef.vrect.height = vid.height - sb_lines;
        }
        if (rdef.vrect.height > vid.height)
        {
            rdef.vrect.height = vid.height;
        }
        rdef.vrect.x = (vid.width - rdef.vrect.width) / 2;
        if (full)
        {
            rdef.vrect.y = 0;
        }
        else
        {
            rdef.vrect.y = (h - rdef.vrect.height) / 2;
        }

        rdef.fov_x = scr_fov.value;
        rdef.fov_y = CalcFov(rdef.fov_x, rdef.vrect.width, rdef.vrect.height);

        scr_vrect = rdef.vrect;
    }
Exemple #20
0
    static void CalcGunAngle()
    {
        refdef_t rdef  = r_refdef;
        float    yaw   = rdef.viewangles.Y;
        float    pitch = -rdef.viewangles.X;

        yaw = angledelta(yaw - rdef.viewangles.Y) * 0.4f;
        if (yaw > 10)
        {
            yaw = 10;
        }
        if (yaw < -10)
        {
            yaw = -10;
        }
        pitch = angledelta(-pitch - rdef.viewangles.X) * 0.4f;
        if (pitch > 10)
        {
            pitch = 10;
        }
        if (pitch < -10)
        {
            pitch = -10;
        }
        float move = (float)host_framtime * 20;

        if (yaw > _OldYaw)
        {
            if (_OldYaw + move < yaw)
            {
                yaw = _OldYaw + move;
            }
        }
        else
        {
            if (_OldYaw - move > yaw)
            {
                yaw = _OldYaw - move;
            }
        }

        if (pitch > _OldPitch)
        {
            if (_OldPitch + move < pitch)
            {
                pitch = _OldPitch + move;
            }
        }
        else
        {
            if (_OldPitch - move > pitch)
            {
                pitch = _OldPitch - move;
            }
        }

        _OldYaw   = yaw;
        _OldPitch = pitch;

        cl.viewent.angles.Y = rdef.viewangles.Y + yaw;
        cl.viewent.angles.X = -(rdef.viewangles.X + pitch);

        float idleScale = v_idlescale.value;

        cl.viewent.angles.Z -= (float)(idleScale * Math.Sin(cl.time * v_iroll_cycle.value) * v_iroll_level.value);
        cl.viewent.angles.X -= (float)(idleScale * Math.Sin(cl.time * v_ipitch_cycle.value) * v_ipitch_level.value);
        cl.viewent.angles.Y -= (float)(idleScale * Math.Sin(cl.time * v_iyaw_cycle.value) * v_iyaw_level.value);
    }
Exemple #21
0
 public abstract void R_RenderFrame(refdef_t fd);
Exemple #22
0
    public static void V_RenderView()
    {
        if (con_forcedup)
        {
            return;
        }

        // don't allow cheats in multiplayer
        if (cl.maxclients > 1)
        {
            Cvar.Cvar_Set("scr_ofsx", "0");
            Cvar.Cvar_Set("scr_ofsy", "0");
            Cvar.Cvar_Set("scr_ofsz", "0");
        }

        if (cl.intermission > 0)
        {
            // intermission / finale rendering
            V_CalcIntermissionRefdef();
        }
        else if (!cl.paused)
        {
            V_CalcRefdef();
        }

        R_PushDlights();

        if (lcd_x.value != 0)
        {
            //
            // render two interleaved views
            //
            refdef_t rdef = r_refdef;

            vid.rowbytes <<= 1;
            vid.aspect    *= 0.5f;

            rdef.viewangles.Y -= lcd_yaw.value;
            rdef.vieworg      -= right * lcd_x.value;

            R_RenderView();

            // ???????? vid.buffer += vid.rowbytes>>1;

            R_PushDlights();

            rdef.viewangles.Y += lcd_yaw.value * 2;
            rdef.vieworg      += right * lcd_x.value * 2;

            R_RenderView();

            // ????????? vid.buffer -= vid.rowbytes>>1;

            rdef.vrect.height <<= 1;

            vid.rowbytes >>= 1;
            vid.aspect    *= 2;
        }
        else
        {
            R_RenderView();
        }
    }