Example #1
0
        public string getTypeName(CreatorMain.CreatorType typeName)
        {
            string name = "Z";

            if (typeName == CreatorMain.CreatorType.X)
            {
                name = "X";
            }
            if (typeName == CreatorMain.CreatorType.Y)
            {
                name = "Y";
            }
            return(name);
        }
        /// <summary>
        /// 圆环
        /// </summary>
        /// <param name="Position"></param>
        /// <param name="Height"></param>
        /// <param name="Radius"></param>
        /// <param name="Hollow"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public IEnumerable <Point3> Circle(Point3 Position, int Height, int Radius, CreatorMain.CreatorType type = CreatorMain.CreatorType.Y, bool Hollow = false)
        {
            int _Radius = Height - Radius;

            for (int x = -Radius; x <= Radius; x++)
            {
                int _radius = _Radius + Radius - x;
                for (int z = -Radius; z <= Radius; z++)
                {
                    if (((int)Math.Sqrt(x * x + z * z)) <= Radius)
                    {
                        if (Hollow && (int)Math.Sqrt((Math.Abs(x) + 1) * (Math.Abs(x) + 1) + z * z) <= Radius && (int)Math.Sqrt(x * x + (Math.Abs(z) + 1) * (Math.Abs(z) + 1)) <= Radius)
                        {
                            continue;
                        }
                        for (int x_2 = -_radius; x_2 <= _radius; x_2++)
                        {
                            for (int z_2 = -_radius; z_2 <= _radius; z_2++)
                            {
                                if (((int)Math.Sqrt(x_2 * x_2 + z_2 * z_2)) <= _radius)
                                {
                                    if ((int)Math.Sqrt((float)(Math.Abs(x_2) + 0.5f) * ((float)Math.Abs(x_2) + 0.5f) + (Math.Abs(z_2) + 1) * (Math.Abs(z_2) + 1)) <= _radius && (int)Math.Sqrt((Math.Abs(x_2) + 1) * (Math.Abs(x_2) + 1) + ((float)Math.Abs(z_2) + 0.5f) * ((float)Math.Abs(z_2) + 0.5f)) <= _radius)
                                    {
                                        continue;
                                    }
                                    if (type == CreatorMain.CreatorType.Y)
                                    {
                                        yield return(new Point3(Position.X + x_2, Position.Y + z, Position.Z + z_2));
                                    }
                                    else if (type == CreatorMain.CreatorType.X)
                                    {
                                        yield return(new Point3(Position.X + z, Position.Y + x_2, Position.Z + z_2));
                                    }
                                    else
                                    {
                                        yield return(new Point3(Position.X + z_2, Position.Y + x_2, Position.Z + z));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #3
0
 public override void upDataButton(CreatorMain.CreatorType creatorType, ButtonWidget button)
 {
     if (this.creatorType != creatorType)
     {
         this.creatorType = creatorType;
         button.Color     = Color.Green;
         if (X_Shaft != button)
         {
             X_Shaft.Color = Color.White;
         }
         if (Y_Shaft != button)
         {
             Y_Shaft.Color = Color.White;
         }
         if (Z_Shaft != button)
         {
             Z_Shaft.Color = Color.White;
         }
     }
 }
Example #4
0
 public override void upDataButton(CreatorMain.CreatorType creatorType, ButtonWidget button)
 {
     if (this.creatorType == creatorType)
     {
         if (typeBool)
         {
             typeBool     = false;
             button.Text  = $"负{getTypeName(creatorType)}轴";
             button.Color = Color.Red;
         }
         else
         {
             typeBool     = true;
             button.Text  = $"正{getTypeName(creatorType)}轴";
             button.Color = Color.Green;
         }
     }
     else
     {
         typeBool         = true;
         this.creatorType = creatorType;
         button.Text      = $"正{getTypeName(creatorType)}轴";
         button.Color     = Color.Green;
         if (X_Shaft != button)
         {
             X_Shaft.Text  = "X轴";
             X_Shaft.Color = Color.White;
         }
         if (Y_Shaft != button)
         {
             Y_Shaft.Text  = "Y轴";
             Y_Shaft.Color = Color.White;
         }
         if (Z_Shaft != button)
         {
             Z_Shaft.Text  = "Z轴";
             Z_Shaft.Color = Color.White;
         }
     }
 }
 /// <summary>
 /// 螺旋
 /// </summary>
 /// <param name="Position"></param>
 /// <param name="Height"></param>
 /// <param name="Radius"></param>
 /// <param name="Number"></param>
 /// <returns></returns>
 public IEnumerable <Point3> Spiral(Point3 Position, int Height, int Radius, int Number, CreatorMain.CreatorType creatorType = CreatorMain.CreatorType.Y, bool YType = true)
 {
     for (int angle = 0; angle <= 360 * Number; angle++)
     {
         float x = (float)Radius * angle / 360 * MathUtils.Cos(angle * MathUtils.PI / 180);
         float z = (float)Radius * angle / 360 * MathUtils.Sin(angle * MathUtils.PI / 180);
         for (int y = 0; y <= Height - 1; y++)
         {
             int Y;
             if (YType)
             {
                 Y = y;
             }
             else
             {
                 Y = -y;
             }
             if (creatorType == CreatorMain.CreatorType.X)
             {
                 yield return(new Point3(Position.X + Y, Position.Y + (int)x, Position.Z + (int)z));
             }
             else if (creatorType == CreatorMain.CreatorType.Y)
             {
                 yield return(new Point3(Position.X + (int)x, Position.Y + Y, Position.Z + (int)z));
             }
             else
             {
                 yield return(new Point3(Position.X + (int)x, Position.Y + (int)z, Position.Z + Y));
             }
         }
     }
 }
 /// <summary>
 /// 柱子
 /// </summary>
 /// <param name="Position"></param>
 /// <param name="Radius"></param>
 /// <param name="Height"></param>
 /// <param name="Hollow"></param>
 /// <param name="creatorType"></param>
 /// <param name="YType"></param>
 /// <param name="XYZType"></param>
 /// <param name="typeBool"></param>
 /// <returns></returns>
 public IEnumerable <Point3> Pillars(Point3 Position, int Radius, int Height, CreatorMain.CreatorType creatorType = CreatorMain.CreatorType.Y, bool YType = true, bool Hollow = false, CreatorMain.CreatorType?XYZType = null, bool typeBool = false)
 {
     for (int y = 0; y < Height; y++)
     {
         for (int x = -Radius; x <= Radius; x++)
         {
             for (int z = -Radius; z <= Radius; z++)
             {
                 if (XYZType != null)
                 {
                     if (XYZType == CreatorMain.CreatorType.X)
                     {
                         if (typeBool)
                         {
                             if (Position.X + x < Position.X)
                             {
                                 continue;
                             }
                         }
                         else
                         {
                             if (Position.X + x > Position.X)
                             {
                                 continue;
                             }
                         }
                     }
                     if (XYZType == CreatorMain.CreatorType.Y)
                     {
                         if (typeBool)
                         {
                             if (Position.Y + y < Position.Y)
                             {
                                 continue;
                             }
                         }
                         else
                         {
                             if (Position.Y + y > Position.Y)
                             {
                                 continue;
                             }
                         }
                     }
                     if (XYZType == CreatorMain.CreatorType.Z)
                     {
                         if (typeBool)
                         {
                             if (Position.Z + z < Position.Z)
                             {
                                 continue;
                             }
                         }
                         else
                         {
                             if (Position.Z + z > Position.Z)
                             {
                                 continue;
                             }
                         }
                     }
                 }
                 if (!(Math.Abs(x) > Radius && Math.Abs(z) > Radius))
                 {
                     if (!(Hollow && (Math.Abs(x) < Radius && Math.Abs(z) < Radius)))
                     {
                         int Y;
                         if (YType)
                         {
                             Y = y;
                         }
                         else
                         {
                             Y = -y;
                         }
                         if (creatorType == CreatorMain.CreatorType.X)
                         {
                             yield return(new Point3(Position.X + Y, Position.Y + x, Position.Z + z));
                         }
                         else if (creatorType == CreatorMain.CreatorType.Y)
                         {
                             yield return(new Point3(Position.X + x, Position.Y + Y, Position.Z + z));
                         }
                         else
                         {
                             yield return(new Point3(Position.X + x, Position.Y + z, Position.Z + Y));
                         }
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// 圆柱
 /// </summary>
 /// <param name="Position"></param>
 /// <param name="Radius"></param>
 /// <param name="Height"></param>
 /// <param name="creatorType"></param>
 /// <param name="YType"></param>
 /// <param name="Hollow"></param>
 /// <returns></returns>
 public IEnumerable <Point3> Cylindrical(Point3 Position, int Radius, int Height, CreatorMain.CreatorType creatorType = CreatorMain.CreatorType.Y, bool YType = true, bool Hollow = false)
 {
     for (int x = -Radius; x <= Radius; x++)
     {
         for (int z = -Radius; z <= Radius; z++)
         {
             if (Math.Sqrt(x * x + z * z) <= Radius)
             {
                 if (Hollow && Math.Sqrt((Math.Abs(x) + 1) * (Math.Abs(x) + 1) + z * z) <= Radius && Math.Sqrt(x * x + (Math.Abs(z) + 1) * (Math.Abs(z) + 1)) <= Radius)
                 {
                     continue;
                 }
                 for (int y = 0; y < Height; y++)
                 {
                     int Y;
                     if (YType)
                     {
                         Y = y;
                     }
                     else
                     {
                         Y = -y;
                     }
                     if (creatorType == CreatorMain.CreatorType.X)
                     {
                         yield return(new Point3(Position.X + Y, Position.Y + x, Position.Z + z));
                     }
                     else if (creatorType == CreatorMain.CreatorType.Y)
                     {
                         yield return(new Point3(Position.X + x, Position.Y + Y, Position.Z + z));
                     }
                     else
                     {
                         yield return(new Point3(Position.X + x, Position.Y + z, Position.Z + Y));
                     }
                 }
             }
         }
     }
 }
        /// <summary>
        /// 圆柱
        /// </summary>
        /// <param name="Position"></param>
        /// <param name="Radius"></param>
        /// <param name="Height"></param>
        /// <param name="Hollow"></param>
        /// <param name="creatorType"></param>
        /// <param name="YType"></param>
        /// <param name="XYZType"></param>
        /// <param name="typeBool"></param>
        /// <returns></returns>
        public IEnumerable <Point3> Cylindrical(Vector3 Position, int XRadius, int Height, int ZRadius, CreatorMain.CreatorType creatorType = CreatorMain.CreatorType.Y, bool YType = true, bool Hollow = false)
        {
            int MaxRadius = Math.Max(XRadius, ZRadius);

            for (int x = -XRadius; x <= XRadius; x++)
            {
                for (int z = -ZRadius; z <= ZRadius; z++)
                {
                    if (((int)Math.Sqrt((float)x * MaxRadius / XRadius * x * MaxRadius / XRadius + (float)z * MaxRadius / ZRadius * z * MaxRadius / ZRadius)) <= MaxRadius)
                    {
                        if (Hollow && (int)Math.Sqrt(((float)Math.Abs(x) + 1) * MaxRadius / XRadius * (Math.Abs(x) + 1) * MaxRadius / XRadius + (float)z * MaxRadius / ZRadius * z * MaxRadius / ZRadius) <= MaxRadius && (int)Math.Sqrt((float)x * x * MaxRadius / XRadius * MaxRadius / XRadius + (float)(Math.Abs(z) + 1) * MaxRadius / ZRadius * (Math.Abs(z) + 1) * MaxRadius / ZRadius) <= MaxRadius)
                        {
                            continue;
                        }
                        for (int y = 0; y < Height; y++)
                        {
                            int Y;
                            if (YType)
                            {
                                Y = y;
                            }
                            else
                            {
                                Y = -y;
                            }
                            if (creatorType == CreatorMain.CreatorType.X)
                            {
                                yield return(new Point3((int)Position.X + Y, (int)Position.Y + x, (int)Position.Z + z));
                            }
                            else if (creatorType == CreatorMain.CreatorType.Y)
                            {
                                yield return(new Point3((int)Position.X + x, (int)Position.Y + Y, (int)Position.Z + z));
                            }
                            else
                            {
                                yield return(new Point3((int)Position.X + x, (int)Position.Y + z, (int)Position.Z + Y));
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// 棱体
 /// </summary>
 /// <param name="Position"></param>
 /// <param name="Radius"></param>
 /// <param name="Hollow"></param>
 /// <param name="creatorType"></param>
 /// <param name="XYZtype"></param>
 /// <param name="typeBool"></param>
 /// <returns></returns>
 public IEnumerable <Point3> Prism(Point3 Position, int Radius, CreatorMain.CreatorType creatorType = CreatorMain.CreatorType.Y, bool Hollow = false, CreatorMain.CreatorType?XYZtype = null, bool typeBool = false)
 {
     for (int x = -Radius; x <= Radius; x++)
     {
         for (int y = -Radius; y <= Radius; y++)
         {
             for (int z = -Radius; z <= Radius; z++)
             {
                 if (XYZtype.HasValue)
                 {
                     if (XYZtype == CreatorMain.CreatorType.X)
                     {
                         if (typeBool)
                         {
                             if (Position.X + x < Position.X)
                             {
                                 continue;
                             }
                         }
                         else
                         {
                             if (Position.X + x > Position.X)
                             {
                                 continue;
                             }
                         }
                     }
                     if (XYZtype == CreatorMain.CreatorType.Y)
                     {
                         if (typeBool)
                         {
                             if (Position.Y + y < Position.Y)
                             {
                                 continue;
                             }
                         }
                         else
                         {
                             if (Position.Y + y > Position.Y)
                             {
                                 continue;
                             }
                         }
                     }
                     if (XYZtype == CreatorMain.CreatorType.Z)
                     {
                         if (typeBool)
                         {
                             if (Position.Z + z < Position.Z)
                             {
                                 continue;
                             }
                         }
                         else
                         {
                             if (Position.Z + z > Position.Z)
                             {
                                 continue;
                             }
                         }
                     }
                 }
                 if (creatorType == CreatorMain.CreatorType.Y)
                 {
                     if ((Math.Abs(x) + Math.Abs(y) > Radius || Math.Abs(z) + Math.Abs(y) > Radius) || (Hollow && Math.Abs(x) + Math.Abs(y) < Radius && Math.Abs(z) + Math.Abs(y) < Radius))
                     {
                         continue;
                     }
                 }
                 if (creatorType == CreatorMain.CreatorType.X)
                 {
                     if ((Math.Abs(x) + Math.Abs(y) > Radius || Math.Abs(z) + Math.Abs(x) > Radius) || (Hollow && Math.Abs(x) + Math.Abs(y) < Radius && Math.Abs(x) + Math.Abs(z) < Radius))
                     {
                         continue;
                     }
                 }
                 if (creatorType == CreatorMain.CreatorType.Z)
                 {
                     if ((Math.Abs(z) + Math.Abs(y) > Radius || Math.Abs(z) + Math.Abs(x) > Radius) || (Hollow && Math.Abs(z) + Math.Abs(y) < Radius && Math.Abs(z) + Math.Abs(x) < Radius))
                     {
                         continue;
                     }
                 }
                 yield return(new Point3(Position.X + x, Position.Y + y, Position.Z + z));
             }
         }
     }
 }