Beispiel #1
0
        public static void DrawDebug()
        {
            // Update view and projection with updated camera coordinates.
            DefaultEffect.View       = Game1.CurrentScene.CurrentCamera.View;
            DefaultEffect.Projection = Game1.CurrentScene.CurrentCamera.ProjectionMatrix;

            DefaultEffect.CurrentTechnique.Passes[0].Apply();

            for (int i = 0; i < DebugList.Count; i++)
            {
                DebugLine dl = DebugList[i];

                VertexPositionColor[] buffer = { new VertexPositionColor(dl.Start, dl.Color), new VertexPositionColor(dl.End, dl.Color) };

                Graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, buffer, 0, 1);
            }

            for (int i = 0; i < DebugHit.Count; i++)
            {
                DebugHit dh = DebugHit[i];
                VertexPositionColor[] buffer =
                {
                    new VertexPositionColor(dh.Point + new Vector3(0, 0, 1), dh.Color), new VertexPositionColor(dh.Point - new Vector3(0, 0, 1), dh.Color),
                    new VertexPositionColor(dh.Point + new Vector3(1, 0, 0), dh.Color), new VertexPositionColor(dh.Point - new Vector3(1, 0, 0), dh.Color),
                };
                Graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, buffer, 0, 2);
            }

            for (int i = 0; i < DebugBoxes.Count; i++)
            {
                DebugBox db = DebugBoxes[i];
                VertexPositionColor[] buffer =
                {
                    // TOP
                    new VertexPositionColor(db.Point + new Vector3(-0.5f, -0.5f, -0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(-0.5f, -0.5f,  0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(-0.5f, -0.5f,  0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(0.5f,  -0.5f,  0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(0.5f,  -0.5f,  0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(0.5f,  -0.5f, -0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(0.5f,  -0.5f, -0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(-0.5f, -0.5f, -0.5f), db.Color),

                    // middle
                    new VertexPositionColor(db.Point + new Vector3(-0.5f, -0.5f, -0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(-0.5f,  0.5f, -0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(-0.5f, -0.5f,  0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(-0.5f,  0.5f,  0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(0.5f,  -0.5f,  0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(0.5f,   0.5f,  0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(0.5f,  -0.5f, -0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(0.5f,   0.5f, -0.5f), db.Color),

                    // bottom
                    new VertexPositionColor(db.Point + new Vector3(-0.5f,  0.5f, -0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(-0.5f,  0.5f,  0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(-0.5f,  0.5f,  0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(0.5f,   0.5f,  0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(0.5f,   0.5f,  0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(0.5f,   0.5f, -0.5f), db.Color),

                    new VertexPositionColor(db.Point + new Vector3(0.5f,   0.5f, -0.5f), db.Color),
                    new VertexPositionColor(db.Point + new Vector3(-0.5f,  0.5f, -0.5f), db.Color),
                };
                Graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, buffer, 0, buffer.Count() / 2);
            }
        }
Beispiel #2
0
 public static void AddDebugHit(DebugHit hit)
 {
     DebugHit.Add(hit);
 }