private void LoadRegions(TextureAtlasData data, Dictionary <TextureAtlasData.Page, TextureContext> pageToTexture) { foreach (var region in data.Regions) { int width = region.Width; int height = region.Height; AtlasRegion atlasRegion = new AtlasRegion(pageToTexture[region.Page], region.Left, region.Top, region.Rotate ? height : width, region.Rotate ? width : height) { Index = region.Index, Name = region.Name, OffsetX = region.OffsetX, OffsetY = region.OffsetY, OriginalWidth = region.OriginalWidth, OriginalHeight = region.OriginalHeight, Rotate = region.Rotate, Splits = region.Splits, Pads = region.Pads, }; if (region.Flip) { atlasRegion.Flip(false, true); } Regions.Add(atlasRegion); } }
public TextureAtlas(GraphicsDevice graphicsDevice, TextureAtlasData data) { Textures = new HashSet<TextureContext>(); Regions = new List<AtlasRegion>(); if (data != null) Load(graphicsDevice, data); }
protected override TextureAtlasData _BuildTextureAtlasData(TextureAtlasData textureAtlasData, object textureAtlas) { if (textureAtlasData == null) { return(BaseObject.BorrowObject <GodotTextureAtlasData>()); } return(null); }
internal TextureAtlas(TextureAtlasData data) { ImagePath = data.ImagePath; _textures = new Dictionary <string, Rectangle>(); foreach (var sub in data.SubTextures) { _textures.Add(sub.Name, new Rectangle(sub.X, sub.Y, sub.Width, sub.Height)); } }
public TextureAtlas(ContentManager contentManager, TextureAtlasData data) { Textures = new HashSet <TextureContext>(); Regions = new List <AtlasRegion>(); if (data != null) { Load(contentManager, data); } }
public TextureAtlas(GraphicsDevice graphicsDevice, TextureAtlasData data) { Textures = new HashSet <TextureContext>(); Regions = new List <AtlasRegion>(); if (data != null) { Load(graphicsDevice, data); } }
public static TextureAtlas LoadAtlas(TextureAtlasData data) { var pixmap = new Pixmap(data.Data, data.Width, data.Height); var texture = new Texture2D(pixmap, false, false); var atlas = TextureAtlas.FromAtlas(texture, data.Atlas); atlas.Id = data.Id; return(atlas); }
private void Load(GraphicsDevice graphicsDevice, TextureAtlasData data) { Dictionary <TextureAtlasData.Page, TextureContext> pageToTexture = new Dictionary <TextureAtlasData.Page, TextureContext>(); foreach (var page in data.Pages) { TextureContext texture = page.Texture ?? new TextureContext(graphicsDevice, page.TextureFile, true); texture.Filter = page.Filter; texture.WrapU = page.UWrap; texture.WrapV = page.VWrap; Textures.Add(texture); pageToTexture[page] = texture; } LoadRegions(data, pageToTexture); }
private void Load(ContentManager contentManager, TextureAtlasData data) { Dictionary <TextureAtlasData.Page, TextureContext> pageToTexture = new Dictionary <TextureAtlasData.Page, TextureContext>(); foreach (var page in data.Pages) { TextureContext texture = page.Texture ?? new TextureContext(contentManager, page.TextureFile, false); texture.Filter = page.Filter; texture.WrapU = page.UWrap; texture.WrapV = page.VWrap; Textures.Add(texture); pageToTexture[page] = texture; } LoadRegions(data, pageToTexture); }
protected override void LoadContent() { _viewportAdapter = new ScalingViewportAdapter(_graphics.GraphicsDevice, 1600, 900); _camera = new OrthographicCamera(_viewportAdapter); _spriteBatch = new SpriteBatch(_graphics.GraphicsDevice); if (File.Exists(@"Content\allSprites_default.xml")) { _atlas = TextureAtlasData.CreateFromFile(Content, @"Content\allSprites_default.xml"); _projectileFactory = new ProjectileFactory(_entityManager, _atlas); } var map = Content.Load <TiledMap>("map01"); _mapRenderer = new TiledMapRenderer(_graphics.GraphicsDevice); LoadMap(map); _player = _entityManager.AddEntity( new Player(_atlas.GetRegion("tankBody_red"), _atlas.GetRegion("tankRed_barrel1"), _projectileFactory) ); _movementController = new MovementController(_player, _camera); }
public TextureAtlas(ContentManager contentManager, TextureAtlasData data) { Textures = new HashSet<TextureContext>(); Regions = new List<AtlasRegion>(); if (data != null) Load(contentManager, data); }
private void LoadRegions(TextureAtlasData data, Dictionary<TextureAtlasData.Page, TextureContext> pageToTexture) { foreach (var region in data.Regions) { int width = region.Width; int height = region.Height; AtlasRegion atlasRegion = new AtlasRegion(pageToTexture[region.Page], region.Left, region.Top, region.Rotate ? height : width, region.Rotate ? width : height) { Index = region.Index, Name = region.Name, OffsetX = region.OffsetX, OffsetY = region.OffsetY, OriginalWidth = region.OriginalWidth, OriginalHeight = region.OriginalHeight, Rotate = region.Rotate, Splits = region.Splits, Pads = region.Pads, }; if (region.Flip) atlasRegion.Flip(false, true); Regions.Add(atlasRegion); } }
private void Load(GraphicsDevice graphicsDevice, TextureAtlasData data) { Dictionary<TextureAtlasData.Page, TextureContext> pageToTexture = new Dictionary<TextureAtlasData.Page, TextureContext>(); foreach (var page in data.Pages) { TextureContext texture = page.Texture ?? new TextureContext(graphicsDevice, page.TextureFile, true); texture.Filter = page.Filter; texture.WrapU = page.UWrap; texture.WrapV = page.VWrap; Textures.Add(texture); pageToTexture[page] = texture; } LoadRegions(data, pageToTexture); }
private void Load(ContentManager contentManager, TextureAtlasData data) { Dictionary<TextureAtlasData.Page, TextureContext> pageToTexture = new Dictionary<TextureAtlasData.Page, TextureContext>(); foreach (var page in data.Pages) { TextureContext texture = page.Texture ?? new TextureContext(contentManager, page.TextureFile, false); texture.Filter = page.Filter; texture.WrapU = page.UWrap; texture.WrapV = page.VWrap; Textures.Add(texture); pageToTexture[page] = texture; } LoadRegions(data, pageToTexture); }
static int IndexComparator(TextureAtlasData.Region region1, TextureAtlasData.Region region2) { int i1 = region1.Index; if (i1 == -1) i1 = int.MaxValue; int i2 = region2.Index; if (i2 == -1) i2 = int.MaxValue; return i1 - i2; }
/// <summary> /// Parse the json file at the given path and return the resulting TextureAtlas. /// Don't forget to load the texture using <see cref="LoadContent"/>. /// </summary> /// <param name="path"></param> /// <returns></returns> public static TextureAtlas FromJson(string path) { return(new TextureAtlas(TextureAtlasData.FromJson(path))); }