Inheritance: AnimationFrameSaveBase
Exemplo n.º 1
0
 public static void WriteAnimationFrameSave(ContentWriter output, AnimationFrameSaveContent value)
 {
     output.Write(value.TextureReference != null);
     if (value.TextureReference != null)
     {
         output.WriteExternalReference(value.TextureReference);
     }
     output.Write(value.FlipHorizontal);
     output.Write(value.FlipVertical);
     if (value.TextureName != null)
     {
         output.Write(value.TextureName);
     }
     else
     {
         output.Write("");
     }
     output.Write(value.FrameLength);
     output.Write(value.LeftCoordinate);
     output.Write(value.RightCoordinate);
     output.Write(value.TopCoordinate);
     output.Write(value.BottomCoordinate);
     output.Write(value.RelativeX);
     output.Write(value.RelativeY);
 }
        /// <summary>
        /// look at all of the textures in each frame and convert them into external references
        /// </summary>
        public override AnimationChainListSaveContent Process(AnimationChainListSaveContent input, ContentProcessorContext context)
        {
            string directory = System.IO.Path.GetDirectoryName(input.FileName) + @"\";

            BitmapTextureProcessor.ResizeToPowerOfTwo           = ResizeToPowerOfTwo;
            BitmapTextureProcessor.TextureProcessorOutputFormat = TextureProcessorOutputFormat;
            BitmapTextureProcessor.GenerateMipmaps = GenerateMipmaps;             // This doesn't seem to be working......why?

            #region Loop through all AnimationChains and process them.

            for (int i = 0; i < input.AnimationChains.Count; i++)
            {
                AnimationChainSaveContent        ach       = input.AnimationChains[i];
                List <AnimationFrameSaveContent> newFrames = new List <AnimationFrameSaveContent>(ach.Frames.Count);

                for (int j = 0; j < ach.Frames.Count; j++)
                {
                    AnimationFrameSaveContent frameSave = ach.Frames[j];// new AnimationFrameSaveContent(ach.Frames[j]);

                    frameSave.TextureReference = BitmapTextureProcessor.BuildTexture(
                        directory + frameSave.TextureName,
                        context);

                    newFrames.Add(frameSave);
                }
                ach.Frames = newFrames;
            }

            #endregion

            return(input);
        }