示例#1
0
        /*
         * =================
         *
         * CL_PrepRefresh
         *
         * Call before entering a new level, or after changing dlls
         * =================
         */
        public static void PrepRefresh()
        {
            string mapname;
            int    i;
            string name;
            float  rotate;
            var    axis = new float[3];

            if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].Length) == 0)
            {
                return;                 // no map loaded
            }
            SCR.AddDirtyPoint(0, 0);
            SCR.AddDirtyPoint(Globals.viddef.getWidth() - 1, Globals.viddef.getHeight() - 1);

            // let the render dll load the map
            mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].Substring(5, i - 9);             // skip "maps/"

            // cut off ".bsp"

            // register models, pics, and skins
            Com.Printf("Map: " + mapname + "\r");
            SCR.UpdateScreen();
            Globals.re.BeginRegistration(mapname);
            Com.Printf("                                     \r");

            // precache status bar pics
            Com.Printf("pics\r");
            SCR.UpdateScreen();
            SCR.TouchPics();
            Com.Printf("                                     \r");
            CL_tent.RegisterTEntModels();
            CL_view.num_cl_weaponmodels = 1;
            CL_view.cl_weaponmodels[0]  = "weapon.md2";

            for (i = 1; i < Defines.MAX_MODELS && Globals.cl.configstrings[Defines.CS_MODELS + i].Length != 0; i++)
            {
                name = new(Globals.cl.configstrings[Defines.CS_MODELS + i]);

                if (name.Length > 37)
                {
                    name = name[..36];
示例#2
0
        public static void PrepRefresh()
        {
            string mapname;
            int    i;
            string name;
            float  rotate;

            float[] axis = new float[3];
            if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].Length) == 0)
            {
                return;
            }
            SCR.AddDirtyPoint(0, 0);
            SCR.AddDirtyPoint(Globals.viddef.GetWidth() - 1, Globals.viddef.GetHeight() - 1);
            mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].Substring(5, i - 4);
            Com.Printf("Map: " + mapname + "\\r");
            SCR.UpdateScreen();
            Globals.re.BeginRegistration(mapname);
            Com.Printf("                                     \\r");
            Com.Printf("pics\\r");
            SCR.UpdateScreen();
            SCR.TouchPics();
            Com.Printf("                                     \\r");
            CL_tent.RegisterTEntModels();
            num_cl_weaponmodels = 1;
            cl_weaponmodels[0]  = "weapon.md2";
            for (i = 1; i < Defines.MAX_MODELS && Globals.cl.configstrings[Defines.CS_MODELS + i].Length != 0; i++)
            {
                name = new string (Globals.cl.configstrings[Defines.CS_MODELS + i]);
                if (name.Length > 37)
                {
                    name = name.Substring(0, 36);
                }
                if (name[0] != '*')
                {
                    Com.Printf(name + "\\r");
                }
                SCR.UpdateScreen();
                CoreSys.SendKeyEvents();
                if (name[0] == '#')
                {
                    if (num_cl_weaponmodels < Defines.MAX_CLIENTWEAPONMODELS)
                    {
                        cl_weaponmodels[num_cl_weaponmodels] = Globals.cl.configstrings[Defines.CS_MODELS + i].Substring(1);
                        num_cl_weaponmodels++;
                    }
                }
                else
                {
                    Globals.cl.model_draw[i] = Globals.re.RegisterModel(Globals.cl.configstrings[Defines.CS_MODELS + i]);
                    if (name[0] == '*')
                    {
                        Globals.cl.model_clip[i] = CM.InlineModel(Globals.cl.configstrings[Defines.CS_MODELS + i]);
                    }
                    else
                    {
                        Globals.cl.model_clip[i] = null;
                    }
                }

                if (name[0] != '*')
                {
                    Com.Printf("                                     \\r");
                }
            }

            Com.Printf("images\\r");
            SCR.UpdateScreen();
            for (i = 1; i < Defines.MAX_IMAGES && Globals.cl.configstrings[Defines.CS_IMAGES + i].Length > 0; i++)
            {
                Globals.cl.image_precache[i] = Globals.re.RegisterPic(Globals.cl.configstrings[Defines.CS_IMAGES + i]);
                CoreSys.SendKeyEvents();
            }

            Com.Printf("                                     \\r");
            for (i = 0; i < Defines.MAX_CLIENTS; i++)
            {
                if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i].Length == 0)
                {
                    continue;
                }
                Com.Printf("client " + i + '\\');
                SCR.UpdateScreen();
                CoreSys.SendKeyEvents();
                CL_parse.ParseClientinfo(i);
                Com.Printf("                                     \\r");
            }

            CL_parse.LoadClientinfo(Globals.cl.baseclientinfo, "unnamed\\\\male/grunt");
            Com.Printf("sky\\r");
            SCR.UpdateScreen();
            rotate = float.Parse(Globals.cl.configstrings[Defines.CS_SKYROTATE]);
            StringTokenizer st = new StringTokenizer(Globals.cl.configstrings[Defines.CS_SKYAXIS]);

            st.MoveNext();
            axis[0] = float.Parse(st.Current);
            st.MoveNext();
            axis[1] = float.Parse(st.Current);
            st.MoveNext();
            axis[2] = float.Parse(st.Current);
            Globals.re.SetSky(Globals.cl.configstrings[Defines.CS_SKY], rotate, axis);
            Com.Printf("                                     \\r");
            Globals.re.EndRegistration();
            Con.ClearNotify();
            SCR.UpdateScreen();
            Globals.cl.refresh_prepped = true;
            Globals.cl.force_refdef    = true;
        }
示例#3
0
        /*
         * ================== V_RenderView
         *
         * ==================
         */
        public static void RenderView(float stereo_separation)
        {
            //		extern int entitycmpfnc( const entity_t *, const entity_t * );
            //
            if (Globals.cls.state != Defines.ca_active)
            {
                return;
            }

            if (!Globals.cl.refresh_prepped)
            {
                return;                 // still loading
            }
            if (Globals.cl_timedemo.value != 0.0f)
            {
                if (Globals.cl.timedemo_start == 0)
                {
                    Globals.cl.timedemo_start = Timer.Milliseconds();
                }

                Globals.cl.timedemo_frames++;
            }

            // an invalid frame will just use the exact previous refdef
            // we can't use the old frame if the video mode has changed, though...
            if (Globals.cl.frame.valid && (Globals.cl.force_refdef || Globals.cl_paused.value == 0.0f))
            {
                Globals.cl.force_refdef = false;
                V.ClearScene();

                // build a refresh entity list and calc cl.sim*
                // this also calls CL_CalcViewValues which loads
                // v_forward, etc.
                CL_ents.AddEntities();

                if (V.cl_testparticles.value != 0.0f)
                {
                    V.TestParticles();
                }

                if (V.cl_testentities.value != 0.0f)
                {
                    V.TestEntities();
                }

                if (V.cl_testlights.value != 0.0f)
                {
                    V.TestLights();
                }

                if (V.cl_testblend.value != 0.0f)
                {
                    Globals.cl.refdef.blend[0] = 1.0f;
                    Globals.cl.refdef.blend[1] = 0.5f;
                    Globals.cl.refdef.blend[2] = 0.25f;
                    Globals.cl.refdef.blend[3] = 0.5f;
                }

                // offset vieworg appropriately if we're doing stereo separation
                if (stereo_separation != 0)
                {
                    var tmp = new float[3];
                    Math3D.VectorScale(Globals.cl.v_right, stereo_separation, tmp);
                    Math3D.VectorAdd(Globals.cl.refdef.vieworg, tmp, Globals.cl.refdef.vieworg);
                }

                // 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/8 pixel, so add 1/16 in
                // each axis
                Globals.cl.refdef.vieworg[0] += 1.0f / 16;
                Globals.cl.refdef.vieworg[1] += 1.0f / 16;
                Globals.cl.refdef.vieworg[2] += 1.0f / 16;
                Globals.cl.refdef.x           = Globals.scr_vrect.x;
                Globals.cl.refdef.y           = Globals.scr_vrect.y;
                Globals.cl.refdef.width       = Globals.scr_vrect.width;
                Globals.cl.refdef.height      = Globals.scr_vrect.height;
                Globals.cl.refdef.fov_y       = Math3D.CalcFov(Globals.cl.refdef.fov_x, Globals.cl.refdef.width, Globals.cl.refdef.height);
                Globals.cl.refdef.time        = Globals.cl.time * 0.001f;
                Globals.cl.refdef.areabits    = Globals.cl.frame.areabits;

                if (Globals.cl_add_entities.value == 0.0f)
                {
                    V.r_numentities = 0;
                }

                if (Globals.cl_add_particles.value == 0.0f)
                {
                    V.r_numparticles = 0;
                }

                if (Globals.cl_add_lights.value == 0.0f)
                {
                    V.r_numdlights = 0;
                }

                if (Globals.cl_add_blend.value == 0)
                {
                    Math3D.VectorClear(Globals.cl.refdef.blend);
                }

                Globals.cl.refdef.num_entities  = V.r_numentities;
                Globals.cl.refdef.entities      = V.r_entities;
                Globals.cl.refdef.num_particles = V.r_numparticles;
                Globals.cl.refdef.num_dlights   = V.r_numdlights;
                Globals.cl.refdef.dlights       = V.r_dlights;
                Globals.cl.refdef.lightstyles   = V.r_lightstyles;
                Globals.cl.refdef.rdflags       = Globals.cl.frame.playerstate.rdflags;
            }

            Globals.re.RenderFrame(Globals.cl.refdef);

            if (V.cl_stats.value != 0.0f)
            {
                Com.Printf("ent:%i  lt:%i  part:%i\n", V.r_numentities, V.r_numdlights, V.r_numparticles);
            }

            if (Globals.log_stats.value != 0.0f && Globals.log_stats_file != null)
            {
                try
                {
                    Globals.log_stats_file.Write(V.r_numentities + "," + V.r_numdlights + "," + V.r_numparticles);
                }
                catch (Exception)
                {
                }
            }

            SCR.AddDirtyPoint(Globals.scr_vrect.x, Globals.scr_vrect.y);
            SCR.AddDirtyPoint(Globals.scr_vrect.x + Globals.scr_vrect.width - 1, Globals.scr_vrect.y + Globals.scr_vrect.height - 1);
            SCR.DrawCrosshair();
        }
示例#4
0
文件: V.cs 项目: optimus-code/Q2Sharp
        public static void RenderView(Single stereo_separation)
        {
            if (cls.state != ca_active)
            {
                return;
            }
            if (!cl.refresh_prepped)
            {
                return;
            }
            if (cl_timedemo.value != 0F)
            {
                if (cl.timedemo_start == 0)
                {
                    cl.timedemo_start = Timer.Milliseconds();
                }
                cl.timedemo_frames++;
            }

            if (cl.frame.valid && (cl.force_refdef || cl_paused.value == 0F))
            {
                cl.force_refdef = false;
                V.ClearScene();
                CL_ents.AddEntities();
                if (cl_testparticles.value != 0F)
                {
                    TestParticles();
                }
                if (cl_testentities.value != 0F)
                {
                    TestEntities();
                }
                if (cl_testlights.value != 0F)
                {
                    TestLights();
                }
                if (cl_testblend.value != 0F)
                {
                    cl.refdef.blend[0] = 1F;
                    cl.refdef.blend[1] = 0.5F;
                    cl.refdef.blend[2] = 0.25F;
                    cl.refdef.blend[3] = 0.5F;
                }

                if (stereo_separation != 0)
                {
                    Single[] tmp = new Single[3];
                    Math3D.VectorScale(cl.v_right, stereo_separation, tmp);
                    Math3D.VectorAdd(cl.refdef.vieworg, tmp, cl.refdef.vieworg);
                }

                cl.refdef.vieworg[0] += 1 / 16;
                cl.refdef.vieworg[1] += 1 / 16;
                cl.refdef.vieworg[2] += 1 / 16;
                cl.refdef.x           = scr_vrect.x;
                cl.refdef.y           = scr_vrect.y;
                cl.refdef.width       = scr_vrect.width;
                cl.refdef.height      = scr_vrect.height;
                cl.refdef.fov_y       = Math3D.CalcFov(cl.refdef.fov_x, cl.refdef.width, cl.refdef.height);
                cl.refdef.time        = cl.time * 0.001F;
                cl.refdef.areabits    = cl.frame.areabits;
                if (cl_add_entities.value == 0F)
                {
                    r_numentities = 0;
                }
                if (cl_add_particles.value == 0F)
                {
                    r_numparticles = 0;
                }
                if (cl_add_lights.value == 0F)
                {
                    r_numdlights = 0;
                }
                if (cl_add_blend.value == 0)
                {
                    Math3D.VectorClear(cl.refdef.blend);
                }

                cl.refdef.num_entities  = r_numentities;
                cl.refdef.entities      = r_entities;
                cl.refdef.num_particles = r_numparticles;
                cl.refdef.num_dlights   = r_numdlights;
                cl.refdef.dlights       = r_dlights;
                cl.refdef.lightstyles   = r_lightstyles;
                cl.refdef.rdflags       = cl.frame.playerstate.rdflags;
            }

            re.RenderFrame(cl.refdef);
            if (cl_stats.value != 0F)
            {
                Com.Printf("ent:%i  lt:%i  part:%i\\n", r_numentities, r_numdlights, r_numparticles);
            }
            if (log_stats.value != 0F && (log_stats_file != null))
            {
                try
                {
                    log_stats_file.Write(r_numentities + "," + r_numdlights + "," + r_numparticles);
                }
                catch (Exception e)
                {
                }
            }

            SCR.AddDirtyPoint(scr_vrect.x, scr_vrect.y);
            SCR.AddDirtyPoint(scr_vrect.x + scr_vrect.width - 1, scr_vrect.y + scr_vrect.height - 1);
            SCR.DrawCrosshair();
        }
示例#5
0
        public static void DrawConsole(Single frac)
        {
            var width  = viddef.GetWidth();
            var height = viddef.GetHeight();
            var lines  = ( Int32 )(height * frac);

            if (lines <= 0)
            {
                return;
            }
            if (lines > height)
            {
                lines = height;
            }
            re.DrawStretchPic(0, -height + lines, width, height, "conback");
            SCR.AddDirtyPoint(0, 0);
            SCR.AddDirtyPoint(width - 1, lines - 1);
            var version = Com.Sprintf("v%4.2f", 1, VERSION);
            var x       = 0;

            for (x = 0; x < 5; x++)
            {
                re.DrawChar(width - 44 + x * 8, lines - 12, 128 + version[x]);
            }
            con.vislines = lines;
            var rows = (lines - 22) >> 3;
            var y    = lines - 30;

            if (con.display != con.current)
            {
                for (x = 0; x < con.linewidth; x += 4)
                {
                    re.DrawChar((x + 1) << 3, y, '^');
                }
                y -= 8;
                rows--;
            }

            Int32 i, j, n;

            x = 0;
            var row = con.display;

            for (i = 0; i < rows; i++, y -= 8, row--)
            {
                if (row < 0)
                {
                    break;
                }
                if (con.current - row >= con.totallines)
                {
                    break;
                }
                var first = (row % con.totallines) * con.linewidth;
                for (x = 0; x < con.linewidth; x++)
                {
                    re.DrawChar((x + 1) << 3, y, con.text[x + first]);
                }
            }

            if (cls.download != null)
            {
                Int32 text;
                if ((text = cls.downloadname.LastIndexOf('/')) != 0)
                {
                    text++;
                }
                else
                {
                    text = 0;
                }
                x = con.linewidth - ((con.linewidth * 7) / 40);
                y = x - (cls.downloadname.Length - text) - 8;
                i = con.linewidth / 3;
                StringBuffer dlbar = new StringBuffer(512);
                if (cls.downloadname.Length - text > i)
                {
                    y = x - i - 11;
                    var end = text + i - 1;
                    dlbar.Append(cls.downloadname.Substring(text, end));
                    dlbar.Append("...");
                }
                else
                {
                    dlbar.Append(cls.downloadname.Substring(text));
                }

                dlbar.Append(": ");
                dlbar.Append(( Char )0x80);
                if (cls.downloadpercent == 0)
                {
                    n = 0;
                }
                else
                {
                    n = y * cls.downloadpercent / 100;
                }
                for (j = 0; j < y; j++)
                {
                    if (j == n)
                    {
                        dlbar.Append(( Char )0x83);
                    }
                    else
                    {
                        dlbar.Append(( Char )0x81);
                    }
                }

                dlbar.Append(( Char )0x82);
                dlbar.Append((cls.downloadpercent < 10) ? " 0" : " ");
                dlbar.Append(cls.downloadpercent).Append('%');
                y = con.vislines - 12;
                for (i = 0; i < dlbar.Length; i++)
                {
                    re.DrawChar((i + 1) << 3, y, dlbar[i]);
                }
            }

            DrawInput();
        }
示例#6
0
        public static void DrawNotify( )
        {
            Int32  x, v;
            Int32  text;
            Int32  i;
            Int32  time;
            String s;
            Int32  skip;

            v = 0;
            for (i = con.current - NUM_CON_TIMES + 1; i <= con.current; i++)
            {
                if (i < 0)
                {
                    continue;
                }
                time = ( Int32 )con.times[i % NUM_CON_TIMES];
                if (time == 0)
                {
                    continue;
                }
                time = ( Int32 )(cls.realtime - time);
                if (time > con_notifytime.value * 1000)
                {
                    continue;
                }
                text = (i % con.totallines) * con.linewidth;
                for (x = 0; x < con.linewidth; x++)
                {
                    re.DrawChar((x + 1) << 3, v, con.text[text + x]);
                }
                v += 8;
            }

            if (cls.key_dest == key_message)
            {
                if (chat_team)
                {
                    DrawString(8, v, "say_team:");
                    skip = 11;
                }
                else
                {
                    DrawString(8, v, "say:");
                    skip = 5;
                }

                s = chat_buffer;
                if (chat_bufferlen > (viddef.GetWidth() >> 3) - (skip + 1))
                {
                    s = s.Substring(chat_bufferlen - ((viddef.GetWidth() >> 3) - (skip + 1)));
                }
                for (x = 0; x < s.Length; x++)
                {
                    re.DrawChar((x + skip) << 3, v, s[x]);
                }

                re.DrawChar((x + skip) << 3, v, ( Int32 )(10 + ((cls.realtime >> 8) & 1)));
                v += 8;
            }

            if (v != 0)
            {
                SCR.AddDirtyPoint(0, 0);
                SCR.AddDirtyPoint(viddef.GetWidth() - 1, v);
            }
        }