Esempio n. 1
0
        protected override void Export(CookingContext context, ParticleSystemSet input)
        {
            var particleBitmaps = new Dictionary <Bitmap, ParticleSystem>();

            foreach (var item in input.ParticleSystems)
            {
                var tag = (ImageCookingTag)item.Value.Image.Tag;
                particleBitmaps.Add(tag.Bitmap, item.Value);
            }

            using (var bitmapSheet = BitmapSheet.Create(particleBitmaps.Keys,
                                                        BitmapSheetSize.Width, BitmapSheetSize.Height,
                                                        BitmapSheetClusterSize.Width, BitmapSheetClusterSize.Height,
                                                        BitmapSheet.Options.PowerOfTwoSize | BitmapSheet.Options.RotatableMerging))
            {
                ExportImageSet.SaveTextureAssets(context, bitmapSheet, TextureOutput, (source, textureURI, clippingRectangle, appliedTransform) =>
                {
                    ParticleSystem value = null;
                    if (particleBitmaps.TryGetValue(source, out value))
                    {
                        value.Image.TextureURI        = textureURI;
                        value.Image.ClippingRectangle = clippingRectangle;
                        value.Image.AppliedTransform  = appliedTransform;
                    }
                });
            }
        }
Esempio n. 2
0
        protected override void Export(CookingContext context, SpriteSet input)
        {
            var spriteBitmaps = new Dictionary <Bitmap, List <Tuple <Sprite, int> > >();

            foreach (var item in input.Sprites)
            {
                var tag = (SpriteCookingTag)item.Value.Tag;
                for (int i = 0; i < tag.Bitmaps.Count; i++)
                {
                    Bitmap bitmap = tag.Bitmaps[i];
                    List <Tuple <Sprite, int> > values = null;
                    if (spriteBitmaps.TryGetValue(bitmap, out values))
                    {
                        values.Add(Tuple.Create(item.Value, i));
                    }
                    else
                    {
                        values = new List <Tuple <Sprite, int> >();
                        values.Add(Tuple.Create(item.Value, i));
                        spriteBitmaps.Add(bitmap, values);
                    }
                }
            }

            using (var bitmapSheet = BitmapSheet.Create(spriteBitmaps.Keys,
                                                        BitmapSheetSize.Width, BitmapSheetSize.Height,
                                                        BitmapSheetClusterSize.Width, BitmapSheetClusterSize.Height,
                                                        BitmapSheet.Options.PowerOfTwoSize | BitmapSheet.Options.RotatableMerging))
            {
                ExportImageSet.SaveTextureAssets(context, bitmapSheet, TextureOutput, (source, textureURI, clippingRectangle, appliedTransform) =>
                {
                    List <Tuple <Sprite, int> > values = null;
                    if (spriteBitmaps.TryGetValue(source, out values))
                    {
                        foreach (var item in values)
                        {
                            item.Item1.Keyframes[item.Item2].TextureURI        = textureURI;
                            item.Item1.Keyframes[item.Item2].ClippingRectangle = clippingRectangle;
                            item.Item1.Keyframes[item.Item2].AppliedTransform  = appliedTransform;
                        }
                    }
                });
            }
        }