Exemplo n.º 1
0
        public void TestLoadExtrenalModels()
        {
            string mdlpath = Path.Combine(Meta.BasePath, Meta.ModelsPath);

            if (!Directory.Exists(mdlpath))
            {
                return;
            }

            string[] models = Directory.GetFiles(mdlpath, "*.ctr");

            if (models.Length == 0)
            {
                return;
            }

            foreach (var s in models)
            {
                CtrModel c = CtrModel.FromFile(s);

                if (!ContentVault.Models.ContainsKey(c.Name))
                {
                    ContentVault.Models.Add(c.Name, DataConverter.ToTriList(c));
                    eng.external.Add(new InstancedModel(c.Name, Vector3.Zero, Vector3.Zero, new Vector3(0.1f)));
                }
            }
        }
Exemplo n.º 2
0
 public void LoadCtr(string filename)
 {
     try
     {
         ctr = CtrModel.FromFile(filename);
         UpdateUI();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 3
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!");
        }