Browse Source

Add AtlasImporter

Nikos Kastellanos 8 years ago
parent
commit
8305bb19b3
30 changed files with 1089 additions and 0 deletions
  1. 6 0
      Aether.Extras.PORTABLE.sln
  2. 13 0
      Aether.Extras.WINDOWS.MG.sln
  3. 13 0
      Aether.Extras.WINDOWS.XNA.sln
  4. 52 0
      Atlas/Aether.Atlas.PORTABLE.csproj
  5. 64 0
      Atlas/Aether.Atlas.WINDOWS.MG.csproj
  6. 78 0
      Atlas/Aether.Atlas.WINDOWS.XNA.csproj
  7. 34 0
      Atlas/Atlas/Extensions.cs
  8. 33 0
      Atlas/Atlas/Sprite.cs
  9. 31 0
      Atlas/Atlas/TextureAtlas.cs
  10. 70 0
      Atlas/ContentReaders/TextureAtlasReader.cs
  11. 24 0
      Atlas/Properties/AssemblyInfo.PORTABLE.cs
  12. 41 0
      Atlas/Properties/AssemblyInfo.cs
  13. 4 0
      Atlas/packages.config
  14. 27 0
      Content.Pipeline/AtlasImporter/Atlas/SourceContent.cs
  15. 28 0
      Content.Pipeline/AtlasImporter/Atlas/SpriteContent.cs
  16. 29 0
      Content.Pipeline/AtlasImporter/Atlas/TextureAtlasContent.cs
  17. 69 0
      Content.Pipeline/AtlasImporter/AtlasImporter.WINDOWS.MG.csproj
  18. 63 0
      Content.Pipeline/AtlasImporter/AtlasImporter.WINDOWS.XNA.csproj
  19. 190 0
      Content.Pipeline/AtlasImporter/AtlasImporter.cs
  20. 131 0
      Content.Pipeline/AtlasImporter/Processors/TextureAtlasProcessor.cs
  21. 28 0
      Content.Pipeline/AtlasImporter/Properties/AssemblyInfo.cs
  22. 53 0
      Content.Pipeline/AtlasImporter/Serialization/TextureAtlasWriter.cs
  23. 5 0
      Content.Pipeline/AtlasImporter/packages.config
  24. 1 0
      README.md
  25. BIN
      bin/Release/Portable/Aether.Atlas.dll
  26. BIN
      bin/Release/Windows.XNA/Aether.Atlas.dll
  27. BIN
      bin/Release/Windows.XNA/Aether.Content.Pipeline.AtlasImporter.dll
  28. BIN
      bin/Release/Windows/Aether.Atlas.dll
  29. BIN
      bin/Release/Windows/Aether.Content.Pipeline.AtlasImporter.dll
  30. 2 0
      packages/repositories.config

+ 6 - 0
Aether.Extras.PORTABLE.sln

@@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Animation.PORTABLE",
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationImporters.PORTABLE", "Content.Pipeline\AnimationImporters\AnimationImporters.PORTABLE.csproj", "{962D579A-91F7-4FAB-940A-423E04B8465E}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationImporters.PORTABLE", "Content.Pipeline\AnimationImporters\AnimationImporters.PORTABLE.csproj", "{962D579A-91F7-4FAB-940A-423E04B8465E}"
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Atlas.PORTABLE", "Atlas\Aether.Atlas.PORTABLE.csproj", "{E5907795-BC19-4CAA-9909-9F7145E1BB0D}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
@@ -41,6 +43,10 @@ Global
 		{962D579A-91F7-4FAB-940A-423E04B8465E}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{962D579A-91F7-4FAB-940A-423E04B8465E}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{962D579A-91F7-4FAB-940A-423E04B8465E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{962D579A-91F7-4FAB-940A-423E04B8465E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{962D579A-91F7-4FAB-940A-423E04B8465E}.Release|Any CPU.Build.0 = Release|Any CPU
 		{962D579A-91F7-4FAB-940A-423E04B8465E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E5907795-BC19-4CAA-9909-9F7145E1BB0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E5907795-BC19-4CAA-9909-9F7145E1BB0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E5907795-BC19-4CAA-9909-9F7145E1BB0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E5907795-BC19-4CAA-9909-9F7145E1BB0D}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 13 - 0
Aether.Extras.WINDOWS.MG.sln

@@ -23,6 +23,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Shaders.FXAA.WINDOWS
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Shaders.Deferred.WINDOWS.MG", "Shaders\Deferred\Aether.Shaders.Deferred.WINDOWS.MG.csproj", "{96105100-20DB-4187-9BCA-0A20AC9F1298}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Shaders.Deferred.WINDOWS.MG", "Shaders\Deferred\Aether.Shaders.Deferred.WINDOWS.MG.csproj", "{96105100-20DB-4187-9BCA-0A20AC9F1298}"
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtlasImporter.WINDOWS.MG", "Content.Pipeline\AtlasImporter\AtlasImporter.WINDOWS.MG.csproj", "{E710FBEA-8C75-405D-B6B4-CFC82CB48FB5}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Atlas.WINDOWS.MG", "Atlas\Aether.Atlas.WINDOWS.MG.csproj", "{C7522B5E-B255-4FB6-A17A-9E6D217AEBD2}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Debug|Any CPU = Debug|Any CPU
@@ -61,6 +65,14 @@ Global
 		{96105100-20DB-4187-9BCA-0A20AC9F1298}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{96105100-20DB-4187-9BCA-0A20AC9F1298}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{96105100-20DB-4187-9BCA-0A20AC9F1298}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{96105100-20DB-4187-9BCA-0A20AC9F1298}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{96105100-20DB-4187-9BCA-0A20AC9F1298}.Release|Any CPU.Build.0 = Release|Any CPU
 		{96105100-20DB-4187-9BCA-0A20AC9F1298}.Release|Any CPU.Build.0 = Release|Any CPU
+		{E710FBEA-8C75-405D-B6B4-CFC82CB48FB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E710FBEA-8C75-405D-B6B4-CFC82CB48FB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E710FBEA-8C75-405D-B6B4-CFC82CB48FB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E710FBEA-8C75-405D-B6B4-CFC82CB48FB5}.Release|Any CPU.Build.0 = Release|Any CPU
+		{C7522B5E-B255-4FB6-A17A-9E6D217AEBD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C7522B5E-B255-4FB6-A17A-9E6D217AEBD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C7522B5E-B255-4FB6-A17A-9E6D217AEBD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C7522B5E-B255-4FB6-A17A-9E6D217AEBD2}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE
@@ -72,5 +84,6 @@ Global
 		{D9A47306-DEE0-4410-BC2C-BA8FFCE682A3} = {A921886B-C6F7-4FF8-8668-EC20004C464A}
 		{D9A47306-DEE0-4410-BC2C-BA8FFCE682A3} = {A921886B-C6F7-4FF8-8668-EC20004C464A}
 		{FBBDE2BA-F9F3-4041-8584-2C912C235E26} = {13D47E11-4A7C-49C8-942E-2543E9C0098A}
 		{FBBDE2BA-F9F3-4041-8584-2C912C235E26} = {13D47E11-4A7C-49C8-942E-2543E9C0098A}
 		{96105100-20DB-4187-9BCA-0A20AC9F1298} = {13D47E11-4A7C-49C8-942E-2543E9C0098A}
 		{96105100-20DB-4187-9BCA-0A20AC9F1298} = {13D47E11-4A7C-49C8-942E-2543E9C0098A}
+		{E710FBEA-8C75-405D-B6B4-CFC82CB48FB5} = {A921886B-C6F7-4FF8-8668-EC20004C464A}
 	EndGlobalSection
 	EndGlobalSection
 EndGlobal
 EndGlobal

+ 13 - 0
Aether.Extras.WINDOWS.XNA.sln

@@ -17,6 +17,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Shaders.FXAA.WINDOWS
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Shaders.Deferred.WINDOWS.XNA", "Shaders\Deferred\Aether.Shaders.Deferred.WINDOWS.XNA.csproj", "{B82B862D-C728-4A10-8A56-65D688E022C8}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Shaders.Deferred.WINDOWS.XNA", "Shaders\Deferred\Aether.Shaders.Deferred.WINDOWS.XNA.csproj", "{B82B862D-C728-4A10-8A56-65D688E022C8}"
 EndProject
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtlasImporter.WINDOWS.XNA", "Content.Pipeline\AtlasImporter\AtlasImporter.WINDOWS.XNA.csproj", "{90E6017D-198B-4470-BF9B-8B8791C295CC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aether.Atlas.WINDOWS.XNA", "Atlas\Aether.Atlas.WINDOWS.XNA.csproj", "{644629BB-1A4E-4932-8E50-4F93BC938794}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|x86 = Debug|x86
 		Debug|x86 = Debug|x86
@@ -47,6 +51,14 @@ Global
 		{B82B862D-C728-4A10-8A56-65D688E022C8}.Debug|x86.Build.0 = Debug|x86
 		{B82B862D-C728-4A10-8A56-65D688E022C8}.Debug|x86.Build.0 = Debug|x86
 		{B82B862D-C728-4A10-8A56-65D688E022C8}.Release|x86.ActiveCfg = Release|x86
 		{B82B862D-C728-4A10-8A56-65D688E022C8}.Release|x86.ActiveCfg = Release|x86
 		{B82B862D-C728-4A10-8A56-65D688E022C8}.Release|x86.Build.0 = Release|x86
 		{B82B862D-C728-4A10-8A56-65D688E022C8}.Release|x86.Build.0 = Release|x86
+		{90E6017D-198B-4470-BF9B-8B8791C295CC}.Debug|x86.ActiveCfg = Debug|x86
+		{90E6017D-198B-4470-BF9B-8B8791C295CC}.Debug|x86.Build.0 = Debug|x86
+		{90E6017D-198B-4470-BF9B-8B8791C295CC}.Release|x86.ActiveCfg = Release|x86
+		{90E6017D-198B-4470-BF9B-8B8791C295CC}.Release|x86.Build.0 = Release|x86
+		{644629BB-1A4E-4932-8E50-4F93BC938794}.Debug|x86.ActiveCfg = Debug|x86
+		{644629BB-1A4E-4932-8E50-4F93BC938794}.Debug|x86.Build.0 = Debug|x86
+		{644629BB-1A4E-4932-8E50-4F93BC938794}.Release|x86.ActiveCfg = Release|x86
+		{644629BB-1A4E-4932-8E50-4F93BC938794}.Release|x86.Build.0 = Release|x86
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE
@@ -54,6 +66,7 @@ Global
 	GlobalSection(NestedProjects) = preSolution
 	GlobalSection(NestedProjects) = preSolution
 		{565ACF47-7E36-435E-8727-2AFB39E61134} = {F6B6E505-6037-49E4-9060-8B29A7B99BC1}
 		{565ACF47-7E36-435E-8727-2AFB39E61134} = {F6B6E505-6037-49E4-9060-8B29A7B99BC1}
 		{E22F02E7-6799-4C14-B9B3-B461D6E9AB6E} = {F6B6E505-6037-49E4-9060-8B29A7B99BC1}
 		{E22F02E7-6799-4C14-B9B3-B461D6E9AB6E} = {F6B6E505-6037-49E4-9060-8B29A7B99BC1}
+		{90E6017D-198B-4470-BF9B-8B8791C295CC} = {F6B6E505-6037-49E4-9060-8B29A7B99BC1}
 		{89E0198E-7298-411A-B5C1-61F2754A3F80} = {EFC7A27C-C20B-4BE7-8B3A-2B109991D704}
 		{89E0198E-7298-411A-B5C1-61F2754A3F80} = {EFC7A27C-C20B-4BE7-8B3A-2B109991D704}
 		{B82B862D-C728-4A10-8A56-65D688E022C8} = {EFC7A27C-C20B-4BE7-8B3A-2B109991D704}
 		{B82B862D-C728-4A10-8A56-65D688E022C8} = {EFC7A27C-C20B-4BE7-8B3A-2B109991D704}
 	EndGlobalSection
 	EndGlobalSection

+ 52 - 0
Atlas/Aether.Atlas.PORTABLE.csproj

@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <ProjectGuid>{E5907795-BC19-4CAA-9909-9F7145E1BB0D}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>tainicom.Aether.Atlas</RootNamespace>
+    <AssemblyName>Aether.Atlas</AssemblyName>
+    <TargetFrameworkProfile>Profile328</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\bin\Debug\Portable\</OutputPath>
+    <DefineConstants>DEBUG;PORTABLE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\bin\Release\Portable\</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <DefineConstants>PORTABLE</DefineConstants>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="Atlas\Extensions.cs" />
+    <Compile Include="Atlas\Sprite.cs" />
+    <Compile Include="Atlas\TextureAtlas.cs" />
+    <Compile Include="ContentReaders\TextureAtlasReader.cs" />
+    <Compile Include="Properties\AssemblyInfo.PORTABLE.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <ItemGroup>
+    <Reference Include="MonoGame.Framework">
+      <HintPath>..\packages\MonoGame.Framework.Portable.3.2.99.1-Beta\lib\portable-net40+sl40+win+wp80\MonoGame.Framework.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup />
+</Project>

+ 64 - 0
Atlas/Aether.Atlas.WINDOWS.MG.csproj

@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectGuid>{C7522B5E-B255-4FB6-A17A-9E6D217AEBD2}</ProjectGuid>
+    <ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>tainicom.Aether.Atlas</RootNamespace>
+    <AssemblyName>Aether.Atlas</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+    <TargetFrameworkProfile>
+    </TargetFrameworkProfile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\bin\Debug\Windows\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;WINDOWS MG MAPPEDMEM</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\bin\Release\Windows\</OutputPath>
+    <DefineConstants>TRACE;WINDOWS MG MAPPEDMEM</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <Prefer32Bit>false</Prefer32Bit>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="MonoGame.Framework">
+      <HintPath>..\packages\MonoGame.Framework.Portable.3.2.99.1-Beta\lib\portable-net40+sl40+win+wp80\MonoGame.Framework.dll</HintPath>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="mscorlib" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Atlas\Extensions.cs" />
+    <Compile Include="Atlas\Sprite.cs" />
+    <Compile Include="Atlas\TextureAtlas.cs" />
+    <Compile Include="ContentReaders\TextureAtlasReader.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+      Other similar extension points exist, see Microsoft.Common.targets.
+      <Target Name="BeforeBuild">
+      </Target>
+      <Target Name="AfterBuild">
+      </Target>
+    -->
+</Project>

+ 78 - 0
Atlas/Aether.Atlas.WINDOWS.XNA.csproj

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectGuid>{644629BB-1A4E-4932-8E50-4F93BC938794}</ProjectGuid>
+    <ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>tainicom.Aether.Atlas</RootNamespace>
+    <AssemblyName>Aether.Atlas</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>
+    <XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
+    <XnaPlatform>Windows</XnaPlatform>
+    <XnaProfile>Reach</XnaProfile>
+    <XnaCrossPlatformGroupID>AD078DF8-7D5B-4648-A4FD-684E5EC62024</XnaCrossPlatformGroupID>
+    <XnaOutputType>Library</XnaOutputType>
+    <!--
+    <XnaRefreshLevel>1</XnaRefreshLevel>
+    -->
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\bin\Debug\Windows.XNA\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;WINDOWS XNA</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <NoStdLib>true</NoStdLib>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <PlatformTarget>x86</PlatformTarget>
+    <XnaCompressContent>false</XnaCompressContent>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\bin\Release\Windows.XNA\</OutputPath>
+    <DefineConstants>WINDOWS XNA</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <NoStdLib>true</NoStdLib>
+    <UseVSHostingProcess>false</UseVSHostingProcess>
+    <PlatformTarget>x86</PlatformTarget>
+    <XnaCompressContent>true</XnaCompressContent>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="mscorlib" />
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+      <Private>False</Private>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Atlas\Extensions.cs" />
+    <Compile Include="Atlas\Sprite.cs" />
+    <Compile Include="Atlas\TextureAtlas.cs" />
+    <Compile Include="ContentReaders\TextureAtlasReader.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup />
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
+  <!--
+      To modify your build process, add your task inside one of the targets below and uncomment it. 
+      Other similar extension points exist, see Microsoft.Common.targets.
+      <Target Name="BeforeBuild">
+      </Target>
+      <Target Name="AfterBuild">
+      </Target>
+    -->
+</Project>

+ 34 - 0
Atlas/Atlas/Extensions.cs

@@ -0,0 +1,34 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using Microsoft.Xna.Framework;
+using tainicom.Aether.Atlas;
+
+namespace Microsoft.Xna.Framework.Graphics
+{
+    public static class Extensions
+    {
+        public static void Draw(this SpriteBatch spriteBatch, Sprite sprite, Vector2 position, Color color)
+        {
+            spriteBatch.Draw(sprite.Texture, position, sprite.SourceRectangle, color);         
+        }
+        
+        public static void Draw(this SpriteBatch spriteBatch, Sprite sprite, Rectangle destinationRectangle, Color color)
+        {
+            spriteBatch.Draw(sprite.Texture, destinationRectangle, sprite.SourceRectangle, color);
+        }
+    }
+}

+ 33 - 0
Atlas/Atlas/Sprite.cs

@@ -0,0 +1,33 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace tainicom.Aether.Atlas
+{
+    public class Sprite
+    {
+        public readonly Texture2D Texture;
+        public readonly Rectangle SourceRectangle;
+
+        internal Sprite(Texture2D texture, Rectangle sourceRectangle)
+        {
+            this.Texture = texture;
+            this.SourceRectangle = sourceRectangle;
+        }
+    }
+}

+ 31 - 0
Atlas/Atlas/TextureAtlas.cs

@@ -0,0 +1,31 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using System.Collections.Generic;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace tainicom.Aether.Atlas
+{
+    public class TextureAtlas
+    {
+        public Texture2D Texture {get; internal set;}
+        public readonly Dictionary<string, Sprite> Sprites;
+        internal TextureAtlas()
+        {
+            this.Sprites = new Dictionary<string, Sprite>();
+        }
+    }
+}

+ 70 - 0
Atlas/ContentReaders/TextureAtlasReader.cs

@@ -0,0 +1,70 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using System;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content;
+using Microsoft.Xna.Framework.Graphics;
+using tainicom.Aether.Atlas;
+
+namespace tainicom.Aether.Graphics.Content
+{
+    public class TextureAtlasReader : ContentTypeReader<TextureAtlas>
+    {
+        protected override TextureAtlas Read(ContentReader input, TextureAtlas existingInstance)
+        {
+            System.Diagnostics.Debugger.Launch();
+
+            IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)input.ContentManager.ServiceProvider.GetService(typeof(IGraphicsDeviceService));
+            var device = graphicsDeviceService.GraphicsDevice;
+
+
+            TextureAtlas output = existingInstance ?? new TextureAtlas();
+
+            // read standard Texture2D
+            output.Texture = ReadTexture2D(input, output.Texture);
+
+            // read Sprites
+            var count = input.ReadInt32();
+            for (int i = 0; i < count; i++)
+            {
+                var name = input.ReadString();
+                var destinationRect = new Rectangle(input.ReadInt32(), input.ReadInt32(), input.ReadInt32(), input.ReadInt32());
+                output.Sprites[name] = new Sprite(output.Texture, destinationRect);
+            }
+
+            return output;
+        }
+
+        private Texture2D ReadTexture2D(ContentReader input, Texture2D existingInstance)
+        {
+            Texture2D output = null;
+            try
+            {
+                output = input.ReadRawObject<Texture2D>(existingInstance);
+            }
+            catch(NotSupportedException)
+            {
+                var assembly = typeof(Microsoft.Xna.Framework.Content.ContentTypeReader).Assembly;
+                var texture2DReaderType = assembly.GetType("Microsoft.Xna.Framework.Content.Texture2DReader");
+                var texture2DReader = (ContentTypeReader)Activator.CreateInstance(texture2DReaderType, true);
+                output = input.ReadRawObject<Texture2D>(texture2DReader, existingInstance);
+            }
+            
+            return output;
+        }
+    }
+}

+ 24 - 0
Atlas/Properties/AssemblyInfo.PORTABLE.cs

@@ -0,0 +1,24 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+[assembly: AssemblyTitle ("Aether.Atlas")]
+[assembly: AssemblyDescription ("")]
+[assembly: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("Aether.Atlas")]
+[assembly: AssemblyCopyright ("Copyright ©  Kastellanos Nikolaos 2016")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+

+ 41 - 0
Atlas/Properties/AssemblyInfo.cs

@@ -0,0 +1,41 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("Aether.Atlas")]
+[assembly: AssemblyProduct("Aether.Atlas")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyCopyright("Copyright ©  Kastellanos Nikolaos 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type. Only Windows
+// assemblies support COM.
+[assembly: ComVisible(false)]
+
+// On Windows, the following GUID is for the ID of the typelib if this
+// project is exposed to COM. On other platforms, it unique identifies the
+// title storage container when deploying this assembly to the device.
+[assembly: Guid("089a2665-02e6-4cf3-8571-30c768fe35f9")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+
+#if WP7_1
+// Enable NEON/SIMD
+[assembly: CodeGeneration(CodeGenerationFlags.EnableFPIntrinsicsUsingSIMD)]
+#endif

+ 4 - 0
Atlas/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MonoGame.Framework.Portable" version="3.2.99.1-Beta" targetFramework="portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10" />
+</packages>

+ 27 - 0
Content.Pipeline/AtlasImporter/Atlas/SourceContent.cs

@@ -0,0 +1,27 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+
+namespace tainicom.Aether.Content.Pipeline.Atlas
+{
+    public class SourceContent
+    {
+        public TextureContent Texture;
+        public int Width;
+        public int Height;
+    }
+}

+ 28 - 0
Content.Pipeline/AtlasImporter/Atlas/SpriteContent.cs

@@ -0,0 +1,28 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+namespace tainicom.Aether.Content.Pipeline
+{
+    public class SpriteContent
+    {
+        public TextureContent Texture;
+        public Rectangle DestinationRectangle;
+        public string Name;
+    }
+}

+ 29 - 0
Content.Pipeline/AtlasImporter/Atlas/TextureAtlasContent.cs

@@ -0,0 +1,29 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using System.Collections.Generic;
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+
+namespace tainicom.Aether.Content.Pipeline.Atlas
+{
+    public class TextureAtlasContent : Texture2DContent
+    {
+        public int Width, Height;
+
+        public List<SourceContent> Textures = new List<SourceContent>();
+        public List<SpriteContent> Sprites = new List<SpriteContent>();
+    }
+}

+ 69 - 0
Content.Pipeline/AtlasImporter/AtlasImporter.WINDOWS.MG.csproj

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{E710FBEA-8C75-405D-B6B4-CFC82CB48FB5}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>tainicom.Aether.Content.Pipeline</RootNamespace>
+    <AssemblyName>Aether.Content.Pipeline.AtlasImporter</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\bin\Debug\Windows\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;WINDOWS MG</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\bin\Release\Windows\</OutputPath>
+    <DefineConstants>TRACE;WINDOWS MG</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="MonoGame.Framework, Version=3.1.2.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\MonoGame.Framework.Portable.3.2.99.1-Beta\lib\portable-net40+sl40+win+wp80\MonoGame.Framework.dll</HintPath>
+      <SpecificVersion>False</SpecificVersion>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="MonoGame.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\MonoGame.Framework.Content.Pipeline.Portable.3.2.99.1-Beta\lib\portable-net40+sl40+win+wp80\MonoGame.Framework.Content.Pipeline.dll</HintPath>
+      <SpecificVersion>False</SpecificVersion>
+      <Private>False</Private>
+    </Reference>
+    <Reference Include="System.XML" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AtlasImporter.cs" />
+    <Compile Include="Atlas\SourceContent.cs" />
+    <Compile Include="Atlas\TextureAtlasContent.cs" />
+    <Compile Include="Atlas\SpriteContent.cs" />
+    <Compile Include="Processors\TextureAtlasProcessor.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Serialization\TextureAtlasWriter.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 63 - 0
Content.Pipeline/AtlasImporter/AtlasImporter.WINDOWS.XNA.csproj

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+  <PropertyGroup>
+    <ProjectGuid>{90E6017D-198B-4470-BF9B-8B8791C295CC}</ProjectGuid>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>tainicom.Aether.Content.Pipeline</RootNamespace>
+    <AssemblyName>Aether.Content.Pipeline.AtlasImporter</AssemblyName>
+    <XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
+    <XnaPlatform>Windows</XnaPlatform>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\bin\Debug\Windows.XNA\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;WINDOWS XNA</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\bin\Release\Windows.XNA\</OutputPath>
+    <DefineConstants>TRACE;WINDOWS XNA</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>x86</PlatformTarget>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="Microsoft.Xna.Framework.Content.Pipeline, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>4.0</RequiredTargetFramework>
+    </Reference>
+    <Reference Include="System.XML" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AtlasImporter.cs" />
+    <Compile Include="Atlas\SourceContent.cs" />
+    <Compile Include="Atlas\TextureAtlasContent.cs" />
+    <Compile Include="Atlas\SpriteContent.cs" />
+    <Compile Include="Processors\TextureAtlasProcessor.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Serialization\TextureAtlasWriter.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.ContentPipelineExtensions.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+     Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 190 - 0
Content.Pipeline/AtlasImporter/AtlasImporter.cs

@@ -0,0 +1,190 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Xml;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content.Pipeline;
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+using Microsoft.Xna.Framework.Graphics;
+using tainicom.Aether.Content.Pipeline.Atlas;
+
+namespace tainicom.Aether.Content.Pipeline
+{
+    [ContentImporter(".tmx", DisplayName = "Atlas Importer - Aether", DefaultProcessor = "AtlasProcessor")]
+    public class AtlasImporter : ContentImporter<TextureAtlasContent>
+    {
+        public override TextureAtlasContent Import(string filename, ContentImporterContext context)
+        {
+            TextureAtlasContent output;
+            
+            if (Path.GetExtension(filename) == ".tmx")
+                output = ImportTMX(filename, context);
+            else
+                throw new InvalidContentException("File type not supported");
+
+            RenderAtlas(output);
+            
+            return output;
+        }
+        
+        private static TextureAtlasContent ImportTMX(string filename, ContentImporterContext context)
+        {
+            TextureAtlasContent output = new TextureAtlasContent();
+            output.Identity = new ContentIdentity(filename);
+
+            XmlDocument xmlDoc = new XmlDocument();
+            xmlDoc.Load(filename);
+
+            var map = xmlDoc.DocumentElement;
+            var orientation = GetAttribute(map, "orientation");
+            if (orientation != "orthogonal")
+                throw new InvalidContentException("Invalid orientation. Only 'orthogonal' is supported for atlases.");
+            var renderorder = GetAttribute(map, "renderorder");
+            var mapColumns = GetAttributeAsInt(map, "width").Value;
+            var mapRows = GetAttributeAsInt(map, "height").Value;
+            var tileWidth = GetAttributeAsInt(map, "tilewidth").Value;
+            var tileHeight = GetAttributeAsInt(map, "tileheight").Value;
+            output.Width = mapColumns * tileWidth;
+            output.Height = mapRows * tileHeight;
+            
+            XmlNode tileset = map["tileset"];
+            if (tileset.Attributes["source"] != null)
+                throw new InvalidContentException("External Tileset is not supported.");
+            if (tileset["tileoffset"] != null)
+                throw new InvalidContentException("tileoffset is not supported.");
+            var firstgid = GetAttributeAsInt(tileset, "firstgid").Value;
+
+            Dictionary<int, SourceContent> images = new Dictionary<int, SourceContent>();
+            TextureImporter txImporter = new TextureImporter();
+            
+            foreach (XmlNode tileNode in tileset.ChildNodes)
+            {
+                if (tileNode.Name != "tile") continue;
+                var tileId = GetAttributeAsInt(tileNode, "id").Value;
+                XmlNode imageNode = tileNode["image"];
+                
+                var source = new SourceContent();
+
+                //var format = GetAttribute(imageNode, "format");
+                var imageSource = GetAttribute(imageNode, "source");
+                var fullImageSource = Path.Combine(Path.GetDirectoryName(filename), imageSource);
+                var textureContent = (Texture2DContent)txImporter.Import(fullImageSource, context);
+                textureContent.Name = Path.GetFileNameWithoutExtension(fullImageSource);
+
+                source.Texture = textureContent;
+
+                var width = GetAttributeAsInt(imageNode, "width");
+                var height = GetAttributeAsInt(imageNode, "height");
+
+                source.Width = width ?? textureContent.Mipmaps[0].Width;
+                source.Height = height ?? textureContent.Mipmaps[0].Height;
+
+                var transKeyColor = GetAttributeAsColor(imageNode, "trans");
+                if (transKeyColor != null)
+                    foreach (var mips in textureContent.Faces)
+                        foreach (var mip in mips)
+                            ((PixelBitmapContent<Color>)mip).ReplaceColor(transKeyColor.Value, Color.Transparent);
+
+                images.Add(firstgid + tileId, source);
+            }
+
+            output.Textures.AddRange(images.Values);
+            
+            XmlNode layerNode = map["layer"];
+            var layerColumns = Convert.ToInt32(map.Attributes["width"].Value, CultureInfo.InvariantCulture);
+            var layerRows = Convert.ToInt32(map.Attributes["height"].Value, CultureInfo.InvariantCulture);
+
+            XmlNode layerDataNode = layerNode["data"];
+            var encoding = layerDataNode.Attributes["encoding"].Value;
+            if (encoding!="csv")
+                throw new InvalidContentException("Invalid encoding. Only 'csv' is supported for data.");
+            var data = layerDataNode.InnerText;
+            var dataList = data.Split(',');
+            for (int i = 0; i < dataList.Length; i++)
+                dataList[i] = dataList[i].Trim();
+            
+            for(int y=0;y<layerRows;y++)
+            {
+                for(int x=0;x<layerColumns;x++ )
+                {
+                    var posX = x * tileWidth;
+                    var posY = y * tileHeight;
+                    
+                    var tilegId = Convert.ToInt32(dataList[y * layerColumns + x], CultureInfo.InvariantCulture);
+                    SourceContent image; 
+                    if (!images.TryGetValue(tilegId, out image))
+                        continue;
+
+                    if (renderorder == "right-down" || renderorder == "right-up")
+                        posX += (tileWidth - image.Width);
+                    if (renderorder == "right-down" || renderorder == "left-down")
+                        posY += (tileHeight - image.Height);
+
+                    var sprite = new SpriteContent();
+                    sprite.Name = image.Texture.Name;
+                    sprite.Texture = image.Texture;
+                    sprite.DestinationRectangle = new Rectangle(posX, posY, image.Width, image.Height);
+
+                    output.Sprites.Add(sprite);
+                }
+            }
+            
+            return output;
+        }
+
+        private static void RenderAtlas(TextureAtlasContent output)
+        {
+            var outputBmp = new PixelBitmapContent<Color>(output.Width, output.Height);
+            foreach (var sprite in output.Sprites)
+            {
+                var srcBmp = sprite.Texture.Faces[0][0];
+                var srcRect = new Rectangle(0, 0, srcBmp.Width, srcBmp.Height);
+                BitmapContent.Copy(srcBmp, srcRect, outputBmp, sprite.DestinationRectangle);
+            }
+            var mipmapChain = new MipmapChain(outputBmp);
+            output.Mipmaps = mipmapChain;
+        }
+        
+        private static string GetAttribute(XmlNode xmlNode, string attributeName)
+        {
+            var attribute = xmlNode.Attributes[attributeName];
+            if(attribute==null) return null;
+            return attribute.Value;
+        }
+        
+        private static int? GetAttributeAsInt(XmlNode xmlNode, string attributeName)
+        {
+            var attribute = xmlNode.Attributes[attributeName];
+            if (attribute == null) return null;
+            return Int32.Parse(attribute.Value, CultureInfo.InvariantCulture);
+        }
+
+        private static Color? GetAttributeAsColor(XmlNode xmlNode, string attributeName)
+        {
+            var attribute = xmlNode.Attributes[attributeName];
+            if (attribute == null) return null;
+            attribute.Value = attribute.Value.TrimStart(new char[] { '#' });
+            return new Color(
+                Int32.Parse(attribute.Value.Substring(0, 2), System.Globalization.NumberStyles.HexNumber),
+                Int32.Parse(attribute.Value.Substring(2, 2), System.Globalization.NumberStyles.HexNumber),
+                Int32.Parse(attribute.Value.Substring(4, 2), System.Globalization.NumberStyles.HexNumber));
+        }
+    }
+}

+ 131 - 0
Content.Pipeline/AtlasImporter/Processors/TextureAtlasProcessor.cs

@@ -0,0 +1,131 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using System;
+using System.ComponentModel;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Content.Pipeline;
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+using Microsoft.Xna.Framework.Content.Pipeline.Processors;
+using tainicom.Aether.Content.Pipeline.Atlas;
+
+namespace tainicom.Aether.Content.Pipeline
+{
+    [ContentProcessor(DisplayName = "AtlasProcessor - Aether")]
+    public class AtlasProcessor : TextureProcessor, IContentProcessor
+    {        
+        private bool _mipmapsPerSprite = true;
+
+#if WINDOWS
+        // override InputType
+        [Browsable(false)]
+#endif
+        Type IContentProcessor.InputType { get { return typeof(TextureAtlasContent); } }
+
+#if WINDOWS
+        // override OutputType
+        [Browsable(false)]
+#endif
+        Type IContentProcessor.OutputType { get { return typeof(TextureAtlasContent); } }
+        
+
+        [DefaultValue(true)]
+        public new bool MipmapsPerSprite
+        {
+            get { return _mipmapsPerSprite; }
+            set { _mipmapsPerSprite = value; }
+        }
+
+        public AtlasProcessor()
+        {
+        }
+        
+        object IContentProcessor.Process(object input, ContentProcessorContext context)
+        {
+            return Process((TextureAtlasContent)input, context);
+        }
+
+        public TextureAtlasContent Process(TextureAtlasContent input, ContentProcessorContext context)
+        {
+            if (MipmapsPerSprite && GenerateMipmaps)
+                foreach (var texture in input.Textures)
+                    texture.Texture.GenerateMipmaps(false);
+
+            var output = input;
+            
+            if (GenerateMipmaps)
+            {
+                if (MipmapsPerSprite)
+                {
+                    var maxSpriteWidth = 1;
+                    var maxSpriteHeight = 1;
+                    foreach (var sprite in input.Textures)
+                    {
+                        var face0 = sprite.Texture.Faces[0];
+                        maxSpriteWidth = Math.Max(maxSpriteWidth, face0[0].Width);
+                        maxSpriteHeight = Math.Max(maxSpriteHeight, face0[0].Height);
+                    }
+
+                    for (int mipLevel = 1; ; mipLevel++)
+                    {
+                        int mipLevel2 = (int)Math.Pow(2, mipLevel);
+                        Rectangle size = new Rectangle(0, 0, input.Width, input.Height);
+                        size.Width /= mipLevel2;
+                        size.Height /= mipLevel2;
+
+                        if ((maxSpriteWidth / mipLevel2) < 1 && (maxSpriteHeight / mipLevel2) < 1) break;
+
+                        var mipmapBmp = new PixelBitmapContent<Color>(size.Width, size.Height);
+                        foreach (var sprite in input.Sprites)
+                        {
+                            if (mipLevel >= sprite.Texture.Faces[0].Count) continue;
+                            var srcBmp = sprite.Texture.Faces[0][mipLevel];
+                            var srcRect = new Rectangle(0, 0, srcBmp.Width, srcBmp.Height);
+                            var destRect = sprite.DestinationRectangle;
+                            destRect.X = (int)Math.Ceiling((float)destRect.X / mipLevel2);
+                            destRect.Y = (int)Math.Ceiling((float)destRect.Y / mipLevel2);
+                            destRect.Width = (int)(destRect.Width / mipLevel2);
+                            destRect.Height = (int)(destRect.Height / mipLevel2);
+                            if (destRect.Width > 1 && destRect.Height > 1)
+                                BitmapContent.Copy(srcBmp, srcRect, mipmapBmp, destRect);
+                        }
+                        output.Mipmaps.Add(mipmapBmp);
+                    }
+
+                    var outputFace0 = output.Faces[0];
+                    while (outputFace0[outputFace0.Count - 1].Width > 1 || outputFace0[outputFace0.Count - 1].Height > 1)
+                    {
+                        var lastMipmap = outputFace0[outputFace0.Count - 1];
+                        var w = Math.Max(1, lastMipmap.Width/2);
+                        var h = Math.Max(1, lastMipmap.Height/2);
+                        var mipmapBmp = new PixelBitmapContent<Color>(w, h);
+                        //PixelBitmapContent<Color>.Copy(lastMipmap, mipmapBmp);
+                        output.Mipmaps.Add(mipmapBmp);
+                    }
+                }
+                else
+                {
+                    output.GenerateMipmaps(false);
+                }
+            }
+            
+            base.Process(output, context);
+            
+            return output;
+        }
+        
+    }
+}

+ 28 - 0
Content.Pipeline/AtlasImporter/Properties/AssemblyInfo.cs

@@ -0,0 +1,28 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Aether.Content.Pipeline.AtlasImporter")]
+[assembly: AssemblyProduct("AtlasImporter")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyCopyright("Copyright © Kastellanos Nikolaos  2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 53 - 0
Content.Pipeline/AtlasImporter/Serialization/TextureAtlasWriter.cs

@@ -0,0 +1,53 @@
+#region License
+//   Copyright 2016 Kastellanos Nikolaos
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+#endregion
+
+using Microsoft.Xna.Framework.Content.Pipeline;
+using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
+using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
+using tainicom.Aether.Content.Pipeline.Atlas;
+using Microsoft.Xna.Framework.Graphics;
+using System;
+
+namespace tainicom.Aether.Content.Pipeline.Serialization
+{
+    [ContentTypeWriter]
+    class TextureAtlasWriter : ContentTypeWriter<TextureAtlasContent>
+    {
+        protected override void Write(ContentWriter output, TextureAtlasContent atlas)
+        {
+            output.WriteRawObject((Texture2DContent)atlas);
+            
+            // write Sprites
+            output.Write(atlas.Sprites.Count);
+            foreach(var sprite in atlas.Sprites)
+            {
+                output.Write(sprite.Name);
+                output.Write(sprite.DestinationRectangle.X);
+                output.Write(sprite.DestinationRectangle.Y);
+                output.Write(sprite.DestinationRectangle.Width);
+                output.Write(sprite.DestinationRectangle.Height);
+            }
+            
+            return;
+        }
+        
+        public override string GetRuntimeReader(TargetPlatform targetPlatform)
+        {
+            return "tainicom.Aether.Graphics.Content.TextureAtlasReader, Aether.Atlas";
+        }
+        
+    }
+}

+ 5 - 0
Content.Pipeline/AtlasImporter/packages.config

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="MonoGame.Framework.Content.Pipeline.Portable" version="3.2.99.1-Beta" targetFramework="net40" />
+  <package id="MonoGame.Framework.Portable" version="3.2.99.1-Beta" targetFramework="net40" />
+</packages>

+ 1 - 0
README.md

@@ -11,6 +11,7 @@ MonoGame Content Importers, Shaders, etc
 * 'RawModelProcessor' - Import 3D Models with a raw copy of Vertex/Index data for platforms that don't support GetData().
 * 'RawModelProcessor' - Import 3D Models with a raw copy of Vertex/Index data for platforms that don't support GetData().
 * 'DynamicModel' - Base Processor to customize the build in Model. It allows to modify
 * 'DynamicModel' - Base Processor to customize the build in Model. It allows to modify
 VertexBuffer & IndexBuffers, make them Dynamic and WriteOnly.
 VertexBuffer & IndexBuffers, make them Dynamic and WriteOnly.
+* 'AtlasImporter' - Import sprite atlas. Supports .tmx files. Mipmaps are generated individually for each sprite, no color-leak.
 
 
 ## tainicom.Aether.Animation
 ## tainicom.Aether.Animation
 
 

BIN
bin/Release/Portable/Aether.Atlas.dll


BIN
bin/Release/Windows.XNA/Aether.Atlas.dll


BIN
bin/Release/Windows.XNA/Aether.Content.Pipeline.AtlasImporter.dll


BIN
bin/Release/Windows/Aether.Atlas.dll


BIN
bin/Release/Windows/Aether.Content.Pipeline.AtlasImporter.dll


+ 2 - 0
packages/repositories.config

@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <repositories>
 <repositories>
   <repository path="..\Animation\packages.config" />
   <repository path="..\Animation\packages.config" />
+  <repository path="..\Atlas\packages.config" />
   <repository path="..\Content.Pipeline\AnimationImporter\packages.config" />
   <repository path="..\Content.Pipeline\AnimationImporter\packages.config" />
+  <repository path="..\Content.Pipeline\AtlasImporter\packages.config" />
   <repository path="..\Content.Pipeline\DDSImporter\packages.config" />
   <repository path="..\Content.Pipeline\DDSImporter\packages.config" />
   <repository path="..\Content.Pipeline\GraphicsImporters\packages.config" />
   <repository path="..\Content.Pipeline\GraphicsImporters\packages.config" />
   <repository path="..\Content.Pipeline\RawModelProcessor\packages.config" />
   <repository path="..\Content.Pipeline\RawModelProcessor\packages.config" />