예제 #1
0
 public void SetInfo(BlockInfo blockInfo)
 {
     BlockInfo = blockInfo;
 }
예제 #2
0
                public List <string> to = new List <string>(); //To[3]
                public double[] GetTo(BlockInfo _model, Vector3 Position)
                {
                    var e = Expression(to, _model);

                    return(new double[] { e[0] + Position.X + 0.5, e[1] + Position.Y + 0.5, e[2] + Position.Z + 0.5 });
                }
예제 #3
0
        private static BlockCollection FillFlow(BlockCollection blocks, Vector3 origin, SimpleBlockInfo fill_block, bool reverse = false)
        {
            Current.WriteLine(Environment.NewLine + "- Filling Flow...");
            var m     = blocks.level[blocks.GetWidth() / 2, blocks.GetHeight() / 2, blocks.GetLength() / 2];
            var close = new List <int[]>();
            var newb  = res.GetBlockInfo(fill_block.Id, fill_block.Data, version);

            if (newb == null)
            {
                newb = new BlockInfo(); newb.Id = "$empty";
            }                                                                 //Get Fill Material

            if (origin.X < 0 || origin.X >= blocks.GetWidth() || origin.Y < 0 || origin.Y >= blocks.GetHeight() || origin.Z < 0 || origin.Z >= blocks.GetLength())
            {
                origin.X = blocks.GetWidth() / 2; origin.Y = blocks.GetHeight() / 2; origin.Z = blocks.GetLength() / 2;
            }
            close.Add(new int[] { (int)origin.X, (int)origin.Y, (int)origin.Z });              //Set Finding Origin

            var flowed  = new bool[blocks.GetWidth(), blocks.GetHeight(), blocks.GetLength()]; //Tag: flowed
            var _blocks = new List <BlockCollection.Block>();

            foreach (var b in blocks.blocks)
            {
                _blocks.Add(b);
            }

            while (close.Count() > 0) //Flowing
            {
                var c = new { x = close[close.Count - 1][0], y = close[close.Count - 1][1], z = close[close.Count - 1][2] };
                close.RemoveAt(close.Count - 1);
                if (blocks.level[c.x, c.y, c.z] == m)
                {
                    var block = new BlockCollection.Block();
                    block.SetCoordinate(c.x, c.y, c.z);
                    block.SetInfo(newb);
                    blocks.blocks.Add(block);
                    blocks.level[c.x, c.y, c.z] = block;
                    flowed[c.x, c.y, c.z]       = true;

                    if (c.x - 1 >= 0)
                    {
                        close.Add(new int[] { c.x - 1, c.y, c.z });
                    }
                    if (c.x + 1 < blocks.GetWidth())
                    {
                        close.Add(new int[] { c.x + 1, c.y, c.z });
                    }
                    if (c.y - 1 >= 0)
                    {
                        close.Add(new int[] { c.x, c.y - 1, c.z });
                    }
                    if (c.y + 1 < blocks.GetHeight())
                    {
                        close.Add(new int[] { c.x, c.y + 1, c.z });
                    }
                    if (c.z - 1 >= 0)
                    {
                        close.Add(new int[] { c.x, c.y, c.z - 1 });
                    }
                    if (c.z + 1 < blocks.GetLength())
                    {
                        close.Add(new int[] { c.x, c.y, c.z + 1 });
                    }
                }
            }
            if (reverse)
            {
                Current.WriteLine(Environment.NewLine + "- Reversing Filling Flow...");
                Current.SetProgressBar();
                int current = 0;
                int total   = bcl.GetWidth() * bcl.GetHeight() * bcl.GetLength(); //Fill Empty Regions
                for (int x = 0; x < blocks.GetWidth(); x++)
                {
                    for (int y = 0; y < blocks.GetHeight(); y++)
                    {
                        for (int z = 0; z < blocks.GetLength(); z++)
                        {
                            if (!flowed[x, y, z] && blocks.level[x, y, z] == null)
                            {
                                var block = new BlockCollection.Block();
                                block.SetCoordinate(x, y, z);
                                block.SetInfo(newb);
                                _blocks.Add(block);
                                blocks.level[x, y, z] = block;
                            }
                            //Update Progress
                            current++;
                            Current.DrawProgressBar(current * 100 / total);
                            Current.Write(" " + current + " blocks have been scanned.(total : " + total + " )");
                        }
                    }
                }
                blocks.blocks = _blocks;
            }
            return(blocks);
        }
예제 #4
0
                private int[] GetUV(BlockInfo _info, string directoryPath)
                {
                    var uv   = new int[] { 0, 0 };
                    var t    = GetTexture(_info);
                    var path = "";

                    if (Program.version >= 1.13)
                    {
                        var m = t.Path.ToList();
                        m.RemoveAt(5);
                        path = String.Join(null, m.ToArray());
                    }
                    if (t.Params != null && t.Params.Contains("ColorMap")) //ColorMap
                    {
                        var pars = t.Params.Split(' ');
                        if (pars.Length != 5 && pars[0] != "ColorMap")
                        {
                            uv = GetColorMapUV(Program.temp, Program.rain, 0, false, 0);
                        }
                        else
                        {
                            uv = GetColorMapUV(Program.temp, Program.rain, int.Parse(pars[1]), bool.Parse(pars[2]), float.Parse(pars[3]), float.Parse(pars[4]));
                        }
                    }
                    else //Default
                    {
                        bool textureError = true;
                        if (Program.smooth)
                        {
                            try
                            {
                                Bitmap compare = new Bitmap(directoryPath + "\\textures\\" + path.Replace("/", "\\") + ".png");
                                for (int mh = 0; mh < compare.Size.Height; mh++)
                                {
                                    for (int mw = 0; mw < compare.Size.Width; mw++)
                                    {
                                        if (compare.GetPixel(mh, mw).A > 8)
                                        {
                                            uv[0] = mh; uv[1] = mw; break;
                                        }
                                    }
                                    if (uv[0] > 0 && uv[1] > 0)
                                    {
                                        break;
                                    }
                                }
                            }
                            catch
                            {
                                Current.Error("Texture: " + t.Path + ".png Not Found", false);
                            }
                        }
                        else
                        {
                            while (textureError)
                            {
                                uv[0] = (int)Math.Floor(StaticRandom.NextDouble() * 16);
                                uv[1] = (int)Math.Floor(StaticRandom.NextDouble() * 16);
                                try
                                {
                                    Bitmap compare = new Bitmap(System.Windows.Forms.Application.StartupPath + "\\textures\\" + path.Replace("/", "\\") + ".png");
                                    textureError = (compare.GetPixel((int)uv[0], (int)uv[1]).A <= 8);
                                }
                                catch
                                {
                                    Current.Error("Texture: " + t.Path + ".png Not Found", false);
                                }
                            }
                        }
                    }
                    return(uv);
                }