예제 #1
0
 public static void MarioKart_MKDS_KCL_Generate(String OBJPath, String OutPath, Dictionary<String, ushort> TypeMapping)
 {
     MKDS.KCL k = new MKDS.KCL();
     OBJ o = new OBJ(File.ReadAllBytes(OBJPath));
     List<String> matnames = new List<string>();
     foreach (var v in o.Faces) if (!matnames.Contains(v.Material)) matnames.Add(v.Material);
     Dictionary<string, bool> Colli = new Dictionary<string,bool>();
     foreach (string s in matnames)
     {
         if (!TypeMapping.ContainsKey(s)) TypeMapping.Add(s, 0);
         Colli.Add(s, true);
     }
     k.FromOBJ(o, TypeMapping, Colli);
     File.Create(OutPath).Close();
     File.WriteAllBytes(OutPath, k.Write());
 }
예제 #2
0
 public void FileClosed(ViewableFile File)
 {
     if (File.FileFormat is MKDS.KCL && File.FileFormat == KCL) KCL = null;
     ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(MKDS.KCL));
     menuItem1.MenuItems.Clear();
     foreach (var vv in v)
     {
         menuItem1.MenuItems.Add(vv.File.Name);
     }
     if (v.Length != 0)
     {
         menuItem1.MenuItems[0].Checked = true;
         KCL = v[0].FileFormat;
     }
     Render();
     Render();
 }
예제 #3
0
 public void FileClosed(ViewableFile File)
 {
     if (File.FileFormat is MKDS.KCL && File.FileFormat == KCL)
     {
         KCL = null;
     }
     ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(MKDS.KCL));
     menuItem1.MenuItems.Clear();
     foreach (var vv in v)
     {
         menuItem1.MenuItems.Add(vv.File.Name);
     }
     if (v.Length != 0)
     {
         menuItem1.MenuItems[0].Checked = true;
         KCL = v[0].FileFormat;
     }
     Render();
     Render();
 }
예제 #4
0
 public void FileOpened(ViewableFile File)
 {
     ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(MKDS.KCL));
     menuItem1.MenuItems.Clear();
     bool curavab = false;
     foreach (var vv in v)
     {
         var m = menuItem1.MenuItems.Add(vv.File.Name);
         if (vv.FileFormat == KCL)
         {
             curavab = true;
             m.Checked = true;
         }
     }
     if (!curavab && v.Length != 0)
     {
         menuItem1.MenuItems[0].Checked = true;
         KCL = v[0].FileFormat;
     }
     Render();
     Render();
 }
예제 #5
0
        public void FileOpened(ViewableFile File)
        {
            ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(MKDS.KCL));
            menuItem1.MenuItems.Clear();
            bool curavab = false;

            foreach (var vv in v)
            {
                var m = menuItem1.MenuItems.Add(vv.File.Name);
                if (vv.FileFormat == KCL)
                {
                    curavab   = true;
                    m.Checked = true;
                }
            }
            if (!curavab && v.Length != 0)
            {
                menuItem1.MenuItems[0].Checked = true;
                KCL = v[0].FileFormat;
            }
            Render();
            Render();
        }
예제 #6
0
        private void NKMDViewer_Load(object sender, EventArgs e)
        {
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glDepthFunc(Gl.GL_ALWAYS);
            Gl.glEnable(Gl.GL_LOGIC_OP);
            Gl.glDisable(Gl.GL_CULL_FACE);
            Gl.glEnable(Gl.GL_TEXTURE_2D);
            Gl.glEnable(Gl.GL_LINE_SMOOTH);
            Gl.glEnable(Gl.GL_BLEND);

            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);

            ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(MKDS.KCL));
            menuItem1.MenuItems.Clear();
            foreach (var vv in v)
            {
                menuItem1.MenuItems.Add(vv.File.Name);
            }
            if (v.Length != 0)
            {
                menuItem1.MenuItems[0].Checked = true;
                KCL = v[0].FileFormat;
            }

            if (NKMD.ObjectInformation != null)
            {
                TabPage p = new TabPage("OBJI");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.OBJI.OBJIEntry>(NKMD.ObjectInformation) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.Path != null)
            {
                TabPage p = new TabPage("PATH");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.PATH.PATHEntry>(NKMD.Path) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.Point != null)
            {
                TabPage p = new TabPage("POIT");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.POIT.POITEntry>(NKMD.Point) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointStart != null)
            {
                TabPage p = new TabPage("KTPS");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.KTPS.KTPSEntry>(NKMD.KartPointStart) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointJugem != null)
            {
                TabPage p = new TabPage("KTPJ");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.KTPJ.KTPJEntry>(NKMD.KartPointJugem) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointSecond != null)
            {
                TabPage p = new TabPage("KTP2");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.KTP2.KTP2Entry>(NKMD.KartPointSecond) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointCannon != null)
            {
                TabPage p = new TabPage("KTPC");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.KTPC.KTPCEntry>(NKMD.KartPointCannon) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointMission != null)
            {
                TabPage p = new TabPage("KTPM");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer<MKDS.NKMD.KTPM.KTPMEntry>(NKMD.KartPointMission) { Dock = DockStyle.Fill });
                tabControl1.TabPages.Add(p);
            }

            Bitmap b3 = OBJI.OBJ_2D01;
            System.Resources.ResourceSet s = OBJI.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, false, false);
            foreach (Object b in s)
            {
                Bitmap b2 = ((Bitmap)((System.Collections.DictionaryEntry)b).Value);
                BitmapData bd = b2.LockBits(new Rectangle(0, 0, b2.Width, b2.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE);
                if ((String)((System.Collections.DictionaryEntry)b).Key != "start")
                {
                    Gl.glBindTexture(Gl.GL_TEXTURE_2D, BitConverter.ToUInt16(BitConverter.GetBytes(ushort.Parse(((String)((System.Collections.DictionaryEntry)b).Key).Split('_')[1], System.Globalization.NumberStyles.HexNumber)).Reverse().ToArray(), 0));
                }
                else
                {
                    Gl.glBindTexture(Gl.GL_TEXTURE_2D, -1);
                }
                Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, b2.Width, b2.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, bd.Scan0);
                b2.UnlockBits(bd);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST);
            }
            init = true;
            Render();
            Render();
        }
예제 #7
0
        private void NKMDViewer_Load(object sender, EventArgs e)
        {
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glDepthFunc(Gl.GL_ALWAYS);
            Gl.glEnable(Gl.GL_LOGIC_OP);
            Gl.glDisable(Gl.GL_CULL_FACE);
            Gl.glEnable(Gl.GL_TEXTURE_2D);
            Gl.glEnable(Gl.GL_LINE_SMOOTH);
            Gl.glEnable(Gl.GL_BLEND);

            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);

            ViewableFile[] v = EveryFileExplorerUtil.GetOpenFilesOfType(typeof(MKDS.KCL));
            menuItem1.MenuItems.Clear();
            foreach (var vv in v)
            {
                menuItem1.MenuItems.Add(vv.File.Name);
            }
            if (v.Length != 0)
            {
                menuItem1.MenuItems[0].Checked = true;
                KCL = v[0].FileFormat;
            }

            if (NKMD.ObjectInformation != null)
            {
                TabPage p = new TabPage("OBJI");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.OBJI.OBJIEntry>(NKMD.ObjectInformation)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.Path != null)
            {
                TabPage p = new TabPage("PATH");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.PATH.PATHEntry>(NKMD.Path)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.Point != null)
            {
                TabPage p = new TabPage("POIT");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.POIT.POITEntry>(NKMD.Point)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointStart != null)
            {
                TabPage p = new TabPage("KTPS");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.KTPS.KTPSEntry>(NKMD.KartPointStart)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointJugem != null)
            {
                TabPage p = new TabPage("KTPJ");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.KTPJ.KTPJEntry>(NKMD.KartPointJugem)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointSecond != null)
            {
                TabPage p = new TabPage("KTP2");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.KTP2.KTP2Entry>(NKMD.KartPointSecond)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointCannon != null)
            {
                TabPage p = new TabPage("KTPC");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.KTPC.KTPCEntry>(NKMD.KartPointCannon)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }
            if (NKMD.KartPointMission != null)
            {
                TabPage p = new TabPage("KTPM");
                p.Controls.Add(new LibEveryFileExplorer.UI.GameDataSectionViewer <MKDS.NKMD.KTPM.KTPMEntry>(NKMD.KartPointMission)
                {
                    Dock = DockStyle.Fill
                });
                tabControl1.TabPages.Add(p);
            }

            Bitmap b3 = OBJI.OBJ_2D01;

            System.Resources.ResourceSet s = OBJI.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, false, false);
            foreach (Object b in s)
            {
                Bitmap     b2 = ((Bitmap)((System.Collections.DictionaryEntry)b).Value);
                BitmapData bd = b2.LockBits(new Rectangle(0, 0, b2.Width, b2.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE);
                if ((String)((System.Collections.DictionaryEntry)b).Key != "start")
                {
                    Gl.glBindTexture(Gl.GL_TEXTURE_2D, BitConverter.ToUInt16(BitConverter.GetBytes(ushort.Parse(((String)((System.Collections.DictionaryEntry)b).Key).Split('_')[1], System.Globalization.NumberStyles.HexNumber)).Reverse().ToArray(), 0));
                }
                else
                {
                    Gl.glBindTexture(Gl.GL_TEXTURE_2D, -1);
                }
                Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA8, b2.Width, b2.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, bd.Scan0);
                b2.UnlockBits(bd);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST);
                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST);
            }
            init = true;
            Render();
            Render();
        }