public override void Draw()
        {
            if (MySector.MainCamera == null)
            {
                return;
            }

            base.Draw();

            //Vector3D compassPosition = MySector.MainCamera.Position + MySector.MainCamera.ForwardVector + MySector.MainCamera.LeftVector / 1.5f - MySector.MainCamera.UpVector / 2;
            //VRageRender.MyRenderProxy.DebugDrawAxis(MatrixD.CreateTranslation(compassPosition), 0.1f, false);
            //VRageRender.MyRenderProxy.DebugDrawSphere(compassPosition, 0.02f, Color.White, 0.4f, false);

            if (MyDebugDrawSettings.DEBUG_DRAW_FRACTURED_PIECES)
            {
                foreach (var entity in MyEntities.GetEntities())
                {
                    var piece = entity as MyFracturedPiece;
                    if (piece != null)
                    {
                        MyPhysicsDebugDraw.DebugDrawBreakable(piece.Physics.BreakableBody, piece.Physics.ClusterToWorld(Vector3D.Zero));
                    }
                }
            }



            return;

            var   mat       = "WeaponLaser";
            float thickness = 0.05f;

            float   spacing = 5;
            int     count   = 100;
            Vector4 color   = Color.White.ToVector4();

            //Vector3 center = MySector.MainCamera.Position + new Vector3(0, -10, 0);
            Vector3 center   = Vector3.Zero;
            Vector3 startPos = center - new Vector3(spacing * count / 2, 0, 0);

            for (int i = 0; i < count; i++)
            {
                Vector3D lineStart = startPos + new Vector3(spacing * i, 0, -spacing * count / 2);
                Vector3D lineEnd   = startPos + new Vector3(spacing * i, 0, spacing * count / 2);

                Vector3D closestPoint = Vector3.Zero;
                Vector3D campos       = MySector.MainCamera.Position;
                closestPoint = MyUtils.GetClosestPointOnLine(ref lineStart, ref lineEnd, ref campos);
                var distance = MySector.MainCamera.GetDistanceWithFOV(closestPoint);

                var lineThickness = thickness * MathHelper.Clamp(distance, 0.1f, 10);

                MySimpleObjectDraw.DrawLine(lineStart, lineEnd, mat, ref color, (float)lineThickness);
            }
        }
Ejemplo n.º 2
0
 public override void UpdateBeforeSimulation()
 {
     if (MyDebugDrawSettings.DEBUG_DRAW_TREE_COLLISION_SHAPES)
     {
         MyPhysicsComponentBase physics = base.Physics;
         if (physics != null)
         {
             HkRigidBody rigidBody = physics.RigidBody;
             if (rigidBody != null)
             {
                 int shapeIndex = 0;
                 MyPhysicsDebugDraw.DrawCollisionShape(rigidBody.GetShape(), physics.GetWorldMatrix(), 1f, ref shapeIndex, physics.IsActive ? "A" : "I", false);
             }
         }
     }
 }
        public static void DrawMountPoints(float cubeSize, MyCubeBlockDefinition def, ref MatrixD drawMatrix)
        {
            var mountPoints = def.GetBuildProgressModelMountPoints(1.0f);

            if (mountPoints == null)
            {
                return;
            }

            if (!MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AUTOGENERATE)
            {
                DrawMountPoints(cubeSize, def, drawMatrix, mountPoints);
            }
            else
            {   //Generate mount points from model collisions and draw them
                if (def.Model != null)
                {
                    int     index = 0;
                    MyModel model = VRage.Game.Models.MyModels.GetModel(def.Model);

                    foreach (var shape in model.HavokCollisionShapes)
                    {
                        MyPhysicsDebugDraw.DrawCollisionShape(shape, drawMatrix, 0.2f, ref index);
                    }

                    var newMountPoints = AutogenerateMountpoints(model, cubeSize);

                    DrawMountPoints(cubeSize, def, drawMatrix, newMountPoints.ToArray());
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS_HELPERS)
            {
                DrawMountPointsAxisHelpers(def, ref drawMatrix, cubeSize);
            }
        }