/** * Add a texture for a specific map name at the location of another existing texture on the master map. * @param texture A texture to add to the atlas. * @param mapName A freely chosen map name that can be later retrieved as a Texture. * @param masterTexture The master texture for determining the location, it has to exist in tha master map. */ public void addTexture(Texture texture, String mapName, Texture masterTexture) { String sourceTextureName = textureName(masterTexture); if (sourceTextureName == null) { throw new IllegalStateException("Supplied master map texture has no asset key name!"); } else { addTexture(texture, mapName, sourceTextureName); } }
/** * 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; }
/** * Add a texture for a specific map name at the location of another existing texture on the master map. * @param texture A texture to add to the atlas. * @param mapName A freely chosen map name that can be later retrieved as a Texture. * @param masterTexture The master texture for determining the location, it has to exist in tha master map. */ public void addTexture(Texture texture, String mapName, Texture masterTexture) { String sourceTextureName = textureName(masterTexture); if (sourceTextureName == null) { throw new IllegalStateException("Supplied master map texture has no asset key name!"); } else { addTexture(texture, mapName, sourceTextureName); } }
private int addCubeGeometry() { Mesh cubeMesh = new BitCubeBox(1f, 1f, 1f); TextureAtlas atlas = new TextureAtlas(400, 1200); MatFactory matFact = getRenderRegCli().getOpticMaterialFacade(null, null); AssetManager assetMgr = matFact.getAssetManager(); Texture zeroTexture = assetMgr.loadTexture("textures/robosteps/Zero.png"); Texture oneTexture = assetMgr.loadTexture("textures/robosteps/One.png"); Texture blankTexture = assetMgr.loadTexture("textures/robosteps/BlankGray.png"); atlas.addTexture(zeroTexture, "ColorMap"); atlas.addTexture(oneTexture, "ColorMap"); atlas.addTexture(blankTexture, "ColorMap"); Material cubeMaterial = matFact.makeMatWithOptTexture("Common/MatDefs/Misc/Unshaded.j3md", "ColorMap", atlas.getAtlasTexture("ColorMap")); return addGeometry(cubeMesh, cubeMaterial, null, new Quaternion()); }
/** * 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; }