mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-21 01:39:32 +00:00
started working on texture atlas importer
This commit is contained in:
@@ -62,6 +62,13 @@
|
||||
<Compile Include="BitmapFonts\BitmapFontImporter.cs" />
|
||||
<Compile Include="BitmapFonts\BitmapFontProcessor.cs" />
|
||||
<Compile Include="BitmapFonts\BitmapFontWriter.cs" />
|
||||
<Compile Include="TextureAtlases\TexturePackerJsonImporter.cs" />
|
||||
<Compile Include="TextureAtlases\TexturePackerFile.cs" />
|
||||
<Compile Include="TextureAtlases\TexturePackerFrame.cs" />
|
||||
<Compile Include="TextureAtlases\TexturePackerMeta.cs" />
|
||||
<Compile Include="TextureAtlases\TexturePackerPoint.cs" />
|
||||
<Compile Include="TextureAtlases\TexturePackerRectangle.cs" />
|
||||
<Compile Include="TextureAtlases\TexturePackerSize.cs" />
|
||||
<Compile Include="Tiled\TmxDataTile.cs" />
|
||||
<Compile Include="Tiled\TiledMapImporter.cs" />
|
||||
<Compile Include="Tiled\TiledMapProcessor.cs" />
|
||||
@@ -92,6 +99,7 @@
|
||||
<Name>MonoGame.Extended</Name>
|
||||
</ProjectReference>
|
||||
</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.
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
||||
{
|
||||
public class TexturePackerFile
|
||||
{
|
||||
[JsonProperty("frames")]
|
||||
public List<TexturePackerFrame> Frames { get; set; }
|
||||
|
||||
[JsonProperty("meta")]
|
||||
public TexturePackerMeta Meta { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
||||
{
|
||||
public class TexturePackerFrame
|
||||
{
|
||||
[JsonProperty("filename")]
|
||||
public string Filename { get; set; }
|
||||
|
||||
[JsonProperty("frame")]
|
||||
public TexturePackerRectangle Frame { get; set; }
|
||||
|
||||
[JsonProperty("rotated")]
|
||||
public bool Rotated { get; set; }
|
||||
|
||||
[JsonProperty("trimmed")]
|
||||
public bool Trimmed { get; set; }
|
||||
|
||||
[JsonProperty("spriteSourceSize")]
|
||||
public TexturePackerRectangle SpriteSourceSize { get; set; }
|
||||
|
||||
[JsonProperty("sourceSize")]
|
||||
public TexturePackerSize SourceSize { get; set; }
|
||||
|
||||
[JsonProperty("pivot")]
|
||||
public TexturePackerPoint Pivot { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.IO;
|
||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
||||
{
|
||||
[ContentImporter(".json", DefaultProcessor = "TexturePackerJsonProcessor", DisplayName = "Texture Packer JSON Importer - MonoGame.Extended")]
|
||||
public class TexturePackerJsonImporter : ContentImporter<TexturePackerFile>
|
||||
{
|
||||
public override TexturePackerFile Import(string filename, ContentImporterContext context)
|
||||
{
|
||||
using (var streamReader = new StreamReader(filename))
|
||||
{
|
||||
var serializer = new JsonSerializer();
|
||||
return (TexturePackerFile) serializer.Deserialize(streamReader, typeof(TexturePackerFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
||||
{
|
||||
public class TexturePackerMeta
|
||||
{
|
||||
[JsonProperty("app")]
|
||||
public string App { get; set; }
|
||||
|
||||
[JsonProperty("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
[JsonProperty("image")]
|
||||
public string Image { get; set; }
|
||||
|
||||
[JsonProperty("format")]
|
||||
public string Format { get; set; }
|
||||
|
||||
[JsonProperty("size")]
|
||||
public TexturePackerSize Size { get; set; }
|
||||
|
||||
[JsonProperty("scale")]
|
||||
public string Scale { get; set; }
|
||||
|
||||
[JsonProperty("smartupdate")]
|
||||
public string SmartUpdate { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
||||
{
|
||||
public class TexturePackerPoint
|
||||
{
|
||||
[JsonProperty("x")]
|
||||
public double X { get; set; }
|
||||
|
||||
[JsonProperty("y")]
|
||||
public double Y { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
||||
{
|
||||
public class TexturePackerRectangle
|
||||
{
|
||||
[JsonProperty("x")]
|
||||
public int X { get; set; }
|
||||
|
||||
[JsonProperty("y")]
|
||||
public int Y { get; set; }
|
||||
|
||||
[JsonProperty("w")]
|
||||
public int Width { get; set; }
|
||||
|
||||
[JsonProperty("h")]
|
||||
public int Height { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MonoGame.Extended.Content.Pipeline.TextureAtlases
|
||||
{
|
||||
public class TexturePackerSize
|
||||
{
|
||||
[JsonProperty("w")]
|
||||
public int Width { get; set; }
|
||||
|
||||
[JsonProperty("h")]
|
||||
public int Height { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
{"frames": [
|
||||
|
||||
{
|
||||
"filename": "1.png",
|
||||
"frame": {"x":2,"y":2,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "2.png",
|
||||
"frame": {"x":36,"y":2,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "3.png",
|
||||
"frame": {"x":70,"y":2,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "4.png",
|
||||
"frame": {"x":2,"y":36,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "5.png",
|
||||
"frame": {"x":36,"y":36,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "6.png",
|
||||
"frame": {"x":70,"y":36,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "7.png",
|
||||
"frame": {"x":2,"y":70,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "8.png",
|
||||
"frame": {"x":36,"y":70,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
},
|
||||
{
|
||||
"filename": "9.png",
|
||||
"frame": {"x":70,"y":70,"w":32,"h":32},
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": {"x":0,"y":0,"w":32,"h":32},
|
||||
"sourceSize": {"w":32,"h":32},
|
||||
"pivot": {"x":0.5,"y":0.5}
|
||||
}],
|
||||
"meta": {
|
||||
"app": "http://www.codeandweb.com/texturepacker",
|
||||
"version": "1.0",
|
||||
"image": "test-tileset.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {"w":104,"h":104},
|
||||
"scale": "1",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:f5f4c00eb32fae603057f0d9dc5c7b73:ca39697f48630ecdea6d81a8fdc48cf6:c79a4cc8e4ba9657462e67dafcaf93d2$"
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ namespace Sandbox
|
||||
//_spriteBatch.End();
|
||||
|
||||
_spriteBatch.Begin(transformMatrix: _camera.GetViewMatrix());
|
||||
_spriteBatch.Draw(_textureRegion, _sprite.GetBoundingRectangle(), Color.White);
|
||||
//_spriteBatch.Draw(_textureRegion, _sprite.GetBoundingRectangle(), Color.White);
|
||||
_spriteBatch.Draw(_sprite);
|
||||
_spriteBatch.End();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user