public MeshGroup this[int objId] { get { if (_meshGroups.TryGetValue(objId, out var meshGroup)) { return(meshGroup); } var objEntryName = _objEntryLookupReversed[objId]; var modelPath = Path.Combine(_objPath, objEntryName); var modelFileName = modelPath + ".mdlx"; if (File.Exists(modelFileName)) { var mdlxEntries = File.OpenRead(modelFileName).Using(Bar.Read); var modelEntry = mdlxEntries.FirstOrDefault(x => x.Type == Bar.EntryType.Model); if (modelEntry != null) { var model = Mdlx.Read(modelEntry.Stream); ModelTexture textures = null; var textureEntry = mdlxEntries.FirstOrDefault(x => x.Type == Bar.EntryType.ModelTexture); if (textureEntry != null) { textures = ModelTexture.Read(textureEntry.Stream); } var modelMotion = MeshLoader.FromKH2(model); modelMotion.ApplyMotion(modelMotion.InitialPose); meshGroup = new MeshGroup { MeshDescriptors = modelMotion.MeshDescriptors, Textures = textures == null ? new IKingdomTexture[0] : textures.LoadTextures(_graphics).ToArray() }; } else { meshGroup = EmptyMeshGroup; } } else { meshGroup = EmptyMeshGroup; } _meshGroups[objId] = meshGroup; return(meshGroup); } }