Esempio n. 1
0
        public override void DebugDraw()
        {
            base.DebugDraw();

            var pos1   = Parent.PositionAndOrientation.Translation + Parent.PositionAndOrientation.Up * m_capsuleOffset;
            var pos2   = pos1 + Parent.PositionAndOrientation.Up * m_capsuleHeight;
            var center = (pos1 + pos2) * 0.5f;

            Vector3 currentMovement;
            Vector3 wantedMovement;

            GetMovements(out currentMovement, out wantedMovement);

            Vector3D?target = TargetWorld;

            if (target.HasValue)
            {
                MyRenderProxy.DebugDrawLine3D(center, target.Value, Color.White, Color.White, true);
                MyRenderProxy.DebugDrawSphere(target.Value, 0.05f, Color.White.ToVector3(), 1.0f, false);
                MyRenderProxy.DebugDrawCapsule(pos1, pos2, (float)Math.Sqrt(m_capsuleRadiusSq), Color.Yellow, false);
            }

            MyRenderProxy.DebugDrawLine3D(pos2, pos2 + wantedMovement, Color.Red, Color.Red, false);
            MyRenderProxy.DebugDrawLine3D(pos2, pos2 + currentMovement, Color.Green, Color.Green, false);
        }
 private void DebugDrawDamageArea()
 {
     if (m_thrust.CurrentStrength != 0 || MyFakes.INACTIVE_THRUSTER_DMG)
     {
         foreach (var flameInfo in m_thrust.Flames)
         {
             var l = m_thrust.GetDamageCapsuleLine(flameInfo);
             MyRenderProxy.DebugDrawCapsule(l.From, l.To, flameInfo.Radius * m_thrust.FlameDamageLengthScale, Color.Red, false);
             //MyRenderProxy.DebugDrawSphere(l.From, flameInfo.Radius * m_thrustDefinition.FlameDamageLengthScale, Color.Green.ToVector3(), 1, false);
         }
     }
 }
Esempio n. 3
0
 private void DebugDrawDamageArea()
 {
     if ((this.m_thrust.CurrentStrength != 0f) || MyFakes.INACTIVE_THRUSTER_DMG)
     {
         foreach (MyThrustFlameAnimator.FlameInfo info in this.m_thrust.Flames)
         {
             MatrixD worldMatrix       = this.m_thrust.WorldMatrix;
             LineD   damageCapsuleLine = this.m_thrust.GetDamageCapsuleLine(info, ref worldMatrix);
             MyRenderProxy.DebugDrawCapsule(damageCapsuleLine.From, damageCapsuleLine.To, info.Radius * this.m_thrust.FlameDamageLengthScale, Color.Red, false, false, false);
         }
     }
 }
Esempio n. 4
0
 public static void DrawShape(HkShape shape, MatrixD worldMatrix, Color color, float alpha, bool shaded = true)
 {
     color.A = (byte)(alpha * 255f);
     if (shape.ShapeType != HkShapeType.Capsule)
     {
         MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, 0.05f, color, 1f, false, false, true, false);
     }
     else
     {
         HkCapsuleShape shape2 = (HkCapsuleShape)shape;
         Vector3        vector = (Vector3)Vector3.Transform(shape2.VertexB, worldMatrix);
         MyRenderProxy.DebugDrawCapsule(Vector3.Transform(shape2.VertexA, worldMatrix), vector, shape2.Radius, color, false, false, false);
     }
 }
Esempio n. 5
0
        public override void Draw()
        {
            base.Draw();
            foreach (var line in m_lines)
            {
                MyRenderProxy.DebugDrawLine3D(line.From, line.To, line.ColorFrom, line.ColorTo, line.DepthRead);
            }

            if (ShowDebugDrawTests)
            {
                Vector3D position = new Vector3D(1000000000.0, 1000000000.0, 1000000000.0);
                MyRenderProxy.DebugDrawLine3D(position, position + Vector3D.Up, Color.Red, Color.Blue, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawLine3D(position, position + Vector3D.Up, Color.Red, Color.Blue, false);

                MyRenderProxy.DebugDrawLine2D(new Vector2(10, 10), new Vector2(50, 50), Color.Red, Color.Blue);

                position += Vector3D.Left;
                MyRenderProxy.DebugDrawPoint(position, Color.White, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawPoint(position, Color.White, false);

                position += Vector3D.Left;
                MyRenderProxy.DebugDrawSphere(position, 0.5f, Color.White, 1.0f, true);

                position += Vector3D.Left;
                MyRenderProxy.DebugDrawAABB(new BoundingBoxD(position - Vector3D.One * 0.5, position + Vector3D.One * 0.5), Color.White, 1.0f, 1.0f, true);

                position += Vector3D.Left;
                //MyRenderProxy.DebugDrawCone(position, Vector3D.Up, Vector3D.One, Color.Yellow, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawAxis(MatrixD.CreateFromTransformScale(Quaternion.Identity, position, Vector3D.One * 0.5), 1.0f, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawOBB(new MyOrientedBoundingBoxD(position, Vector3D.One * 0.5, Quaternion.Identity), Color.White, 1.0f, true, false);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawCylinder(MatrixD.CreateFromTransformScale(Quaternion.Identity, position, Vector3D.One * 0.5), Color.White, 1.0f, true, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawTriangle(position, position + Vector3D.Up, position + Vector3D.Left, Color.White, true, true);
                position += Vector3D.Left;
                var msg = MyRenderProxy.PrepareDebugDrawTriangles();
                msg.AddTriangle(position, position + Vector3D.Up, position + Vector3D.Left);
                msg.AddTriangle(position, position + Vector3D.Left, position - Vector3D.Up);
                MyRenderProxy.DebugDrawTriangles(msg, MatrixD.Identity, Color.White, true, true);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawCapsule(position, position + Vector3D.Up, 0.5f, Color.White, true);
                MyRenderProxy.DebugDrawText2D(new Vector2(100, 100), "text", Color.Green, 1.0f);
                position += Vector3D.Left;
                MyRenderProxy.DebugDrawText3D(position, "3D Text", Color.Blue, 1.0f, true);
            }
        }
Esempio n. 6
0
        public override void DebugDraw()
        {
            Vector3  vector;
            Vector3  vector2;
            Vector3D vectord   = base.Parent.PositionAndOrientation.Translation + (base.Parent.PositionAndOrientation.Up * this.m_capsuleOffset);
            Vector3D vectord2  = vectord + (base.Parent.PositionAndOrientation.Up * this.m_capsuleHeight);
            Vector3D pointFrom = (vectord + vectord2) * 0.5;

            this.GetMovements(out vector, out vector2);
            Vector3D?targetWorld = this.TargetWorld;

            if (targetWorld != null)
            {
                MyRenderProxy.DebugDrawLine3D(pointFrom, targetWorld.Value, Color.White, Color.White, true, false);
                MyRenderProxy.DebugDrawSphere(targetWorld.Value, 0.05f, Color.White.ToVector3(), 1f, false, false, true, false);
                MyRenderProxy.DebugDrawCapsule(vectord, vectord2, (float)Math.Sqrt((double)this.m_capsuleRadiusSq), Color.Yellow, false, false, false);
            }
            MyRenderProxy.DebugDrawLine3D(vectord2, vectord2 + vector2, Color.Red, Color.Red, false, false);
            MyRenderProxy.DebugDrawLine3D(vectord2, vectord2 + vector, Color.Green, Color.Green, false, false);
        }
Esempio n. 7
0
        public override void Draw()
        {
            base.Draw();
            if (OnDraw != null)
            {
                try
                {
                    OnDraw();
                }
                catch (Exception e)
                {
                    OnDraw = null;
                }
            }

            foreach (var entry in AABBsToDraw)
            {
                MyRenderProxy.DebugDrawAABB(entry.Item1, entry.Item2, 1f, 1f, false);
            }

            foreach (var entry in MatricesToDraw)
            {
                MyRenderProxy.DebugDrawAxis(entry.Item1, 1f, false);
                MyRenderProxy.DebugDrawOBB(entry.Item1, entry.Item2, 1f, false, false);
            }

            foreach (var capsule in CapsulesToDraw)
            {
                MyRenderProxy.DebugDrawCapsule(capsule.Item1.P0, capsule.Item1.P1, capsule.Item1.Radius, capsule.Item2, false, true);
            }

            foreach (var line in LinesToDraw)
            {
                MyRenderProxy.DebugDrawLine3D(line.Item1, line.Item2, line.Item3, line.Item3, false);
            }
        }
Esempio n. 8
0
 internal override void DebugDraw(ref MatrixD worldTranslation, Color color)
 {
     MyRenderProxy.DebugDrawCapsule(Vector3D.Transform(this.m_pointA, worldTranslation), Vector3D.Transform(this.m_pointB, worldTranslation), this.m_radius, color, true, true, false);
 }
Esempio n. 9
0
        public static void DebugDraw(this IMyConveyorEndpoint endpoint)
        {
            if (!MyDebugDrawSettings.DEBUG_DRAW_CONVEYORS)
            {
                return;
            }

            Vector3 centerPos = new Vector3();

            for (int i = 0; i < endpoint.GetLineCount(); ++i)
            {
                var     position = endpoint.GetPosition(i);
                Vector3 pos      = new Vector3(position.LocalGridPosition) + 0.5f * new Vector3(position.VectorDirection);
                centerPos += pos;
            }
            centerPos = centerPos * endpoint.CubeBlock.CubeGrid.GridSize / (float)endpoint.GetLineCount();
            centerPos = Vector3.Transform(centerPos, endpoint.CubeBlock.CubeGrid.WorldMatrix);

            for (int i = 0; i < endpoint.GetLineCount(); ++i)
            {
                var            position = endpoint.GetPosition(i);
                MyConveyorLine line     = endpoint.GetConveyorLine(i);
                Vector3        pos      = (new Vector3(position.LocalGridPosition) + 0.5f * new Vector3(position.VectorDirection)) * endpoint.CubeBlock.CubeGrid.GridSize;
                Vector3        pos2     = (new Vector3(position.LocalGridPosition) + 0.4f * new Vector3(position.VectorDirection)) * endpoint.CubeBlock.CubeGrid.GridSize;
                pos  = Vector3.Transform(pos, endpoint.CubeBlock.CubeGrid.WorldMatrix);
                pos2 = Vector3.Transform(pos2, endpoint.CubeBlock.CubeGrid.WorldMatrix);
                Vector3 dir = Vector3.TransformNormal(position.VectorDirection * endpoint.CubeBlock.CubeGrid.GridSize * 0.5f, endpoint.CubeBlock.CubeGrid.WorldMatrix);

                Color color = line.IsFunctional ? Color.Orange : Color.DarkRed;
                color = line.IsWorking ? Color.GreenYellow : color;

                EndpointDebugShape shape = EndpointDebugShape.SHAPE_SPHERE;
                float dirMultiplier      = 1.0f;
                float radius             = 0.05f;

                if (line.GetEndpoint(0) == null || line.GetEndpoint(1) == null)
                {
                    if (line.Type == Common.ObjectBuilders.MyObjectBuilder_ConveyorLine.LineType.SMALL_LINE)
                    {
                        dirMultiplier = 0.2f;
                        radius        = 0.015f;
                        shape         = EndpointDebugShape.SHAPE_SPHERE;
                    }
                    else
                    {
                        dirMultiplier = 0.1f;
                        radius        = 0.015f;
                        shape         = EndpointDebugShape.SHAPE_CAPSULE;
                    }
                }
                else
                {
                    if (line.Type == Common.ObjectBuilders.MyObjectBuilder_ConveyorLine.LineType.SMALL_LINE)
                    {
                        dirMultiplier = 1.0f;
                        radius        = 0.05f;
                        shape         = EndpointDebugShape.SHAPE_SPHERE;
                    }
                    else
                    {
                        dirMultiplier = 0.2f;
                        radius        = 0.05f;
                        shape         = EndpointDebugShape.SHAPE_CAPSULE;
                    }
                }

                MyRenderProxy.DebugDrawLine3D(pos, pos + dir * dirMultiplier, color, color, true);
                if (shape == EndpointDebugShape.SHAPE_SPHERE)
                {
                    MyRenderProxy.DebugDrawSphere(pos, radius * endpoint.CubeBlock.CubeGrid.GridSize, color.ToVector3(), 1.0f, false);
                }
                else if (shape == EndpointDebugShape.SHAPE_CAPSULE)
                {
                    MyRenderProxy.DebugDrawCapsule(pos - dir * dirMultiplier, pos + dir * dirMultiplier, radius * endpoint.CubeBlock.CubeGrid.GridSize, color, false);
                }

                if (MyDebugDrawSettings.DEBUG_DRAW_CONVEYORS_LINE_IDS)
                {
                    MyRenderProxy.DebugDrawText3D(pos2, line.GetHashCode().ToString(), color, 0.6f, false);
                }

                MyRenderProxy.DebugDrawLine3D(pos, centerPos, color, color, false);
            }
        }
Esempio n. 10
0
        public static unsafe void DrawCollisionShape(HkShape shape, MatrixD worldMatrix, float alpha, ref int shapeIndex, string customText = null, bool isPhantom = false)
        {
            Color color = GetShapeColor(shape.ShapeType, ref shapeIndex, isPhantom);

            if (isPhantom)
            {
                alpha *= alpha;
            }
            color.A = (byte)(alpha * 255f);
            bool        smooth    = true;
            float       num       = 0.02f;
            float       num2      = 1.035f;
            bool        flag2     = false;
            HkShapeType shapeType = shape.ShapeType;

            switch (shapeType)
            {
            case HkShapeType.Sphere:
            {
                float radius = ((HkSphereShape)shape).Radius;
                MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, alpha, true, smooth, true, false);
                if (isPhantom)
                {
                    MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, 1f, true, false, true, false);
                    MyRenderProxy.DebugDrawSphere(worldMatrix.Translation, radius, color, 1f, true, false, false, false);
                }
                flag2 = true;
                goto TR_0003;
            }

            case HkShapeType.Cylinder:
            {
                HkCylinderShape shape4 = (HkCylinderShape)shape;
                MyRenderProxy.DebugDrawCylinder(worldMatrix, shape4.VertexA, shape4.VertexB, shape4.Radius, color, alpha, true, smooth, false);
                flag2 = true;
                goto TR_0003;
            }

            case HkShapeType.Triangle:
            {
                HkTriangleShape shape12 = (HkTriangleShape)shape;
                MyRenderProxy.DebugDrawTriangle(shape12.Pt0, shape12.Pt1, shape12.Pt2, Color.Green, false, false, false);
                goto TR_0003;
            }

            case HkShapeType.Box:
            {
                HkBoxShape shape5 = (HkBoxShape)shape;
                MyRenderProxy.DebugDrawOBB(MatrixD.CreateScale((shape5.HalfExtents * 2f) + new Vector3(num)) * worldMatrix, color, alpha, true, smooth, true, false);
                if (isPhantom)
                {
                    MyRenderProxy.DebugDrawOBB(Matrix.CreateScale((shape5.HalfExtents * 2f) + new Vector3(num)) * worldMatrix, color, 1f, true, false, true, false);
                    MyRenderProxy.DebugDrawOBB(Matrix.CreateScale((shape5.HalfExtents * 2f) + new Vector3(num)) * worldMatrix, color, 1f, true, false, false, false);
                }
                flag2 = true;
                goto TR_0003;
            }

            case HkShapeType.Capsule:
            {
                HkCapsuleShape shape3 = (HkCapsuleShape)shape;
                MyRenderProxy.DebugDrawCapsule(Vector3.Transform(shape3.VertexA, worldMatrix), Vector3.Transform(shape3.VertexB, worldMatrix), shape3.Radius, color, true, smooth, false);
                flag2 = true;
                goto TR_0003;
            }

            case HkShapeType.ConvexVertices:
            {
                Vector3 vector;
                ((HkConvexVerticesShape)shape).GetGeometry(DebugGeometry, out vector);
                Vector3D vectord2 = Vector3D.Transform(vector, worldMatrix.GetOrientation());
                MatrixD  xd       = worldMatrix;
                xd = MatrixD.CreateScale((double)num2) * xd;
                MatrixD *xdPtr1 = (MatrixD *)ref xd;
                xdPtr1.Translation -= vectord2 * (num2 - 1f);
                DrawGeometry(DebugGeometry, xd, color, true, true);
                flag2 = true;
                goto TR_0003;
            }

            case HkShapeType.TriSampledHeightFieldCollection:
            case HkShapeType.TriSampledHeightFieldBvTree:
            case HkShapeType.SampledHeightField:
            case HkShapeType.ExtendedMesh:
            case HkShapeType.Transform:
            case HkShapeType.CompressedMesh:
            case HkShapeType.Collection:
            case HkShapeType.User0:
            case HkShapeType.User1:
            case HkShapeType.User2:
                goto TR_0003;

            case HkShapeType.List:
            {
                HkShapeContainerIterator iterator = ((HkListShape)shape).GetIterator();
                while (iterator.IsValid)
                {
                    DrawCollisionShape(iterator.CurrentValue, worldMatrix, alpha, ref shapeIndex, customText, false);
                    iterator.Next();
                }
                goto TR_0003;
            }

            case HkShapeType.Mopp:
                DrawCollisionShape((HkShape)((HkMoppBvTreeShape)shape).ShapeCollection, worldMatrix, alpha, ref shapeIndex, customText, false);
                goto TR_0003;

            case HkShapeType.ConvexTranslate:
            {
                HkConvexTranslateShape shape7 = (HkConvexTranslateShape)shape;
                DrawCollisionShape((HkShape)shape7.ChildShape, Matrix.CreateTranslation(shape7.Translation) * worldMatrix, alpha, ref shapeIndex, customText, false);
                goto TR_0003;
            }

            case HkShapeType.ConvexTransform:
            {
                HkConvexTransformShape shape8 = (HkConvexTransformShape)shape;
                DrawCollisionShape((HkShape)shape8.ChildShape, shape8.Transform * worldMatrix, alpha, ref shapeIndex, customText, false);
                goto TR_0003;
            }

            case HkShapeType.StaticCompound:
            {
                HkStaticCompoundShape shape11 = (HkStaticCompoundShape)shape;
                if (DebugDrawFlattenHierarchy)
                {
                    HkShapeContainerIterator iterator2 = shape11.GetIterator();
                    while (iterator2.IsValid)
                    {
                        if (shape11.IsShapeKeyEnabled(iterator2.CurrentShapeKey))
                        {
                            object[] objArray1 = new object[4];
                            object[] objArray2 = new object[4];
                            objArray2[0] = customText ?? string.Empty;
                            object[] local2 = objArray2;
                            local2[1] = "-";
                            local2[2] = iterator2.CurrentShapeKey;
                            local2[3] = "-";
                            string str = string.Concat(local2);
                            DrawCollisionShape(iterator2.CurrentValue, worldMatrix, alpha, ref shapeIndex, str, false);
                        }
                        iterator2.Next();
                    }
                }
                else
                {
                    for (int i = 0; i < shape11.InstanceCount; i++)
                    {
                        string str2;
                        bool   flag3 = shape11.IsInstanceEnabled(i);
                        if (flag3)
                        {
                            object[] objArray3 = new object[4];
                            object[] objArray4 = new object[4];
                            objArray4[0] = customText ?? string.Empty;
                            object[] local4 = objArray4;
                            local4[1] = "<";
                            local4[2] = i;
                            local4[3] = ">";
                            str2      = string.Concat(local4);
                        }
                        else
                        {
                            object[] objArray5 = new object[4];
                            object[] objArray6 = new object[4];
                            objArray6[0] = customText ?? string.Empty;
                            object[] local6 = objArray6;
                            local6[1] = "(";
                            local6[2] = i;
                            local6[3] = ")";
                            str2      = string.Concat(local6);
                        }
                        if (flag3)
                        {
                            DrawCollisionShape(shape11.GetInstance(i), shape11.GetInstanceTransform(i) * worldMatrix, alpha, ref shapeIndex, str2, false);
                        }
                    }
                }
                goto TR_0003;
            }

            case HkShapeType.BvCompressedMesh:
                break;

            case HkShapeType.BvTree:
            {
                HkGridShape shape13 = (HkGridShape)shape;
                if (HkGridShapeCellDebugDraw && !shape13.Base.IsZero)
                {
                    float cellSize       = shape13.CellSize;
                    int   shapeInfoCount = shape13.GetShapeInfoCount();
                    for (int i = 0; i < shapeInfoCount; i++)
                    {
                        try
                        {
                            Vector3S vectors;
                            Vector3S vectors2;
                            shape13.GetShapeInfo(i, out vectors, out vectors2, m_tmpShapeList);
                            Vector3 position = (Vector3)(((vectors2 * cellSize) + (vectors * cellSize)) / 2f);
                            Color   color2   = color;
                            if (vectors == vectors2)
                            {
                                color2 = new Color(1f, 0.2f, 0.1f);
                            }
                            MyRenderProxy.DebugDrawOBB((Matrix.CreateScale((((vectors2 * cellSize) - (vectors * cellSize)) + (Vector3.One * cellSize)) + new Vector3(num)) * Matrix.CreateTranslation(position)) * worldMatrix, color2, alpha, true, smooth, true, false);
                        }
                        finally
                        {
                            m_tmpShapeList.Clear();
                        }
                    }
                }
                else
                {
                    MyRenderMessageDebugDrawTriangles msgInterface = MyRenderProxy.PrepareDebugDrawTriangles();
                    try
                    {
                        using (HkShapeBuffer buffer = new HkShapeBuffer())
                        {
                            HkShapeContainerIterator iterator3 = ((HkBvTreeShape)shape).GetIterator(buffer);
                            while (iterator3.IsValid)
                            {
                                HkShape currentValue = iterator3.CurrentValue;
                                if (currentValue.ShapeType != HkShapeType.Triangle)
                                {
                                    DrawCollisionShape(currentValue, worldMatrix, alpha, ref shapeIndex, null, false);
                                }
                                else
                                {
                                    HkTriangleShape shape17 = (HkTriangleShape)currentValue;
                                    msgInterface.AddTriangle(shape17.Pt0, shape17.Pt1, shape17.Pt2);
                                }
                                iterator3.Next();
                            }
                            goto TR_0003;
                        }
                    }
                    finally
                    {
                        msgInterface.Color = color;
                        MyRenderProxy.DebugDrawTriangles(msgInterface, new MatrixD?(worldMatrix), false, false, false, false);
                    }
                    break;
                }
                goto TR_0003;
            }

            default:
                if (shapeType == HkShapeType.Bv)
                {
                    HkBvShape shape19 = (HkBvShape)shape;
                    DrawCollisionShape(shape19.BoundingVolumeShape, worldMatrix, alpha, ref shapeIndex, null, true);
                    DrawCollisionShape(shape19.ChildShape, worldMatrix, alpha, ref shapeIndex, null, false);
                }
                else if (shapeType == HkShapeType.PhantomCallback)
                {
                    MyRenderProxy.DebugDrawText3D(worldMatrix.Translation, "Phantom", Color.Green, 0.75f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
                }
                goto TR_0003;
            }
            if (MyDebugDrawSettings.DEBUG_DRAW_TRIANGLE_PHYSICS)
            {
                ((HkBvCompressedMeshShape)shape).GetGeometry(DebugGeometry);
                DrawGeometry(DebugGeometry, worldMatrix, Color.Green, false, false);
                flag2 = true;
            }
TR_0003:
            if (flag2 && (customText != null))
            {
                color.A = 0xff;
                MyRenderProxy.DebugDrawText3D(worldMatrix.Translation, customText, color, 0.8f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false);
            }
        }