Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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);
            }
        }