@Override public void updateRect() { rect = Rect2f.createFromMinAndSize(4.5f, 0.05f, 1f, 1f); }
public BasicTextureRegion(Texture texture, Vector2f offset, Vector2f size) { this(texture, Rect2f.createFromMinAndSize(offset, size)); }
@Override public void updateRect() { this.rect = Rect2f.createFromMinAndSize( index() + 0.4f, 4.05f, 0.6f, 0.9f); }
@Override public void updateRect() { this.rect = Rect2f.createFromMinAndSize( index(), 4.05f, 0.4f, 0.9f); }
public ControlWidget addHUDElement(String uri) { return addHUDElement(uri, ControlWidget.class, Rect2f.createFromMinAndSize(0, 0, 1, 1)); }
private void createTextureAtlas(final Texture texture) { final Map<Name, Map<Name, SubtextureData>> textureAtlases = Maps.newHashMap(); final Vector2f texSize = new Vector2f(getRelativeTileSize(), getRelativeTileSize()); tileIndexes.forEachEntry((tileUri, index) -> { Vector2f coords = getTexCoords(index); SubtextureData subtextureData = new SubtextureData(texture, Rect2f.createFromMinAndSize(coords, texSize)); Map<Name, SubtextureData> textureAtlas = textureAtlases.get(tileUri.getModuleName()); if (textureAtlas == null) { textureAtlas = Maps.newHashMap(); textureAtlases.put(tileUri.getModuleName(), textureAtlas); } textureAtlas.put(tileUri.getResourceName(), subtextureData); return true; }); for (Map.Entry<Name, Map<Name, SubtextureData>> atlas : textureAtlases.entrySet()) { AtlasData data = new AtlasData(atlas.getValue()); Assets.generateAsset(new ResourceUrn(atlas.getKey(), new Name("terrain")), data, Atlas.class); } }
@Override public Rect2f deserialize(PersistedData data, DeserializationContext context) { if (!data.isNull() && data.isValueMap()) { PersistedDataMap map = data.getAsValueMap(); Vector2f min = context.deserializeAs(map.get(MIN_FIELD), Vector2f.class); Vector2f size = context.deserializeAs(map.get(SIZE_FIELD), Vector2f.class); return Rect2f.createFromMinAndSize(min, size); } return null; }
pos.x += tileX * tileSize.x; pos.y += tileY * tileSize.y; Rect2f tileLocation = Rect2f.createFromMinAndSize(offset.x + tileX * tileSize.x, offset.y + tileY * tileSize.y, tileSize.x, tileSize.y); out.put(new Name(name), new SubtextureData(texture, tileLocation));
private void process(FreeformDefinition freeform, Texture texture, Vector2i size, Map<Name, SubtextureData> out) { if (freeform.getName() == null || freeform.getName().isEmpty()) { logger.error("Bad subimage definition - missing mandatory property name"); return; } if (freeform.getMin() == null) { logger.error("Bad subimage definition '{}' - missing mandatory property min", freeform.getName()); return; } if (freeform.getSize() == null && freeform.getMax() == null) { logger.error("Bad subimage definition '{}' - requires one of max or size", freeform.getName()); return; } Vector2f min = new Vector2f((float) freeform.getMin().x / size.x, (float) freeform.getMin().y / size.y); if (freeform.getSize() != null) { Vector2f itemSize = new Vector2f((float) freeform.getSize().x / size.x, (float) freeform.getSize().y / size.y); out.put(new Name(freeform.getName()), new SubtextureData(texture, Rect2f.createFromMinAndSize(min, itemSize))); } else if (freeform.getMax() != null) { Vector2f max = new Vector2f((float) freeform.getMax().x / size.x, (float) freeform.getMax().y / size.y); out.put(new Name(freeform.getName()), new SubtextureData(texture, Rect2f.createFromMinAndMax(min, max))); } }