예제 #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);
        }
        public override void DebugDraw()
        {
            var fromColor   = Color.White;
            var toColor     = Color.Tomato;
            var worldPointA = m_worldPosition + m_pointA;
            var worldPointB = m_worldPosition + m_pointB;

            MyDebugDraw.DrawLine3D(ref worldPointA, ref worldPointB, ref fromColor, ref toColor, true);
            base.DebugDraw();
        }
            public void DebugDraw_FromVectorValues(Vector3 Point, Color endColor)
            {
                Color color = Color.Violet;

                for (int i = 0; i < GetRecordCount(); ++i)
                {
                    Vector3 pointTo = new Vector3();
                    GetRecordPoint(i, ref pointTo);
                    MyDebugDraw.DrawLine3D(Point, pointTo, color, endColor);
                }
            }
 internal override void DebugDraw()
 {
     if (m_path != null && m_path.Count > 0)
     {
         MyDebugDraw.DrawSphereWireframe(m_path[0].Position, 2, new Vector3(0, 1, 1), 1);
         for (int i = 1; i < m_path.Count; i++)
         {
             MyDebugDraw.DrawSphereWireframe(m_path[i].Position, 2, new Vector3(0, 1, 1), 1);
             MyDebugDraw.DrawLine3D(m_path[i - 1].Position, m_path[i].Position, Color.Blue, Color.Cyan);
         }
     }
 }
            public void DebugDraw_LinearValues()
            {
                Color color = Color.Yellow;

                if (GetRecordCount() > 1)
                {
                    for (int i = 0; i < GetRecordCount() - 1; ++i)
                    {
                        Vector3 pointFrom = new Vector3();
                        Vector3 pointTo   = new Vector3();
                        GetRecordPoint(i, ref pointFrom);
                        GetRecordPoint(i + 1, ref pointTo);
                        MyDebugDraw.DrawLine3D(pointFrom, pointTo, color, color);
                    }
                }
            }
예제 #6
0
        public override bool DebugDraw()
        {
            return(false);

            bool retVal = base.DebugDraw();

            if (retVal)
            {
                //MyDebugDraw.DrawLine3D(WorldMatrix.Translation, m_headPositionTransformed, Color.Red, Color.Red);

                float length = Vector3.Distance(WorldMatrix.Translation, m_headPositionTransformed);
                float scale  = (length / (2 * ModelLod0.BoundingSphere.Radius));

                //float scale = GetScaleMatrix().Forward.Length();
                MyDebugDraw.DrawLine3D(WorldMatrix.Translation, WorldMatrix.Translation + length * WorldMatrix.Forward, Color.Red, Color.Red);

                MyDebugDraw.DrawSphereWireframe(Matrix.CreateScale(m_harvestingOreHead.ModelLod0.BoundingSphere.Radius) *
                                                Matrix.CreateTranslation(m_headPositionTransformed), new Vector3(0, 1, 0), 0.6f);
            }

            return(true);
        }
예제 #7
0
        void DrawWaypointEdge(Vector3 position1, Vector3 position2, Color color1, Color color2)
        {
            if (MyFakes.MWBUILDER)
            {
                MyDebugDraw.DrawText((position1 + position2) / 2, new StringBuilder(Vector3.Distance(position1, position2).ToString("#,###0.000")), Color.White, 1);
            }

            if (position1 == position2)
            {
                return;
            }
            Vector3 direction  = position2 - position1;
            float   lineLength = direction.Length();

            direction.Normalize();
            MyTransparentGeometry.AddLineBillboard(MyTransparentMaterialEnum.ProjectileTrailLine, color1.ToVector4(), position1, direction, lineLength, 0.25f);

            if (MyWayPointGraph.WaypointsIgnoreDepth)
            {
                MyDebugDraw.DrawLine3D(position1, position2, color1, color2);
            }
        }
예제 #8
0
        public override void DebugDraw()
        {
            base.DebugDraw();

            return;

            if (m_skeletonIndices == null)
            {
                return;
            }

            int bonesCount = m_skeletonIndices.Length;

            for (int i = 0; i < bonesCount; i++)
            {
                var bone2 = m_skeletonHierarchy[m_skeletonIndices[i]];

                if (bone2.Parent == -1)
                {
                    continue;
                }



                Vector3D p2 = ((MatrixD)m_absoluteTransforms[m_skeletonIndices[i]] * WorldMatrix).Translation;
                Vector3D p1 = ((MatrixD)m_absoluteTransforms[bone2.Parent] * WorldMatrix).Translation;

                MyDebugDraw.DrawLine3D(p1, p2, Color.Green, Color.Green, false);

                //              Vector3 pCenter = (p1 + p2) * 0.5f;
//                VRageRender.MyRenderProxy.DebugDrawText3D(pCenter, bone2 + " (" + s.ToString() + ")", Color.White, 0.5f, false);
            }

            //DebugDrawOBB();
            //MyDebugDraw.DrawAxis(WorldMatrix, m_localVolume.Radius, 1, false);
        }
예제 #9
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;
                }
                }
            }
        }
예제 #10
0
        public override bool DebugDraw()
        {
            /*
             * m_targetEntities.Clear();
             *
             * Matrix proj = Matrix.CreateOrthographic(300, 300, 0, 1000);
             * Matrix view = Matrix.CreateLookAt(GetPosition(), GetPosition() + WorldMatrix.Forward, WorldMatrix.Up);
             * m_visualFrustum.Matrix = view * proj;
             *
             * //MyEntities.GetIntersectionWithSphere(ref sphere, this, OwnerEntity, false, false, ref m_targetEntities);
             * MyEntities.GetAllIntersectionWithBoundingFrustum(ref m_visualFrustum, m_targetEntities);
             *
             * MyEntity target = null;
             * float closestToMissileDirection = float.MaxValue;
             *
             * foreach (MyEntity entity in m_targetEntities)
             * {
             * if (CanTarget(entity))
             * {
             *  MySmallShip targetShip = entity as MySmallShip;
             *  if (targetShip != null)
             *  {
             *      if ((targetShip.IsEngineTurnedOff()))
             *          continue;
             *  }
             *
             *  Vector3 targetPos = entity.GetPosition();
             *  Vector3 missilePos = this.GetPosition();
             *  Vector3 missilePosEnd = this.GetPosition() + this.WorldMatrix.Forward * 10000;
             *  Vector3 closestPos = MyUtils.GetClosestPointOnLine(ref missilePos, ref missilePosEnd, ref targetPos);
             *
             *  float distance = Vector3.Distance(closestPos, targetPos);
             *
             *  MyDebugDraw.DrawText(targetPos, new System.Text.StringBuilder(distance.ToString()), Color.White, 1);
             *
             *  if (distance < closestToMissileDirection)
             *  {
             *      closestToMissileDirection = distance;
             *      target = entity;
             *  }
             * }
             * }
             *
             * /*
             * MyEntity target = null; //looks better if missile gets "lost"
             *
             * float closestToMissileDirection = float.MaxValue;
             *
             * foreach (MyEntity entity in m_targetEntities)
             * {
             * if (!CanTarget(entity))
             *  continue;
             *
             * if (MyEnemyTargeting.CanSee(this, entity) == null)
             * {
             *  Vector3 targetPos = entity.GetPosition();
             *  Vector3 missilePos = this.GetPosition();
             *  Vector3 missilePosEnd = this.GetPosition() + this.WorldMatrix.Forward * 10000;
             *  Vector3 closestPos = MyUtils.GetClosestPointOnLine(ref missilePos, ref missilePosEnd, ref targetPos);
             *
             *  float distance = Vector3.Distance(closestPos, targetPos);
             *
             *
             *  MyDebugDraw.DrawText(targetPos, new System.Text.StringBuilder(distance.ToString()), Color.White, 1);
             *
             *  if (distance < closestToMissileDirection)
             *  {
             *      closestToMissileDirection = distance;
             *      target = entity;
             *  }
             * }
             * }
             */


            return(base.DebugDraw());

            //MyDebugDraw.DrawBoundingFrustum(m_visualFrustum, Color.White);
            return(true);

            //  bool retVal = base.DebugDraw();
            //if (!retVal)
            //  return false;

            //Matrix tempInvertedWorldMatrix = Matrix.Invert(Body.CollisionSkin.GetPrimitiveLocal(0).Transform.Orientation * Physics.Matrix);

            //  Transform world's Y axis to body space
            //Vector3 forward = MyUtils.GetTransformNormal(WorldMatrix.Forward, ref tempInvertedWorldMatrix);

#if DEBUG_MISSILE
            if (m_targetShip != null)
            {
                //Vector3 torque = MyUtils.GetTransformNormal(MyMwcUtils.Normalize(m_targetEntity.WorldMatrix.Translation - WorldMatrix.Translation), ref tempInvertedWorldMatrix);
                MyDebugDraw.DrawLine3D(WorldMatrix.Translation, WorldMatrix.Translation + (m_targetShip.WorldMatrix.Translation - WorldMatrix.Translation), Color.Pink, Color.Pink);

                MyDebugDraw.DrawLine3D(WorldMatrix.Translation, WorldMatrix.Translation + (m_predicatedPosition - WorldMatrix.Translation), Color.Yellow, Color.Yellow);
            }
#endif
            Vector3 pos = WorldMatrix.Translation;
            MyDebugDraw.DrawSphereWireframe(pos, WorldVolume.Radius, Vector3.One, 1);
            //Matrix matrix = Physics.Matrix;

            /*
             * MyDebugDraw.DrawLine3D(pos, pos + matrix.Right * 1000, Color.Red, Color.Red);
             * MyDebugDraw.DrawLine3D(pos, pos + matrix.Up * 1000, Color.Green, Color.Green);
             * MyDebugDraw.DrawLine3D(pos, pos + matrix.Forward * 1000, Color.Blue, Color.Blue);
             */
            /*
             * pos = WorldMatrix.Translation;
             * matrix = Physics.Matrix;
             * matrix.Right *= m_targetsRelativePosition.X;
             * matrix.Up *= m_targetsRelativePosition.Y;
             * matrix.Forward *= m_targetsRelativePosition.Z;
             *
             * MyDebugDraw.DrawLine3D(pos, pos + matrix.Right * 1000, Color.Red, Color.Red);
             * MyDebugDraw.DrawLine3D(pos, pos + matrix.Up * 1000, Color.Green, Color.Green);
             * MyDebugDraw.DrawLine3D(pos, pos + matrix.Forward * 1000, Color.Blue, Color.Blue);
             */

#if DEBUG_MISSILE
            for (int i = 0; i < m_trailDebug.Count - 1; i++)
            {
                MyDebugDraw.DrawLine3D(m_trailDebug[i], m_trailDebug[i + 1], Color.White, Color.White);
            }
#endif

            //if (this.Physics.CollisionSkin.Collisions.Count > 0)
            //{
            //    MyDebugDraw.DrawLine3D(GetPosition(), GetPosition() + (Vector3.Negate(this.Physics.CollisionSkin.Collisions[0].DirToBody0) * 1000), Color.White, Color.White);
            //}

            return(true);
        }
예제 #11
0
        public void DebugDraw(float elapsedTime, Matrix worldMatrix)
        {
            Vector3 currentOffsetUntransformed, currentOffset;

            Offset.GetInterpolatedValue <Vector3>(elapsedTime, out currentOffsetUntransformed);
            Vector3.Transform(ref currentOffsetUntransformed, ref worldMatrix, out currentOffset);
            float currentSize;

            Size.GetInterpolatedValue <float>(elapsedTime, out currentSize);

            switch (Type)
            {
            case MyParticleEmitterType.Point:
            {
                MyDebugDraw.DrawSphereWireframe(currentOffset, 0.1f, new Vector3(1, 1, 0), 1.0f);
            }
            break;

            case MyParticleEmitterType.Line:
            {
                if (DirToCamera)
                {
                    Vector3 dir = MyCamera.Position - currentOffset;
                    dir.Normalize();
                    Matrix  matrix = Matrix.CreateScale(currentSize) * MyMath.MatrixFromDir(dir);
                    Vector3 currentOffsetScaled = Vector3.TransformNormal(Vector3.Forward, matrix);
                    MyDebugDraw.DrawLine3D(worldMatrix.Translation, worldMatrix.Translation + currentOffsetScaled, Color.Yellow, Color.Yellow);
                }
                else
                {
                    Vector3 currentOffsetScaled = Vector3.Transform(Vector3.Up * currentSize, worldMatrix);
                    MyDebugDraw.DrawLine3D(worldMatrix.Translation, currentOffsetScaled, Color.Yellow, Color.Yellow);
                }
            }
            break;

            case MyParticleEmitterType.Sphere:
            {
                MyDebugDraw.DrawSphereWireframe(currentOffset, currentSize, new Vector3(1, 1, 0), 1.0f);
            }
            break;

            case MyParticleEmitterType.Box:
            {
                Matrix matrix = Matrix.CreateScale(currentSize) * Matrix.CreateTranslation(currentOffsetUntransformed) * worldMatrix;
                MyDebugDraw.DrawLowresBoxWireframe(matrix, new Vector3(1, 1, 0), 1.0f);
            }
            break;

            case MyParticleEmitterType.Hemisphere:
            {
                Vector3 worldPos = currentOffset;

                Matrix matrix;

                if (DirToCamera)
                {
                    Matrix WorldView = worldMatrix * MyCamera.ViewMatrix;
                    WorldView.Translation += currentOffsetUntransformed;
                    Matrix newWorld = WorldView * Matrix.Invert(MyCamera.ViewMatrix);

                    Vector3 dir = MyCamera.Position - newWorld.Translation;
                    dir.Normalize();

                    matrix             = Matrix.CreateScale(currentSize) * Matrix.CreateRotationX(MathHelper.PiOver2) * MyMath.MatrixFromDir(dir);
                    matrix.Translation = newWorld.Translation;
                }
                else
                {
                    matrix = Matrix.CreateScale(currentSize) * Matrix.CreateTranslation(currentOffsetUntransformed) * worldMatrix;
                }

                MyDebugDraw.DrawHemisphereWireframe(matrix, new Vector3(1, 1, 0), 1.0f);
            }
            break;

            case MyParticleEmitterType.Circle:
            {
                //No debug draw
            }
            break;

            default:
                System.Diagnostics.Debug.Assert(false);
                break;
            }
        }