public Texture loadTexture(String name){ TextureKey key = new TextureKey(name, true); key.setGenerateMips(true); return loadTexture(key); }
protected static String formatMatParamTexture(MatParamTexture param) { StringBuilder ret = new StringBuilder(); Texture tex = (Texture) param.getValue(); TextureKey key; if (tex != null) { key = (TextureKey) tex.getKey(); if (key != null && key.isFlipY()) { ret.append("Flip "); } ret.append(formatWrapMode(tex, Texture.WrapAxis.S)); ret.append(formatWrapMode(tex, Texture.WrapAxis.T)); ret.append(formatWrapMode(tex, Texture.WrapAxis.R)); //Min and Mag filter Texture.MinFilter def = Texture.MinFilter.BilinearNoMipMaps; if (tex.getImage().hasMipmaps() || (key != null && key.isGenerateMips())) { def = Texture.MinFilter.Trilinear; } if (tex.getMinFilter() != def) { ret.append("Min").append(tex.getMinFilter().name()).append(" "); } if (tex.getMagFilter() != Texture.MagFilter.Bilinear) { ret.append("Mag").append(tex.getMagFilter().name()).append(" "); } ret.append("\"").append(key.getName()).append("\""); } return ret.toString(); }
textureKey = new TextureKey(textureValues.get(0), false); } else { String texturePath = value.trim(); textureKey = new TextureKey(texturePath, flipY); textureKey = new TextureKey(textureValues.get(textureValues.size() - 1), false); textureKey.setTextureTypeHint(Texture.Type.ThreeDimensional); break; case TextureArray: textureKey.setTextureTypeHint(Texture.Type.TwoDimensionalArray); break; case TextureCubeMap: textureKey.setTextureTypeHint(Texture.Type.CubeMap); break; textureKey.setGenerateMips(true); texture = new Texture2D(PlaceholderAssets.getPlaceholderImage(assetManager)); texture.setKey(textureKey); texture.setName(textureKey.getName());
/** * Create a sky using the given cubemap or spheremap texture. * * @param assetManager from which to load materials * @param textureName the path to the texture asset to use * @param envMapType see {@link EnvMapType} * @return a new spatial representing the sky, ready to be attached to the * scene graph */ public static Spatial createSky(AssetManager assetManager, String textureName, EnvMapType envMapType) { TextureKey key = new TextureKey(textureName, true); key.setGenerateMips(false); if (envMapType == EnvMapType.CubeMap) { key.setTextureTypeHint(Texture.Type.CubeMap); } Texture tex = assetManager.loadTexture(key); return createSky(assetManager, tex, envMapType); }
@Override public Image loadImage(final String filename) { TextureKey key = new TextureKey(filename, false); key.setAnisotropy(0); key.setGenerateMips(false); Texture2D texture = (Texture2D) display.getAssetManager().loadTexture(key); return new ImageImpl(texture.getImage()); }
/** * Set the image to put on the picture. * * @param assetManager The {@link AssetManager} to use to load the image. * @param imgName The image name. * @param useAlpha If true, the picture will appear transparent and allow * objects behind it to appear through. If false, the transparent * portions will be the image's color at that pixel. */ public void setImage(AssetManager assetManager, String imgName, boolean useAlpha){ TextureKey key = new TextureKey(imgName, true); Texture2D tex = (Texture2D) assetManager.loadTexture(key); setTexture(assetManager, tex, useAlpha); }
/** * Loads a texture. * * @param name * @param generateMipmaps Enable if applying texture to 3D objects, disable * for GUI/HUD elements. * @return */ public Texture loadTexture(String name, boolean generateMipmaps){ TextureKey key = new TextureKey(name, true); key.setGenerateMips(generateMipmaps); key.setAsCube(false); return loadTexture(key); }
TextureKey texKey = new TextureKey(folderName + path, true); texKey.setGenerateMips(genMips); texKey.setAsCube(cubic); texKey = new TextureKey(folderName + "../textures/" + path, true); texKey.setGenerateMips(genMips); texKey.setAsCube(cubic); try texKey = new TextureKey(path, true); texKey.setGenerateMips(genMips); texKey.setAsCube(cubic); try textures[texUnit].setName(texKey.getName());
TextureKey key = new TextureKey(absoluteName); key.setFlipY(true); key.setGenerateMips(generateMipmaps); result = assetManager.loadTexture(key); result.setKey(key); TextureKey key = new TextureKey(assetName); key.setFlipY(true); key.setGenerateMips(generateMipmaps); AssetInfo info = assetManager.locateAsset(key); if (info != null) { TextureKey key = new TextureKey(name); assetManager.loadTexture(key); } catch (AssetNotFoundException | AssetLoadException e) {
if (texKey.getTextureTypeHint() == Texture.Type.CubeMap) { if (texKey.isFlipY()) { } else if (texKey.getTextureTypeHint() == Texture.Type.ThreeDimensional) { tex = new Texture3D(); } else { if (img.hasMipmaps() || texKey.isGenerateMips()) { tex.setMinFilter(Texture.MinFilter.Trilinear); tex.setAnisotropicFilter(texKey.getAnisotropy()); tex.setName(texKey.getName()); tex.setImage(img); return tex;
@Override public Object postProcess(Object asset) { Image img = (Image) asset; if (img == null) { return null; } Texture tex; if (isAsCube()) { if (isFlipY()) { // also flip -y and +y image in cubemap ByteBuffer pos_y = img.getData(2); img.setData(2, img.getData(3)); img.setData(3, pos_y); } tex = new TextureCubeMap(); } else if (isAsTexture3D()) { tex = new Texture3D(); } else { tex = new Texture2D(); } // enable mipmaps if image has them // or generate them if requested by user if (img.hasMipmaps() || isGenerateMips()) { tex.setMinFilter(Texture.MinFilter.Trilinear); } tex.setAnisotropicFilter(getAnisotropy()); tex.setName(getName()); tex.setImage(img); return tex; }
TextureKey tex1key = new TextureKey("Models/Sign Post/Sign Post.jpg", false); tex1key.setGenerateMips(true); if (!originalKey.equals(tex1key)){ System.out.println("TEXTURE KEYS ARE NOT EQUAL");
public Texture loadTexture(String name, boolean generateMipmaps, boolean flipY, boolean asCube, int aniso){ TextureKey key = new TextureKey(name, flipY); key.setGenerateMips(generateMipmaps); key.setAsCube(asCube); key.setAnisotropy(aniso); return loadTexture(key); }
public Object load(AssetInfo info) throws IOException { boolean flip = ((TextureKey) info.getKey()).isFlipY(); Image img = null; InputStream in = null; try { in = info.openStream(); img = loadImageData(Format.RGBA8, flip, in); } finally { if (in != null) { in.close(); } } return img; }
public Object load(AssetInfo info) throws IOException { if (!(info.getKey() instanceof TextureKey)) { throw new IllegalArgumentException("Texture assets must be loaded using a TextureKey"); } InputStream stream = null; try { stream = info.openStream(); in = new LittleEndien(stream); loadHeader(); if (texture3D) { ((TextureKey) info.getKey()).setTextureTypeHint(Texture.Type.ThreeDimensional); } else if (depth > 1) { ((TextureKey) info.getKey()).setTextureTypeHint(Texture.Type.CubeMap); } ArrayList<ByteBuffer> data = readData(((TextureKey) info.getKey()).isFlipY()); return new Image(pixelFormat, width, height, depth, data, sizes, ColorSpace.sRGB); } finally { if (stream != null){ stream.close(); } } }
@Override protected Texture toJmeObject() { Image image = null; TextureKey key = null; if (media != null) { image = (Image) media.getJmeObject(); key = media.getTextureKey(); } if (image == null) { image = PlaceholderAssets.getPlaceholderImage(assetManager); } Texture2D tex = new Texture2D(image); if (key != null) { tex.setKey(key); tex.setName(key.getName()); tex.setAnisotropicFilter(key.getAnisotropy()); } tex.setMinFilter(MinFilter.Trilinear); tex.setMagFilter(MagFilter.Bilinear); if (wrapModeU == 0) { tex.setWrap(WrapAxis.S, WrapMode.Repeat); } if (wrapModeV == 0) { tex.setWrap(WrapAxis.T, WrapMode.Repeat); } return tex; }
tKey = new TextureKey("dummy" + ext, flipY); try { result = assetManager.loadAssetFromStream(tKey, inputStream);
TextureKey key = new TextureKey("Textures/3D/flame.dds"); key.setGenerateMips(true); key.setTextureTypeHint(Texture.Type.ThreeDimensional);
public static Spatial createSky(AssetManager assetManager, String textureName, boolean sphereMap) { TextureKey key = new TextureKey(textureName, true); key.setGenerateMips(true); key.setAsCube(!sphereMap); Texture tex = assetManager.loadTexture(key); return createSky(assetManager, tex, sphereMap); } }