internal static AniModel LoadCharacter(string path, string name) { using (var zip = ZipFile.OpenRead(path)) { using (var ms = new MemoryStream()) { using (var temp = zip.GetEntry("main.oes")?.Open()) temp?.CopyTo(ms); ms.Position = 0; var root = OESFile.Read <OESRoot>(ms); var model = root.Find <OESCharacter>().First(x => x.Name == name); WriteLine($"Loading {model.Name}"); var materials = FromSkin(model.Find <OESSkin>().First(), zip); var anisets = model.Find <OESAnimationSet>().Select(x => (x.Name, x.Find <OESAnimationBuffer>().ToList())).ToDictionary(); var animodel = new AniModel(); model.Find <OESAnimatedMesh>().ForEach((oam, i) => { var animations = anisets.Select(kv => (kv.Key, kv.Value[i])).ToDictionary(); animations[""] = oam.Find <OESAnimationBuffer>().First(); animodel.Add(new AnimatedMesh(materials[i], animations.Select(kv => (kv.Key, kv.Value.VertexBuffers)).ToDictionary(), oam.IndexBuffer.ToArray())); }); return(animodel); } } }
public void LoadCharacter(string filename, string name) { var model = LastModelLoaded = Loader.LoadCharacter($"../ConverterApp/{filename}_oes.zip", name); var instance = new AniModelInstance(model) { Animation = "C05", Position = vec3(-153, 149, 80) }; Engine.Add(instance); }