コード例 #1
0
ファイル: V.cs プロジェクト: optimus-code/Quake2Sharp
        /*
         * ================== 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();
        }
コード例 #2
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();
        }