Пример #1
0
        public void Draw(TextBuilder text, TextBatcher textBatcher, DemoSet demoSet, Vector2 position, float textHeight, Vector3 textColor, Font font)
        {
            if (TrackingInput)
            {
                text.Clear().Append("Swap demo to: ");
                if (TargetDemoIndex >= 0)
                {
                    text.Append(TargetDemoIndex);
                }
                else
                {
                    text.Append("_");
                }
                textBatcher.Write(text, position, textHeight, textColor, font);

                var lineSpacing = textHeight * 1.1f;
                position.Y += textHeight * 0.5f;
                textHeight *= 0.8f;
                for (int i = 0; i < demoSet.Count; ++i)
                {
                    position.Y += lineSpacing;
                    text.Clear().Append(demoSet.GetName(i));
                    textBatcher.Write(text.Clear().Append(i).Append(": ").Append(demoSet.GetName(i)), position, textHeight, textColor, font);
                }
            }
        }
Пример #2
0
        public DemoHarness(GameLoop loop, ContentArchive content,
                           Controls?controls = null, DemoSet customDemoSet = null)
        {
            this.window  = loop.Window;
            this.input   = loop.Input;
            this.camera  = loop.Camera;
            this.content = content;
            timeSamples  = new SimulationTimeSamples(512, loop.Pool);
            if (controls == null)
            {
                this.controls = Controls.Default;
            }

            var fontContent = content.Load <FontContent>(@"Content\Carlito-Regular.ttf");

            font = new Font(loop.Surface.Device, loop.Surface.Context, fontContent);

            timingGraph = new Graph(new GraphDescription
            {
                BodyLineColor                 = new Vector3(1, 1, 1),
                AxisLabelHeight               = 16,
                AxisLineRadius                = 0.5f,
                HorizontalAxisLabel           = "Frames",
                VerticalAxisLabel             = "Time (ms)",
                VerticalIntervalValueScale    = 1e3f,
                VerticalIntervalLabelRounding = 2,
                BackgroundLineRadius          = 0.125f,
                IntervalTextHeight            = 12,
                IntervalTickRadius            = 0.25f,
                IntervalTickLength            = 6f,
                TargetHorizontalTickCount     = 5,
                HorizontalTickTextPadding     = 0,
                VerticalTickTextPadding       = 3,

                LegendMinimum    = new Vector2(20, 200),
                LegendNameHeight = 12,
                LegendLineLength = 7,

                TextColor = new Vector3(1, 1, 1),
                Font      = font,

                LineSpacingMultiplier = 1f,

                ForceVerticalAxisMinimumToZero = true
            });
            timingGraph.AddSeries("Total", new Vector3(1, 1, 1), 0.75f, timeSamples.Simulation);
            timingGraph.AddSeries("Pose Integrator", new Vector3(0, 0, 1), 0.25f, timeSamples.PoseIntegrator);
            timingGraph.AddSeries("Sleeper", new Vector3(0.5f, 0, 1), 0.25f, timeSamples.Sleeper);
            timingGraph.AddSeries("Broad Update", new Vector3(1, 1, 0), 0.25f, timeSamples.BroadPhaseUpdate);
            timingGraph.AddSeries("Collision Test", new Vector3(0, 1, 0), 0.25f, timeSamples.CollisionTesting);
            timingGraph.AddSeries("Narrow Flush", new Vector3(1, 0, 1), 0.25f, timeSamples.NarrowPhaseFlush);
            timingGraph.AddSeries("Solver", new Vector3(1, 0, 0), 0.5f, timeSamples.Solver);

            timingGraph.AddSeries("Body Opt", new Vector3(1, 0.5f, 0), 0.125f, timeSamples.BodyOptimizer);
            timingGraph.AddSeries("Constraint Opt", new Vector3(0, 0.5f, 1), 0.125f, timeSamples.ConstraintOptimizer);
            timingGraph.AddSeries("Batch Compress", new Vector3(0, 0.5f, 0), 0.125f, timeSamples.BatchCompressor);

            demoSet = customDemoSet ?? new DemoSet().AddDefaultOptions();
            demo    = demoSet.Build(0, content, camera);

            OnResize(window.Resolution);
        }