Defines a mapping of block types to materials.
示例#1
0
            /// <summary>
            /// Renders the chunk with the specified parameters.
            /// </summary>
            public void Render(Chunk[] Sides, Slice?Slice, Scheme Scheme)
            {
                RenderCache rc = this._GetCache(Scheme);
                Slice       s  = Slice.GetValueOrDefault(new Slice()
                {
                    Axis = Axis.Z, StartLevel = 0, EndLevel = ChunkSize
                });

                if (s.StartLevel < 0)
                {
                    s.StartLevel = 0;
                }
                if (s.EndLevel >= ChunkSize)
                {
                    s.EndLevel = ChunkSize - 1;
                }
                if (s.EndLevel >= s.StartLevel)
                {
                    if (s.StartLevel > 0 || s.EndLevel < ChunkSize - 1)
                    {
                        rc.InteriorRenderer.Render(s.Axis, s.StartLevel, s.EndLevel);
                    }
                    else
                    {
                        rc.InteriorRenderer.Render();
                    }

                    // Here marks the worst code in the program
                    if (s.Axis == Axis.Z)
                    {
                        if (s.EndLevel == ChunkSize - 1)
                        {
                            rc.GetSide(Axis.Z, Polarity.Positive, Axis.Z, this._DataOctree).Render();
                        }
                        if (s.StartLevel == 0 && s.EndLevel == ChunkSize - 1)
                        {
                            for (int t = 0; t < 4; t++)
                            {
                                Axis     ax  = (Axis)(t % 2);
                                Polarity pol = (Polarity)(t / 2);
                                if (Sides[t] == null)
                                {
                                    rc.GetSide(ax, pol, ax, this._DataOctree).Render();
                                }
                                else
                                {
                                    if (t < 2)
                                    {
                                        rc.GetInteriorSide(ax, Sides[t], ax, this._DataOctree).Render();
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int t = 0; t < 4; t++)
                            {
                                Axis     ax  = (Axis)(t % 2);
                                Polarity pol = (Polarity)(t / 2);
                                if (Sides[t] == null)
                                {
                                    rc.GetSide(ax, pol, Axis.Z, this._DataOctree).Render(s.StartLevel, 0, s.EndLevel, 2);
                                }
                                else
                                {
                                    if (t < 2)
                                    {
                                        rc.GetInteriorSide(ax, Sides[t], Axis.Z, this._DataOctree).Render(s.StartLevel, 0, s.EndLevel, 2);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Axis oppose = (Axis)(((int)s.Axis + 1) % 2);
                        if (s.StartLevel == 0)
                        {
                            if (Sides[(int)s.Axis + 2] == null)
                            {
                                rc.GetSide(s.Axis, Polarity.Negative, s.Axis, this._DataOctree).Render();
                            }
                        }
                        if (s.EndLevel == ChunkSize - 1)
                        {
                            if (Sides[(int)s.Axis] == null)
                            {
                                rc.GetSide(s.Axis, Polarity.Positive, s.Axis, this._DataOctree).Render();
                            }
                            else
                            {
                                rc.GetInteriorSide(s.Axis, Sides[(int)s.Axis], s.Axis, this._DataOctree).Render();
                            }
                        }
                        if (s.StartLevel == 0 && s.EndLevel == ChunkSize - 1)
                        {
                            rc.GetSide(Axis.Z, Polarity.Positive, Axis.Z, this._DataOctree).Render();
                            if (Sides[(int)oppose + 2] == null)
                            {
                                rc.GetSide(oppose, Polarity.Negative, oppose, this._DataOctree).Render();
                            }
                            if (Sides[(int)oppose] == null)
                            {
                                rc.GetSide(oppose, Polarity.Positive, oppose, this._DataOctree).Render();
                            }
                            else
                            {
                                rc.GetInteriorSide(oppose, Sides[(int)oppose], oppose, this._DataOctree).Render();
                            }
                        }
                        else
                        {
                            rc.GetSide(Axis.Z, Polarity.Positive, s.Axis, this._DataOctree).Render(s.StartLevel, 0, s.EndLevel, 2);
                            if (Sides[(int)oppose + 2] == null)
                            {
                                rc.GetSide(oppose, Polarity.Negative, s.Axis, this._DataOctree).Render(s.StartLevel, 0, s.EndLevel, 2);
                            }
                            if (Sides[(int)oppose] == null)
                            {
                                rc.GetSide(oppose, Polarity.Positive, s.Axis, this._DataOctree).Render(s.StartLevel, 0, s.EndLevel, 2);
                            }
                            else
                            {
                                rc.GetInteriorSide(oppose, Sides[(int)oppose], s.Axis, this._DataOctree).Render(s.StartLevel, 0, s.EndLevel, 2);
                            }
                        }
                    }
                }
            }
示例#2
0
 public frmKey(Scheme scheme)
 {
     InitializeComponent();
     _Scheme = scheme;
 }
示例#3
0
        public static void Main(string[] Args)
        {
            Application.EnableVisualStyles();
            // Load schemes from lua files
            Dictionary <string, Scheme> schemes = null;

            try
            {
                string     path = Application.StartupPath + Path.DirectorySeparatorChar + "scheme.lua";
                FileStream str  = File.OpenRead(path);
                schemes = Scheme.Load(str);
                if (!schemes.ContainsKey("Default"))
                {
                    MessageBox.Show("Scheme.lua does not define a scheme named \"Default\"", "Scheme load error");
                    schemes = null;
                }
            }
            catch (LuaException le)
            {
                string error = "";
                error += le.Run ? "Runtime lua " : "Lua syntax ";
                error += "error in scheme.lua: ";
                error += le.LuaDesc;
                MessageBox.Show(error, "Scheme load error");
            }
            catch (FileNotFoundException fnfe)
            {
                MessageBox.Show("Scheme.lua cannot be found", "Scheme load error");
            }


            if (schemes != null)
            {
                WorldSelect ws = new WorldSelect();
                ws.Show();
                while (ws.Visible)
                {
                    Application.DoEvents();
                }

                string world = ws.World;

                if (world != null)
                {
#if RELEASEMODE
                    try
                    {
#endif
                    Window win = new Window(world, ws.Nether, schemes);
                    win.TargetUpdateFrequency = 60.0;
                    win.VSync = OpenTK.VSyncMode.On;
                    win.Run(60.0, 60.0);
#if RELEASEMODE
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error has occurred and the error contents has been dumped to \"error.txt\"\nPlease report this bug on bugs.xiatek.org (please make sure it has not been posted yet)", "Unhandeled Error");
                    File.AppendAllText("error.txt", "\nERROR:\n" + ex.Message + "\nSTACKTRACE:\n" + ex.StackTrace);
                }
#endif
                }
            }
        }
示例#4
0
 public frmKey(Scheme scheme)
 {
     InitializeComponent();
     _Scheme = scheme;
 }