LoadedTextureInfo(int width, int height, int depth, TextureData data) { this.width = width; this.height = height; this.depth = depth; this.wrapMode = data.getWrapMode(); this.filterMode = data.getFilterMode(); this.textureData = data; }
@Test public void successTest() throws IOException { BufferedImage image = createBufferedImage(2, 3, BufferedImage.TYPE_3BYTE_BGR); TextureData textureData = AWTTextureFormat.convertToTextureData(image, Texture.FilterMode.LINEAR); Assert.assertNotNull(textureData); Assert.assertEquals(2, textureData.getWidth()); Assert.assertEquals(3, textureData.getHeight()); Assert.assertEquals(Texture.FilterMode.LINEAR, textureData.getFilterMode()); }
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 protected void doReload(SubtextureData data) { data.getTexture().subscribeToDisposal(disposalAction); if (texture != null) { texture.unsubscribeToDisposal(disposalAction); } this.texture = data.getTexture(); this.subregion = data.getRegion(); }
@Override public Optional<TextureData> getAssetData(ResourceUrn urn) throws IOException { if (TerasologyConstants.ENGINE_MODULE.equals(urn.getModuleName()) && TextureUtil.COLOR_RESOURCE_NAME.equals(urn.getResourceName())) { Name fragmentName = urn.getFragmentName(); if (!fragmentName.isEmpty()) { Color color = TextureUtil.getColorForColorName(fragmentName.toLowerCase()); return Optional.of(TextureDataFactory.newInstance(color)); } } return Optional.empty(); } }
public float getTexHeight() { return ((float) height) / page.getHeight(); }
public float getTexWidth() { return ((float) width) / page.getWidth(); }
public void setEffectsTexture(TextureRegionAsset textureRegionAsset) { setEffectsTexture(textureRegionAsset.getTexture()); textureRegion = textureRegionAsset.getRegion(); // reinitialize to recreate the mesh's UV coordinates for this textureRegion initialize(); }
@Override public void drawTextureRawBordered(TextureRegion texture, Rect2i region, Border border, boolean tile, int ux, int uy, int uw, int uh) { drawTextureRawBordered(texture, region, border, tile, (float) ux / texture.getWidth(), (float) uy / texture.getHeight(), (float) uw / texture.getWidth(), (float) uh / texture.getHeight()); }
@Override public int getHeight() { return textureData.getHeight(); }
@Override public FilterMode getFilterMode() { return textureData.getFilterMode(); }
@Override public WrapMode getWrapMode() { return textureData.getWrapMode(); }
@Override public boolean isRenderable() { for (Texture texture : textureMap.valueCollection()) { if (!texture.isLoaded()) { return false; } } return true; }
@Override public TextureData getData() { return new TextureData(textureData); }
private static String getColorName(Color color) { StringBuilder builder = new StringBuilder(); appendColorName(builder, color); return builder.toString(); }
@Test public void testRedColorNoAlphaTransformedToTextureUri() throws Exception { Color expectedColor = Color.RED; int expectedRed = -1; int expectedGreen = 0; int expectedBlue = 0; int expectedAlpha = -1; testRepeatedColorInDataTexture(expectedColor, expectedRed, expectedGreen, expectedBlue, expectedAlpha); }
@Override public TextureData getData() { return new TextureData(resources.loadedTextureInfo.getTextureData()); }