コード例 #1
0
ファイル: DemoHarness.cs プロジェクト: weihua44/bepuphysics2
        public DemoHarness(GameLoop loop, ContentArchive content,
                           Controls?controls = null)
        {
            this.loop    = loop;
            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 = new DemoSet();
            demo    = demoSet.Build(0, content, loop.Camera, loop.Surface);

            OnResize(loop.Window.Resolution);
        }
コード例 #2
0
        public DemoHarness(Window window, Input input, Camera camera, Font font,
                           Controls?controls = null)
        {
            this.window = window;
            this.input  = input;
            this.camera = camera;
            if (controls == null)
            {
                this.controls = Controls.Default;
            }
            this.font = font;

            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 = new DemoSet();
            demo    = demoSet.Build(0, camera);

            OnResize(window.Resolution);
        }