From 4c4b999b9c8aba9ee786821bb2c903120467231f Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Fri, 28 Sep 2012 10:43:38 +0000 Subject: [PATCH] - default ContentProcessor for ContentImporter now working - some improvements in TextureImporter - some improvements in SpriteTextureProcessor Missing for basic texture handling: Texture2DContentWriter --- .../Importer/TextureImporter.cs | 2 +- .../Processors/SpriteTextureProcessor.cs | 22 ++++++++++++++++++- .../Tasks/BuildContent.cs | 6 ++++- .../Tasks/ImporterManager.cs | 19 ++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/ANX.Framework.Content.Pipeline/Importer/TextureImporter.cs b/ANX.Framework.Content.Pipeline/Importer/TextureImporter.cs index b46fd8f8..38e63b2e 100644 --- a/ANX.Framework.Content.Pipeline/Importer/TextureImporter.cs +++ b/ANX.Framework.Content.Pipeline/Importer/TextureImporter.cs @@ -45,7 +45,7 @@ namespace ANX.Framework.Content.Pipeline.Importer } TextureContent textureContent = new Texture2DContent(); - textureContent.Faces.Add(new MipmapChain(bitmapContent)); + textureContent.Faces[0] = new MipmapChain(bitmapContent); return textureContent; } diff --git a/ANX.Framework.Content.Pipeline/Processors/SpriteTextureProcessor.cs b/ANX.Framework.Content.Pipeline/Processors/SpriteTextureProcessor.cs index a4c27a98..2998e2ed 100644 --- a/ANX.Framework.Content.Pipeline/Processors/SpriteTextureProcessor.cs +++ b/ANX.Framework.Content.Pipeline/Processors/SpriteTextureProcessor.cs @@ -26,7 +26,27 @@ namespace ANX.Framework.Content.Pipeline.Processors public override TextureContent Process(TextureContent input, ContentProcessorContext context) { - throw new NotImplementedException(); + if (ColorKeyEnabled) + { + throw new NotImplementedException("ColorKey not yet implemented"); + } + + if (GenerateMipmaps) + { + throw new NotImplementedException("Generation of MipMaps not yet implemented"); + } + + if (ResizeToPowerOfTwo) + { + throw new NotImplementedException("Resizing to power of two not yet implemented"); + } + + if (TextureFormat == TextureProcessorOutputFormat.DxtCompressed) + { + throw new NotImplementedException("DXT compression of textures not yet implemented"); + } + + return input; } } } diff --git a/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs b/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs index da46c41f..410038d0 100644 --- a/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs +++ b/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs @@ -106,7 +106,11 @@ namespace ANX.Framework.Content.Pipeline.Tasks if (String.IsNullOrEmpty(buildItem.ProcessorName)) { - buildItem.ProcessorName = ProcessorManager.GetProcessorForType(importedObject.GetType()); + buildItem.ProcessorName = ImporterManager.GetDefaultProcessor(buildItem.ImporterName); + if (string.IsNullOrEmpty(buildItem.ProcessorName)) + { + buildItem.ProcessorName = ProcessorManager.GetProcessorForType(importedObject.GetType()); + } } var buildedItem = Process(buildItem, importedObject); diff --git a/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs b/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs index 043c375f..7b603ded 100644 --- a/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs +++ b/ANX.Framework.Content.Pipeline/Tasks/ImporterManager.cs @@ -17,6 +17,7 @@ namespace ANX.Framework.Content.Pipeline.Tasks public class ImporterManager { private Dictionary importerTypes = new Dictionary(); + private Dictionary defaultProcessor = new Dictionary(); public ImporterManager() { @@ -29,6 +30,14 @@ namespace ANX.Framework.Content.Pipeline.Tasks if (value.Length > 0) { importerTypes[type.Name] = type; + + foreach (ContentImporterAttribute cia in value) + { + if (!String.IsNullOrEmpty(cia.DefaultProcessor)) + { + defaultProcessor.Add(type.Name, cia.DefaultProcessor); + } + } } } } @@ -44,6 +53,16 @@ namespace ANX.Framework.Content.Pipeline.Tasks return (IContentImporter)Activator.CreateInstance(type); } + public String GetDefaultProcessor(string importerName) + { + if (defaultProcessor.ContainsKey(importerName)) + { + return defaultProcessor[importerName]; + } + + return String.Empty; + } + public static String GuessImporterByFileExtension(string filename) { String extension = System.IO.Path.GetExtension(filename);