@Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof TextureParameter)) { return false; } final TextureParameter other = (TextureParameter) obj; if (textureKey == null) { if (other.textureKey != null) { return false; } } else if (!textureKey.equals(other.textureKey)) { return false; } return true; }
public static synchronized TextureKey getKey(final ResourceSource source, final boolean flipped, final TextureStoreFormat storeFormat, final Texture.MinificationFilter minFilter) { return getKey(source, flipped, storeFormat, null, minFilter); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (textureKey == null ? 0 : textureKey.hashCode()); return result; }
public static synchronized TextureKey getKey(final ResourceSource source, final boolean flipped, final TextureStoreFormat storeFormat, final String id, final Texture.MinificationFilter minFilter) { final TextureKey key = new TextureKey(); key._source = source; key._flipped = flipped; key._minFilter = minFilter; key._format = storeFormat; key._id = id; key._code = Integer.MAX_VALUE; { WeakReference<TextureKey> ref; TextureKey check; for (final Iterator<WeakReference<TextureKey>> it = _keyCache.iterator(); it.hasNext();) { ref = it.next(); check = ref.get(); if (check == null) { // found empty, clean up it.remove(); continue; } if (check.equals(key)) { // found match, return return check; } } } // not found _keyCache.add(new WeakReference<TextureKey>(key)); return key; }
public void read(final InputCapsule capsule) throws IOException { _minificationFilter = capsule.readEnum("minificationFilter", MinificationFilter.class, MinificationFilter.NearestNeighborNoMipMaps); _image = (Image) capsule.readSavable("image", null); // pull our key, if exists final TextureKey key = (TextureKey) capsule.readSavable("textureKey", null); if (key != null) { _key = TextureKey.getKey(key.getSource(), key.isFlipped(), key.getFormat(), key.getId(), key.getMinificationFilter()); } else { // none set, so pop in a generated key _key = TextureKey.getRTTKey(_minificationFilter); } // pull texture image from resource, if possible. if (_image == null && _key != null && _key.getSource() != null) { TextureManager.loadFromKey(_key, null, this); } _borderColor.set((ColorRGBA) capsule.readSavable("borderColor", new ColorRGBA(ColorRGBA.BLACK_NO_ALPHA))); _hasBorder = capsule.readBoolean("hasBorder", false); _anisotropicFilterPercent = capsule.readFloat("anisotropicFilterPercent", 0.0f); _lodBias = capsule.readFloat("lodBias", 0.0f); _magnificationFilter = capsule.readEnum("magnificationFilter", MagnificationFilter.class, MagnificationFilter.Bilinear); _storeFormat = capsule.readEnum("storeFormat", TextureStoreFormat.class, TextureStoreFormat.RGBA8); _rttPixelDataType = capsule.readEnum("rttPixelDataType", PixelDataType.class, PixelDataType.UnsignedByte); }
private Texture createTexture() { textureClipmap = new Texture3D(); textureClipmap.setMinificationFilter(MinificationFilter.NearestNeighborNoMipMaps); textureClipmap.setMagnificationFilter(MagnificationFilter.NearestNeighbor); final Image img = new Image(); img.setWidth(textureSize); img.setHeight(textureSize); img.setDepth(textureLevels); img.setDataFormat(useAlpha ? ImageDataFormat.RGBA : ImageDataFormat.RGB); img.setDataType(PixelDataType.UnsignedByte); textureClipmap.setTextureKey(TextureKey.getRTTKey(textureClipmap.getMinificationFilter())); for (int l = 0; l < textureLevels; l++) { final ByteBuffer sliceData = BufferUtils.createByteBuffer(textureSize * textureSize * colorBits); img.setData(l, sliceData); if (l < validLevels) { levelDataList.get(l).sliceData = sliceData; } } textureClipmap.setImage(img); return textureClipmap; }
img = ImageLoaderUtil.loadImage(tkey.getSource(), tkey.isFlipped()); logger.warning("(image null) Could not load: " + tkey.getSource()); return TextureState.getDefaultTexture(); result.setMinificationFilter(tkey.getMinificationFilter()); result.setTextureStoreFormat(ImageUtils.getTextureStoreFormat(tkey.getFormat(), result.getImage()));
if (textureState.isEnabled() && textureState.getTexture() != null) { final TextureKey tKey = textureState.getTexture().getTextureKey(); final String tmpTextureName = tKey.getSource().getName(); final int lastIndexOfUnixPathSeparator = tmpTextureName.lastIndexOf('/'); final int lastIndexOfWindowsPathSeparator = tmpTextureName.lastIndexOf('\\'); if (tKey.isFlipped()) { ObjExporter.logger.warning("The texture " + tmpTextureName + " will have to be flipped manually when loading this OBJ file");
@MainThread public static void preloadCache(final ITextureUtils util) { for (final Texture t : _tCache.values()) { if (t == null) { continue; } if (t.getTextureKey().getSource() != null) { util.loadTexture(t, 0); } } }
/** DO NOT USE. FOR INTERNAL USE ONLY */ public static TextureKey initSavable() { return new TextureKey(); }
private Texture createTexture() { textureClipmap = new Texture3D(); textureClipmap.setMinificationFilter(MinificationFilter.NearestNeighborNoMipMaps); textureClipmap.setMagnificationFilter(MagnificationFilter.NearestNeighbor); // textureClipmap.setMinificationFilter(MinificationFilter.BilinearNoMipMaps); // textureClipmap.setMagnificationFilter(MagnificationFilter.Bilinear); final Image img = new Image(); img.setWidth(textureSize); img.setHeight(textureSize); img.setDepth(textureLevels); img.setDataFormat(useAlpha ? ImageDataFormat.RGBA : ImageDataFormat.RGB); img.setDataType(PixelDataType.UnsignedByte); textureClipmap.setTextureKey(TextureKey.getRTTKey(textureClipmap.getMinificationFilter())); for (int l = 0; l < textureLevels; l++) { final ByteBuffer sliceData = BufferUtils.createByteBuffer(textureSize * textureSize * colorBits); img.setData(l, sliceData); if (l < validLevels) { levelDataList.get(l).sliceData = sliceData; } } textureClipmap.setImage(img); return textureClipmap; }
img = ImageLoaderUtil.loadImage(tkey.getSource(), tkey.isFlipped()); logger.warning("(image null) Could not load: " + tkey.getSource()); return TextureState.getDefaultTexture(); result.setMinificationFilter(tkey.getMinificationFilter()); result.setTextureStoreFormat(ImageUtils.getTextureStoreFormat(tkey.getFormat(), result.getImage()));
public static synchronized TextureKey getKey(final ResourceSource source, final boolean flipped, final TextureStoreFormat storeFormat, final String id, final Texture.MinificationFilter minFilter) { final TextureKey key = new TextureKey(); key._source = source; key._flipped = flipped; key._minFilter = minFilter; key._format = storeFormat; key._id = id; key._code = Integer.MAX_VALUE; { WeakReference<TextureKey> ref; TextureKey check; for (final Iterator<WeakReference<TextureKey>> it = _keyCache.iterator(); it.hasNext();) { ref = it.next(); check = ref.get(); if (check == null) { // found empty, clean up it.remove(); continue; } if (check.equals(key)) { // found match, return return check; } } } // not found _keyCache.add(new WeakReference<TextureKey>(key)); return key; }
@MainThread public static void preloadCache(final Renderer r) { for (final Texture t : _tCache.values()) { if (t == null) { continue; } if (t.getTextureKey().getSource() != null) { r.loadTexture(t, 0); } } }
/** DO NOT USE. FOR INTERNAL USE ONLY */ public static TextureKey initSavable() { return new TextureKey(); }
tex.setTextureKey(TextureKey.getRTTKey(tex.getMinificationFilter())); } else if (tex.getTextureIdForContext(context.getGlContextRep()) != 0) { throw new Ardor3dException("Texture is already setup and has id.");
public static synchronized boolean clearKey(final TextureKey key) { WeakReference<TextureKey> ref; TextureKey check; for (final Iterator<WeakReference<TextureKey>> it = _keyCache.iterator(); it.hasNext();) { ref = it.next(); check = ref.get(); if (check != null && check.equals(key)) { it.remove(); return true; } } return false; }
public static synchronized TextureKey getKey(final ResourceSource source, final boolean flipped, final TextureStoreFormat storeFormat, final Texture.MinificationFilter minFilter) { return getKey(source, flipped, storeFormat, null, minFilter); }
tex = ((TextureState) system.getLocalRenderState(StateType.Texture)).getTexture(); if (tex != null) { if (tex.getTextureKey() != null && tex.getTextureKey().getSource() != null) { _imageLabel .setIcon(new ImageIcon(((URLResourceSource) tex.getTextureKey().getSource()).getURL())); logger.warning("image: " + tex + " : " + tex != null ? tex.getTextureKey().getSource().toString() : "");