示例#1
0
        public void LoadModel(string filename)
        {
            try
            {
                switch (Path.GetExtension(filename).ToLower())
                {
                case ".obj":
                    OBJ obj = OBJ.FromFile(filename);
                    ctr = CtrModel.FromObj(obj);
                    break;

                case ".ply":
                    ctr = CtrModel.FromPly(filename);
                    break;

                default:
                    MessageBox.Show("Unsupported model.");
                    break;
                }

                UpdateUI();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        static void ConvertFile(string filename)
        {
            string basepath = Path.GetDirectoryName(filename);
            string name     = Path.GetFileNameWithoutExtension(filename);
            string ext      = Path.GetExtension(filename).ToLower();

            switch (ext)
            {
            case ".lev":
            {
                Scene scn = Scene.FromFile(filename);
                //scn.quads = scn.quads.OrderBy(o => o.id).ToList();
                scn.Export(basepath, ExportFlags.All);
                break;
            }

            case ".ctr":
            case ".dyn":
            {
                CtrModel d = CtrModel.FromFile(filename);
                d.Export(basepath);

                break;
            }

            case ".obj":
            {
                OBJ      obj = OBJ.FromFile(filename);
                CtrModel ctr = CtrModel.FromObj(obj);
                ctr.Save(basepath);

                break;
            }

            case ".ply":
            {
                CtrModel ctr = CtrModel.FromPly(filename);
                ctr.Save(basepath);

                break;
            }

            case ".mpk":
            {
                string vrampath = Path.ChangeExtension(filename, "vrm");

                if (!File.Exists(vrampath))
                {
                    vrampath = Path.Combine(Path.GetDirectoryName(filename), "shared.vrm");

                    if (!File.Exists(vrampath))
                    {
                        Console.WriteLine("Warning! No vram file found.\r\nPlease put shared.vrm file with mpk you want to extract.");
                        vrampath = "";
                    }
                }

                ModelPack mpk = ModelPack.FromFile(filename);
                mpk.Extract(Path.Combine(basepath, name), CtrVrm.FromFile(vrampath).GetVram());

                break;
            }

            default:
            {
                Console.WriteLine($"Unsupported file: {filename}");
                return;
            }
            }

            Console.WriteLine("Done!");
        }