private String textureName(Texture texture) { if (texture == null) { return null; } AssetKey key = texture.getKey(); if (key != null) { return key.toString(); } else { return null; } }
/** * Add a geometries DiffuseMap (or ColorMap), NormalMap and SpecularMap to the atlas. * @param geometry * @return false if the atlas is full. */ public boolean addGeometry(Geometry geometry) { Texture diffuse = getMaterialTexture(geometry, "DiffuseMap"); Texture normal = getMaterialTexture(geometry, "NormalMap"); Texture specular = getMaterialTexture(geometry, "SpecularMap"); if (diffuse == null) { diffuse = getMaterialTexture(geometry, "ColorMap"); } if (diffuse != null && diffuse.getKey() != null) { String keyName = diffuse.getKey().toString(); if (!addTexture(diffuse, "DiffuseMap")) { return false; } else { if (normal != null && normal.getKey() != null) { addTexture(normal, "NormalMap", keyName); } if (specular != null && specular.getKey() != null) { addTexture(specular, "SpecularMap", keyName); } } return true; } return true; }
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(); }
textures[texUnit].setMagFilter(loadedTexture.getMagFilter()); textures[texUnit].setAnisotropicFilter(loadedTexture.getAnisotropicFilter()); textures[texUnit].setKey(loadedTexture.getKey());
TextureKey originalKey = (TextureKey) mat4.getTextureParam("DiffuseMap").getTextureValue().getKey(); TextureKey tex1key = new TextureKey("Models/Sign Post/Sign Post.jpg", false); tex1key.setGenerateMips(true);
case TextureCubeMap: Texture texVal = (Texture) value; TextureKey texKey = (TextureKey) texVal.getKey(); if (texKey == null){
private String textureName(Texture texture) { if (texture == null) { return null; } AssetKey key = texture.getKey(); if (key != null) { return key.toString(); } else { return null; } }
/** * Add a geometries DiffuseMap (or ColorMap), NormalMap and SpecularMap to the atlas. * @param geometry * @return false if the atlas is full. */ public boolean addGeometry(Geometry geometry) { Texture diffuse = getMaterialTexture(geometry, "DiffuseMap"); Texture normal = getMaterialTexture(geometry, "NormalMap"); Texture specular = getMaterialTexture(geometry, "SpecularMap"); if (diffuse == null) { diffuse = getMaterialTexture(geometry, "ColorMap"); } if (diffuse != null && diffuse.getKey() != null) { String keyName = diffuse.getKey().toString(); if (!addTexture(diffuse, "DiffuseMap")) { return false; } else { if (normal != null && normal.getKey() != null) { addTexture(normal, "NormalMap", keyName); } if (specular != null && specular.getKey() != null) { addTexture(specular, "SpecularMap", keyName); } } return true; } return true; }
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(); }
textures[texUnit].setKey(loadedTexture.getKey());
textures[texUnit].setMagFilter(loadedTexture.getMagFilter()); textures[texUnit].setAnisotropicFilter(loadedTexture.getAnisotropicFilter()); textures[texUnit].setKey(loadedTexture.getKey());
textures[texUnit].setMagFilter(loadedTexture.getMagFilter()); textures[texUnit].setAnisotropicFilter(loadedTexture.getAnisotropicFilter()); textures[texUnit].setKey(loadedTexture.getKey());
/** * Assign different kind of maps (Specular, Norma, etc.) to material, if * found * * @param assetManager the asset manager * @param material the material to apply to */ public static void assignMapsToMaterial(AssetManager assetManager, Material material) { // Unharmed texture String diffuseTexture = ((Texture) material.getParam("DiffuseMap").getValue()).getKey().getName(); assignMapToMaterial(assetManager, material, "NormalMap", getNormalMapName(diffuseTexture)); assignMapToMaterial(assetManager, material, "SpecularMap", getSpecularMapName(diffuseTexture)); }
textures[texUnit].setKey(loadedTexture.getKey());
String diffuseTexture = ((Texture) material.getParam("DiffuseMap").getValue()).getKey().getName().replaceFirst("_DECAY\\d", ""); // Unharmed texture if (textureIndex > 0) {
case TextureCubeMap: Texture texVal = (Texture) value; TextureKey texKey = (TextureKey) texVal.getKey(); if (texKey == null){ throw new UnsupportedOperationException("The specified MatParam cannot be represented in J3M");
case TextureCubeMap: Texture texVal = (Texture) value; TextureKey texKey = (TextureKey) texVal.getKey(); if (texKey == null){