diff --git a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj
index b2b07468..ed440d92 100644
--- a/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj
+++ b/ANX.Framework.Content.Pipeline/ANX.Framework.Content.Pipeline.csproj
@@ -35,6 +35,7 @@
+
@@ -170,6 +171,7 @@
+
diff --git a/ANX.Framework.Content.Pipeline/AnxContentProcessorContext.cs b/ANX.Framework.Content.Pipeline/AnxContentProcessorContext.cs
new file mode 100644
index 00000000..5f57d719
--- /dev/null
+++ b/ANX.Framework.Content.Pipeline/AnxContentProcessorContext.cs
@@ -0,0 +1,116 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.Graphics;
+
+#endregion
+
+// This file is part of the ANX.Framework created by the
+// "ANX.Framework developer group" and released under the Ms-PL license.
+// For details see: http://anxframework.codeplex.com/license
+
+namespace ANX.Framework.Content.Pipeline
+{
+ public class AnxContentProcessorContext : ContentProcessorContext
+ {
+ private string buildConfiguration;
+ private string intermediateDirectory;
+ private ContentBuildLogger contentBuildLogger;
+ private string outputDirectory;
+ private string outputFilename;
+ private OpaqueDataDictionary parameters;
+ private TargetPlatform targetPlatform;
+ private GraphicsProfile targetProfile;
+
+ public override string BuildConfiguration
+ {
+ get
+ {
+ return buildConfiguration;
+ }
+ }
+
+ public override string IntermediateDirectory
+ {
+ get
+ {
+ return intermediateDirectory;
+ }
+ }
+
+ public override ContentBuildLogger Logger
+ {
+ get
+ {
+ return contentBuildLogger;
+ }
+ }
+
+ public override string OutputDirectory
+ {
+ get
+ {
+ return outputDirectory;
+ }
+ }
+
+ public override string OutputFilename
+ {
+ get
+ {
+ return outputFilename;
+ }
+ }
+
+ public override OpaqueDataDictionary Parameters
+ {
+ get
+ {
+ return parameters;
+ }
+ }
+
+ public override TargetPlatform TargetPlatform
+ {
+ get
+ {
+ return targetPlatform;
+ }
+ }
+
+ public override GraphicsProfile TargetProfile
+ {
+ get
+ {
+ return targetProfile;
+ }
+ }
+
+ public override void AddDependency(string filename)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void AddOutputFile(string filename)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override TOutput BuildAndLoadAsset(ExternalReference sourceAsset, string processorName, OpaqueDataDictionary processorParameters, string importerName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override ExternalReference BuildAsset(ExternalReference sourceAsset, string processorName, OpaqueDataDictionary processorParameters, string importerName, string assetName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override TOutput Convert(TInput input, string processorName, OpaqueDataDictionary processorParameters)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/ANX.Framework.Content.Pipeline/ContentItem.cs b/ANX.Framework.Content.Pipeline/ContentItem.cs
index 0cb0dca7..1f7f2dd3 100644
--- a/ANX.Framework.Content.Pipeline/ContentItem.cs
+++ b/ANX.Framework.Content.Pipeline/ContentItem.cs
@@ -34,7 +34,7 @@ namespace ANX.Framework.Content.Pipeline
public OpaqueDataDictionary OpaqueData
{
get;
- private set;
+ set;
}
diff --git a/ANX.Framework.Content.Pipeline/ContentProcessor.cs b/ANX.Framework.Content.Pipeline/ContentProcessor.cs
index 620559a9..3740fd47 100644
--- a/ANX.Framework.Content.Pipeline/ContentProcessor.cs
+++ b/ANX.Framework.Content.Pipeline/ContentProcessor.cs
@@ -14,26 +14,27 @@ namespace ANX.Framework.Content.Pipeline
{
public abstract class ContentProcessor : IContentProcessor
{
- protected ContentProcessor()
- {
- throw new NotImplementedException();
- }
-
public abstract TOutput Process(TInput input, ContentProcessorContext context);
Type IContentProcessor.InputType
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ return typeof(TInput);
+ }
}
Type IContentProcessor.OutputType
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ return typeof(TOutput);
+ }
}
object IContentProcessor.Process(object input, ContentProcessorContext context)
{
- throw new NotImplementedException();
+ return Process((TInput)input, context);
}
}
}
diff --git a/ANX.Framework.Content.Pipeline/ContentProcessorContext.cs b/ANX.Framework.Content.Pipeline/ContentProcessorContext.cs
index b05c54cc..546ba240 100644
--- a/ANX.Framework.Content.Pipeline/ContentProcessorContext.cs
+++ b/ANX.Framework.Content.Pipeline/ContentProcessorContext.cs
@@ -17,7 +17,6 @@ namespace ANX.Framework.Content.Pipeline
{
public ContentProcessorContext()
{
- throw new NotImplementedException();
}
public abstract string BuildConfiguration { get; }
diff --git a/ANX.Framework.Content.Pipeline/Processors/EffectProcessor.cs b/ANX.Framework.Content.Pipeline/Processors/EffectProcessor.cs
index 1d312321..748440d1 100644
--- a/ANX.Framework.Content.Pipeline/Processors/EffectProcessor.cs
+++ b/ANX.Framework.Content.Pipeline/Processors/EffectProcessor.cs
@@ -30,7 +30,14 @@ namespace ANX.Framework.Content.Pipeline.Processors
public override CompiledEffectContent Process(EffectContent input, ContentProcessorContext context)
{
- throw new NotImplementedException();
+ byte[] effectCompiledCode = new byte[1]; //TODO: compile effect!!!
+
+ return new CompiledEffectContent(effectCompiledCode)
+ {
+ Identity = input.Identity,
+ Name = input.Name,
+ OpaqueData = input.OpaqueData
+ };
}
}
}
diff --git a/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs b/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs
index 420c12f5..005bfff8 100644
--- a/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs
+++ b/ANX.Framework.Content.Pipeline/Tasks/BuildContent.cs
@@ -15,6 +15,7 @@ namespace ANX.Framework.Content.Pipeline.Tasks
public class BuildContent
{
private ImporterManager importerManager;
+ private ProcessorManager processorManager;
public ImporterManager ImporterManager
{
@@ -24,15 +25,36 @@ namespace ANX.Framework.Content.Pipeline.Tasks
{
this.importerManager = new ImporterManager();
}
+
return this.importerManager;
}
}
+ public ProcessorManager ProcessorManager
+ {
+ get
+ {
+ if (this.processorManager == null)
+ {
+ this.processorManager = new ProcessorManager();
+ }
+
+ return this.processorManager;
+ }
+ }
+
public void Execute(IEnumerable itemsToBuild)
{
foreach (BuildItem buildItem in itemsToBuild)
{
var importedObject = ImportAsset(buildItem);
+
+ if (String.IsNullOrEmpty(buildItem.BuildRequest.ProcessorName))
+ {
+ buildItem.BuildRequest.ProcessorName = ProcessorManager.GetProcessorForType(importedObject.GetType());
+ }
+
+ var buildedItem = Process(buildItem, importedObject);
}
}
@@ -47,5 +69,19 @@ namespace ANX.Framework.Content.Pipeline.Tasks
//});
return instance.Import(item.BuildRequest.SourceFilename, context);
}
+
+ private object Process(BuildItem item, object importedObject)
+ {
+ if (String.IsNullOrEmpty(item.BuildRequest.ProcessorName) == false)
+ {
+ IContentProcessor instance = this.ProcessorManager.GetInstance(item.BuildRequest.ProcessorName);
+ ContentProcessorContext context = new AnxContentProcessorContext();
+ return instance.Process(importedObject, context);
+ }
+ else
+ {
+ return importedObject;
+ }
+ }
}
}
diff --git a/ANX.Framework.Content.Pipeline/Tasks/ProcessorManager.cs b/ANX.Framework.Content.Pipeline/Tasks/ProcessorManager.cs
new file mode 100644
index 00000000..116a7e22
--- /dev/null
+++ b/ANX.Framework.Content.Pipeline/Tasks/ProcessorManager.cs
@@ -0,0 +1,59 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Reflection;
+
+#endregion
+
+// This file is part of the ANX.Framework created by the
+// "ANX.Framework developer group" and released under the Ms-PL license.
+// For details see: http://anxframework.codeplex.com/license
+
+namespace ANX.Framework.Content.Pipeline.Tasks
+{
+ public class ProcessorManager
+ {
+ private Dictionary processors = new Dictionary();
+
+ public ProcessorManager()
+ {
+ foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ foreach (Type type in assembly.GetTypes())
+ {
+ ContentProcessorAttribute[] value = (ContentProcessorAttribute[]) type.GetCustomAttributes(typeof(ContentProcessorAttribute), true);
+ if (value.Length > 0 && !processors.ContainsKey(type.Name))
+ {
+ processors[type.Name] = (IContentProcessor)Activator.CreateInstance(type);
+ }
+ }
+ }
+ }
+
+ public IContentProcessor GetInstance(string processorName)
+ {
+ IContentProcessor processor;
+ if (!this.processors.TryGetValue(processorName, out processor))
+ {
+ throw new Exception(String.Format("can't find processor {0}", processorName));
+ }
+
+ return processor;
+ }
+
+ public String GetProcessorForType(Type type)
+ {
+ foreach (KeyValuePair processorDescription in processors)
+ {
+ if (Type.Equals(processorDescription.Value.InputType, type))
+ {
+ return processorDescription.Key;
+ }
+ }
+
+ return String.Empty;
+ }
+ }
+}
diff --git a/Tools/ContentBuilder/Program.cs b/Tools/ContentBuilder/Program.cs
index d8413690..a78b59a4 100644
--- a/Tools/ContentBuilder/Program.cs
+++ b/Tools/ContentBuilder/Program.cs
@@ -29,6 +29,7 @@ namespace ContentBuilder
BuildItem buildItem = new BuildItem();
buildItem.BuildRequest = new BuildRequest();
buildItem.BuildRequest.ImporterName = ImporterManager.GuessImporterByFileExtension(arg);
+ //TODO: set configured processor name
buildItem.BuildRequest.SourceFilename = arg;
buildItem.BuildRequest.AssetName = System.IO.Path.GetFileNameWithoutExtension(arg);