Пример #1
0
        public void DebugDraw()
        {
            Vector3?prePosition = null;

            for (int i = 0; i < Keys.Count - 1; i++)
            {
                MyKey key0 = Keys[(int)MathHelper.Clamp(i - 1, 0, Keys.Count - 1)];
                MyKey key1 = Keys[(int)MathHelper.Clamp(i, 0, Keys.Count - 1)];
                MyKey key2 = Keys[(int)MathHelper.Clamp(i + 1, 0, Keys.Count - 1)];
                MyKey key3 = Keys[(int)MathHelper.Clamp(i + 2, 0, Keys.Count - 1)];

                MyDebugDraw.DrawAxis(Matrix.CreateTranslation(key1.Position), 10, 1);

                int steps = 50;
                for (int j = 0; j < steps; j++)
                {
                    float amount = 1.0f * j / steps;

                    Vector3 position = new Vector3(
                        MathHelper.CatmullRom(key0.Position.X, key1.Position.X, key2.Position.X, key3.Position.X, amount),
                        MathHelper.CatmullRom(key0.Position.Y, key1.Position.Y, key2.Position.Y, key3.Position.Y, amount),
                        MathHelper.CatmullRom(key0.Position.Z, key1.Position.Z, key2.Position.Z, key3.Position.Z, amount));

                    if (prePosition.HasValue)
                    {
                        MyDebugDraw.DrawLine3D(prePosition.Value, position, Color.Orange, Color.Orange);
                    }

                    prePosition = position;
                }
            }

            MyDebugDraw.DrawAxis(Matrix.CreateTranslation(Keys[Keys.Count - 1].Position), 10, 1);
        }
Пример #2
0
        private static void DebugDrawLights()
        {
            return;

            //Debug draw lights
            foreach (MyRenderLight light in m_renderLightsForDraw)
            {
                //if (light.LightOn && light.Glare.Type == TransparentGeometry.MyLightGlare.GlareTypeEnum.Distant)
                {
                    if ((light.LightType & LightTypeEnum.PointLight) != 0)
                    {
                        MyDebugDraw.DrawSphereWireframe(MatrixD.CreateScale(light.Range) * MatrixD.CreateTranslation(light.PositionWithOffset), Color.Red, 1);
                        MyDebugDraw.DrawAxis(MatrixD.CreateWorld(light.Position, light.ReflectorDirection, light.ReflectorUp), 2, 1, false);
                        // MyDebugDraw.DrawText(light.PositionWithOffset, new System.Text.StringBuilder(light.ID.ToString()), Color.White, 1);
                    }
                    //if ((light.LightType & LightTypeEnum.Hemisphere) != 0)
                    //{
                    //    Matrix rotationHotfix = Matrix.CreateFromAxisAngle(Vector3.UnitX, MathHelper.PiOver2);
                    //    Matrix world = Matrix.CreateScale(light.Range) * rotationHotfix * Matrix.CreateWorld(light.Position, light.ReflectorDirection, light.ReflectorUp);
                    //    MyDebugDraw.DrawHemisphereWireframe(world, new Vector3(1, 0, 0), 1);
                    //}
                    if ((light.LightType & LightTypeEnum.Spotlight) != 0)
                    {
                        // Uncomment to show sphere for spot light
                        //MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(light.ReflectorRange) * Matrix.CreateTranslation(light.Position), new Vector3(color.X, color.Y, color.Z), 0.25f);

                        //MyDebugDraw.DrawCapsule(light.Position, light.Position + light.ReflectorDirection * light.ReflectorRange, 1, new Color(color.X, color.Y, color.Z), false);

                        //float reflectorConeAngle = (float)System.Math.Acos(1 - light.ReflectorConeMaxAngleCos);
                        //float reflectorRadius = (float)System.Math.Tan(reflectorConeAngle) * light.ReflectorRange;
                        //MyDebugDraw.DrawCylinder(light.Position, light.Position + light.ReflectorDirection * light.ReflectorRange, 0, reflectorRadius, new Color(color.X, color.Y, color.Z), false);

//                        MyDebugDraw.DrawText(light.Position, new System.Text.StringBuilder(light.ShadowMapIndex.ToString() + " (" + (light.SpotQuery != null ? light.QueryPixels.ToString() : "") + ")" ), Color.Yellow, 0.8f, false);

                        MyDebugDraw.DrawText(light.Position, new System.Text.StringBuilder(Vector3D.Distance(MyRenderCamera.Position, light.Position).ToString()), Color.Yellow, 0.8f, false);

                        MyStateObjects.WireframeClockwiseRasterizerState.Apply();
                        DepthStencilState.None.Apply();



                        MyDebugDraw.DrawModel(MyDebugDraw.ModelCone, light.SpotWorld, Color.White, false);
                    }

                    //just glare
                    if (light.LightType == LightTypeEnum.None)
                    {
                        MyDebugDraw.DrawSphereWireframe(MatrixD.CreateScale(light.Range) * MatrixD.CreateTranslation(light.PositionWithOffset), Color.Red, 1);
                    }
                }
            }
        }
Пример #3
0
        public override bool DebugDraw()
        {
            return(false);

            if (!base.DebugDraw())
            {
                return(false);
            }

            MyDebugDraw.DrawAxis(WorldMatrix, 1.0f, 1);

            return(false);
        }
Пример #4
0
        public override bool DebugDraw()
        {
            if (!base.DebugDraw())
            {
                return(false);
            }

            if (MyMwcFinalBuildConstants.DrawHelperPrimitives)
            {
                MyDebugDraw.DrawSphereWireframe(GetPosition(), 0.1f, new Vector3(0, 1, 0), 1);
                MyDebugDraw.DrawAxis(WorldMatrix, 5, 1);
            }

            return(true);
        }
Пример #5
0
        public void DebugDraw()
        {
            MyDebugDraw.DrawAxis(WorldMatrix, 1.0f, 1.0f);
            MyDebugDraw.DrawSphereWireframe(WorldMatrix.Translation, 0.1f, Vector3.One, 1.0f);

            foreach (MyParticleGeneration generation in m_generations)
            {
                generation.DebugDraw();
            }

            Color color = !m_isStopped ? Color.White : Color.Red;

            MyDebugDraw.DrawText(WorldMatrix.Translation, new System.Text.StringBuilder(GetID().ToString() + " [" + GetParticlesCount().ToString() + "]"), color, 1.0f);

            // Vector4 colorV = color.ToVector4();
            // MyDebugDraw.DrawAABB(ref m_AABB, ref colorV, 1.0f);
        }
Пример #6
0
        /// <summary>
        /// Draw debug.
        /// </summary>
        /// <returns></returns>
        public override void DebugDraw()
        {
            return;

            //if (MyMwcFinalBuildConstants.DrawHelperPrimitives)
            {
                // DebugDrawVolume();
                DebugDrawOBB();
                MyDebugDraw.DrawAxis(WorldMatrix, (float)m_localVolume.Radius, 1, false);
            }

            /*
             * if (MyMwcFinalBuildConstants.DrawJLXCollisionPrimitives)
             * {
             *  DebugDrawPhysics();
             * }
             *
             * if (MyMwcFinalBuildConstants.DrawNormalVectors)
             * {
             *  DebugDrawNormalVectors();
             * } */
        }
Пример #7
0
        public static void DebugDraw()
        {
            MyLights.UpdateSortedLights(ref MyCamera.BoundingSphere, false);

            foreach (MyLight light in m_sortedLights)
            {
                //if (light.LightOn && light.Glare.Type == TransparentGeometry.MyLightGlare.GlareTypeEnum.Distant)
                {
                    if ((light.LightType & MyLight.LightTypeEnum.PointLight) != 0)
                    {
                        MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(light.Range) * Matrix.CreateTranslation(light.PositionWithOffset), new Vector3(1, 0, 0), 1);
                    }
                    if ((light.LightType & MyLight.LightTypeEnum.Hemisphere) != 0)
                    {
                        Matrix rotationHotfix = Matrix.CreateFromAxisAngle(Vector3.UnitX, MathHelper.PiOver2);
                        Matrix world          = Matrix.CreateScale(light.Range) * rotationHotfix * Matrix.CreateWorld(light.Position, light.ReflectorDirection, light.ReflectorUp);
                        MyDebugDraw.DrawHemisphereWireframe(world, new Vector3(1, 0, 0), 1);
                    }
                    if ((light.LightType & MyLight.LightTypeEnum.Spotlight) != 0 /* && light.ReflectorOn*/)
                    {
                        Vector4 color = Color.Aqua.ToVector4();
                        // MyDebugDraw.DrawAABB(ref bb, ref color, 1.0f);

                        MyDebugDraw.DrawAxis(Matrix.CreateWorld(light.Position, Vector3.Up, Vector3.Forward), 2, 1);
                        MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(light.Range) * Matrix.CreateTranslation(light.PositionWithOffset), new Vector3(1, 0, 0), 1);

                        // Uncomment to show sphere for spot light
                        //MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(light.ReflectorRange) * Matrix.CreateTranslation(light.Position), new Vector3(color.X, color.Y, color.Z), 0.25f);
                        //MySimpleObjectDraw.DrawConeForLight();
                        MyStateObjects.WireframeRasterizerState.Apply();
                        SharpDX.Toolkit.Graphics.DepthStencilState.None.Apply();

                        MyDebugDraw.DrawModel(MySimpleObjectDraw.ModelCone, light.SpotWorld, Vector3.One, 1);
                    }
                }
            }
        }
Пример #8
0
        private static void DrawDebugMessages()
        {
            //DepthStencilState.None.Apply();
            DepthStencilState.DepthRead.Apply();
            BlendState.NonPremultiplied.Apply();

            while (m_debugDrawMessages.Count > 0)
            {
                IMyRenderMessage debugDrawMessage = m_debugDrawMessages.Dequeue();

                MyRenderMessageEnum messageType = debugDrawMessage.MessageType;

                switch (messageType)
                {
                case MyRenderMessageEnum.DebugDrawLine3D:
                {
                    MyRenderMessageDebugDrawLine3D message = (MyRenderMessageDebugDrawLine3D)debugDrawMessage;

                    MyDebugDraw.DrawLine3D(
                        message.PointFrom,
                        message.PointTo,
                        message.ColorFrom,
                        message.ColorTo,
                        message.DepthRead);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawLine2D:
                {
                    MyRenderMessageDebugDrawLine2D message = (MyRenderMessageDebugDrawLine2D)debugDrawMessage;

                    MyDebugDraw.DrawLine2D(
                        message.PointFrom,
                        message.PointTo,
                        message.ColorFrom,
                        message.ColorTo,
                        message.Projection);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawSphere:
                {
                    MyRenderMessageDebugDrawSphere message = (MyRenderMessageDebugDrawSphere)debugDrawMessage;

                    MyDebugDraw.DrawSphere(
                        message.Position,
                        message.Radius,
                        message.Color,
                        message.Alpha,
                        message.DepthRead,
                        message.Smooth,
                        message.Cull);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawAABB:
                {
                    MyRenderMessageDebugDrawAABB message = (MyRenderMessageDebugDrawAABB)debugDrawMessage;

                    Color color = new Color(message.Color, message.Alpha);
                    var   aabb  = new BoundingBoxD(message.AABB.Min, message.AABB.Max);
                    MyDebugDraw.DrawAABBLine(
                        ref aabb,
                        ref color,
                        message.Scale,
                        message.DepthRead);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawAxis:
                {
                    MyRenderMessageDebugDrawAxis message = (MyRenderMessageDebugDrawAxis)debugDrawMessage;

                    MyDebugDraw.DrawAxis(
                        (MatrixD)message.Matrix,
                        message.AxisLength,
                        1,
                        message.DepthRead);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawOBB:
                {
                    MyRenderMessageDebugDrawOBB message = (MyRenderMessageDebugDrawOBB)debugDrawMessage;

                    if (message.Smooth)
                    {
                        MyDebugDraw.DrawLowresBoxSmooth(
                            message.Matrix,
                            message.Color,
                            message.Alpha,
                            message.DepthRead,
                            message.Cull);
                    }
                    else
                    {
                        MyDebugDraw.DrawOBBLine(
                            new MyOrientedBoundingBoxD(message.Matrix),
                            message.Color,
                            message.Alpha,
                            message.DepthRead);

                        //BoundingBoxD bd = new BoundingBoxD(message.Matrix.Translation - new Vector3(100),message.Matrix.Translation + new Vector3(100));

                        //Vector4 c = new Vector4(message.Color.X, message.Color.Y, message.Color.Z, message.Alpha);
                        //MyDebugDraw.DrawAABBLine(ref bd, ref c, 1, false);
                    }
                    break;
                }

                case MyRenderMessageEnum.DebugDrawCylinder:
                {
                    MyRenderMessageDebugDrawCylinder message = (MyRenderMessageDebugDrawCylinder)debugDrawMessage;

                    if (message.Smooth)
                    {
                        MyDebugDraw.DrawLowresCylinderSmooth(
                            (MatrixD)message.Matrix,
                            message.Color,
                            message.Alpha,
                            message.DepthRead);
                    }
                    else
                    {
                        MyDebugDraw.DrawLowresCylinderWireframe(
                            (MatrixD)message.Matrix,
                            message.Color,
                            message.Alpha,
                            message.DepthRead);
                    }
                    break;
                }

                case MyRenderMessageEnum.DebugDrawTriangle:
                {
                    MyRenderMessageDebugDrawTriangle message = (MyRenderMessageDebugDrawTriangle)debugDrawMessage;

                    MyDebugDraw.DrawTriangle((Vector3D)message.Vertex0, (Vector3D)message.Vertex1, (Vector3D)message.Vertex2, message.Color, message.Color, message.Color, message.Smooth, message.DepthRead);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawTriangles:
                {
                    MyRenderMessageDebugDrawTriangles message = (MyRenderMessageDebugDrawTriangles)debugDrawMessage;

                    MyDebugDraw.DrawTriangles(message.WorldMatrix, message.Vertices, message.Indices, message.Color,
                                              message.DepthRead, message.Shaded);
                    break;
                }

                case MyRenderMessageEnum.DebugDrawCapsule:
                {
                    MyRenderMessageDebugDrawCapsule message = (MyRenderMessageDebugDrawCapsule)debugDrawMessage;

                    if (message.Shaded)
                    {
                        MyDebugDraw.DrawCapsuleShaded(message.P0, message.P1, message.Radius, message.Color, message.DepthRead);
                    }
                    else
                    {
                        MyDebugDraw.DrawCapsule(message.P0, message.P1, message.Radius, message.Color, message.DepthRead);
                    }

                    break;
                }

                case MyRenderMessageEnum.DebugDrawText2D:
                {
                    MyRenderMessageDebugDrawText2D message = (MyRenderMessageDebugDrawText2D)debugDrawMessage;

                    MyDebugDraw.DrawText(
                        message.Coord,
                        new StringBuilder(message.Text),
                        message.Color,
                        message.Scale,
                        false,
                        message.Align);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawText3D:
                {
                    MyRenderMessageDebugDrawText3D message = (MyRenderMessageDebugDrawText3D)debugDrawMessage;

                    MyDebugDraw.DrawText(
                        (Vector3D)message.Coord,
                        new StringBuilder(message.Text),
                        message.Color,
                        message.Scale,
                        message.DepthRead,
                        message.Align,
                        message.CustomViewProjection);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawModel:
                {
                    MyRenderMessageDebugDrawModel message = (MyRenderMessageDebugDrawModel)debugDrawMessage;

                    MyDebugDraw.DrawModel(MyRenderModels.GetModel(message.Model), message.WorldMatrix, message.Color,
                                          message.DepthRead);

                    break;
                }

                case MyRenderMessageEnum.DebugDrawPlane:
                {
                    MyRenderMessageDebugDrawPlane message = (MyRenderMessageDebugDrawPlane)debugDrawMessage;

                    MyDebugDraw.DrawPlane((Vector3D)message.Position, message.Normal, message.Color, message.DepthRead);

                    break;
                }

                default:
                {
                    System.Diagnostics.Debug.Assert(false, "Unknown debug draw message");
                    break;
                }
                }
            }
        }