public int Execute() { var perTexture = new DeserializerBuilder() .IgnoreUnmatchedProperties() .WithAttributeOverride <TextureFrame>(it => it.Data, new YamlIgnoreAttribute()) .Build() .Deserialize <PerTexture>(File.ReadAllText(Path.Combine(YmlFile))); var model = perTexture.Textures.Single(); var baseDir = Path.GetDirectoryName(YmlFile); var footer = new TextureFooterData(); model.Value.ConvertBackTo( pngFile => { return(new SpriteBitmap(Path.Combine(baseDir, pngFile))); }, footer ); var toFile = new MemoryStream(); footer.Write(toFile); File.WriteAllBytes(BinFile ?? Path.ChangeExtension(YmlFile, ".bin"), toFile.ToArray()); return(0); }
public TextureFooterDataIMEx(TextureFooterData footerData) { UvscList = footerData.UvscList.ToList(); TextureAnimationList = footerData.TextureAnimationList.Select(it => new TextureAnimationIMEx(it)).ToList(); UnkFooter = footerData.UnkFooter; ShouldEmitDMYAtFirst = footerData.ShouldEmitDMYAtFirst; ShouldEmitKN5 = footerData.ShouldEmitKN5; }
public void CreateDummy() { { var footer = new TextureFooterData(); var stream = new MemoryStream(); footer.Write(stream); } { var footer = new TextureFooterData(); footer.UvscList.Add(new UvScroll { }); var stream = new MemoryStream(); footer.Write(stream); } { var footer = new TextureFooterData(); footer.TextureAnimationList.Add(new TextureAnimation { }); var stream = new MemoryStream(); footer.Write(stream); } }
public TextureFooterData ConvertBackTo(Func <string, ISpriteImageSource> imageLoader, TextureFooterData back) { back.UvscList.Clear(); back.UvscList.AddRange(UvscList); back.TextureAnimationList.Clear(); back.TextureAnimationList.AddRange( TextureAnimationList .Select(texa => texa.ConvertBack(imageLoader)) ); back.UnkFooter = UnkFooter; back.ShouldEmitDMYAtFirst = ShouldEmitDMYAtFirst; back.ShouldEmitKN5 = ShouldEmitKN5; return(back); }
public MapBuilder(string modelFile, MapGenConfig config, Func <MaterialDef, Imgd> imageLoader) { this.config = config; ConvertModelIntoMapModel(modelFile, config); logger.Debug($"Starting collision plane builder."); collisionBuilder = new CollisionBuilder(smallMeshList, config.disableBSPCollisionBuilder); if (collisionBuilder.vifPacketRenderingGroup != null) { logger.Debug($"Updating vifPacketRenderingGroup builder."); mapModel.vifPacketRenderingGroup = collisionBuilder.vifPacketRenderingGroup; logger.Debug($"Output: {mapModel.vifPacketRenderingGroup.Count:#,##0} groups."); } logger.Debug($"Output: {collisionBuilder.coct.Nodes.Count:#,##0} collision mesh groups"); { var matDefList = bigMeshContainer.AllocatedMaterialDefs; var imageSets = matDefList .Select(matDef => new ImageSet { image = imageLoader(matDef), matDef = matDef, }) .ToArray(); var footerData = new MemoryStream(); { var footer = new TextureFooterData(); foreach (var uvscItem in config.uvscList) { footer.UvscList.Add( new UvScroll { TextureIndex = uvscItem.index, UScrollSpeed = uvscItem.u, VScrollSpeed = uvscItem.v, } ); } footer.Write(footerData); } var build = new ModelTexture.Build { images = imageSets .Select(set => set.image) .ToArray(), offsetData = null, // auto serial number map textureTransfer = null, // auto create gsInfo = imageSets .Select( set => { var gsInfo = new ModelTexture.UserGsInfo(set.image); gsInfo.AddressMode.AddressU = Enum.Parse <ModelTexture.TextureWrapMode>( set.matDef.textureOptions.addressU ?? config.textureOptions.addressU ?? "Repeat" ); gsInfo.AddressMode.AddressV = Enum.Parse <ModelTexture.TextureWrapMode>( set.matDef.textureOptions.addressV ?? config.textureOptions.addressV ?? "Repeat" ); return(gsInfo); } ) .ToArray(), footerData = footerData.ToArray(), }; modelTex = new ModelTexture(build); } }