public float getTexHeight() { return ((float) height) / page.getHeight(); }
public void setEffectsTexture(Texture newEffectsTexture) { if ((effectsTexture.getWidth() == newEffectsTexture.getWidth()) && (effectsTexture.getHeight() == newEffectsTexture.getHeight())) { this.effectsTexture = newEffectsTexture; } else { // This should not be possible with the current BlockSelectionRenderSystem implementation throw new RuntimeException("New effectsTexture must have same height and width as the original effectsTexture"); } }
@Override public int getHeight() { return TeraMath.ceilToInt(texture.getHeight() * subregion.height()); }
@Override public int getHeight() { return TeraMath.ceilToInt(texture.getHeight() * region.height()); }
private void reloadHeightmap() { logger.info("Reading height map '{}'", configuration.heightMap); ResourceUrn urn = new ResourceUrn("core", configuration.heightMap); Texture texture = Assets.getTexture(urn).get(); ByteBuffer[] bb = texture.getData().getBuffers(); IntBuffer intBuf = bb[0].asIntBuffer(); mapWidth = texture.getWidth(); mapHeight = texture.getHeight(); heightmap = new float[mapWidth][mapHeight]; while (intBuf.position() < intBuf.limit()) { int pos = intBuf.position(); long val = intBuf.get() & 0xFFFFFFFFL; heightmap[pos % mapWidth][pos / mapWidth] = val / (256 * 256 * 256 * 256f); } }
public FontDataBuilder endCharacter() { Texture page = pages.get(characterPage); FontCharacter character = new FontCharacter(((float) characterX / page.getWidth()), ((float) characterY / page.getHeight()), characterWidth, characterHeight, characterXOffset, characterYOffset, characterXAdvance, page, pageMats.get(characterPage)); characters.put(currentCharacterId, character); return this; }
/** * @param atlas The texture atlas that is being used * @param atlasSize How many textures the atlas contains in it's width and height. * @param validTextures Indices of the valid textures */ public TextureOffsetGeneratorComponent(final Texture atlas, final Vector2i atlasSize, final Vector2i[] validTextures) { final float textureWidth = atlas.getWidth() / (float) atlasSize.getX(); final float textureHeight = atlas.getHeight() / (float) atlasSize.getY(); Function<Vector2i, Vector2f> absolute2Relative = (absolute) -> new Vector2f( absolute.getX() * textureWidth, absolute.getY() * textureHeight ); this.validOffsets = new LinkedList<>(); for (Vector2i offset : validTextures) { this.validOffsets.add(absolute2Relative.apply(offset)); } } }
@Override public void renderOverlay() { for (EntityRef entity : entityManager.getEntitiesWith(BlockSelectionComponent.class)) { BlockSelectionComponent blockSelectionComponent = entity.getComponent(BlockSelectionComponent.class); if (blockSelectionComponent.shouldRender) { Texture texture = blockSelectionComponent.texture; if (null == texture) { texture = Assets.getTexture("engine:selection").get(); } Vector2i textureDimensions = new Vector2i(texture.getWidth(), texture.getHeight()); BlockSelectionRenderer selectionRenderer = cachedBlockSelectionRendererByTextureDimensionsMap.get(textureDimensions); if (null == selectionRenderer) { selectionRenderer = new BlockSelectionRenderer(texture); cachedBlockSelectionRendererByTextureDimensionsMap.put(textureDimensions, selectionRenderer); } else { selectionRenderer.setEffectsTexture(texture); } renderOverlayForOneBlockSelection(blockSelectionComponent, selectionRenderer); } } }
Vector2i size = def.getTextureSize(); if (size == null) { size = new Vector2i(texture.get().getWidth(), texture.get().getHeight());
@Override public Rect2i getPixelRegion() { return Rect2i.createFromMinAndSize(TeraMath.floorToInt(subregion.minX() * texture.getWidth()), TeraMath.floorToInt(subregion.minY() * texture.getHeight()), getWidth(), getHeight()); }
@Override public Rect2i getPixelRegion() { return Rect2i.createFromMinAndSize(TeraMath.floorToInt(region.minX() * texture.getWidth()), TeraMath.floorToInt(region.minY() * texture.getHeight()), getWidth(), getHeight()); } }
@Test public void testNoiseTextures() { int size = 256; ResourceUrn textureUriForWhiteNoise = TextureUtil.getTextureUriForWhiteNoise(size, 123354, 0, 255); String simpleString = textureUriForWhiteNoise.toString(); Optional<Texture> tex = Assets.getTexture(simpleString); assertTrue(tex.isPresent()); assertTrue(tex.get().getWidth() == size); assertTrue(tex.get().getHeight() == size); } }