I’m trying to load texture from the Image and not from assets and they behave different. From asset my texture is stretched to each side of the cube, but from Image its cutting it on each side and not stretching it. Here is my code:
private Material createMaterialFromImage(String name, Image image) {
Material material = new Material(assetManager,
"Common/MatDefs/Misc/Unshaded.j3md");
Texture tex = new Texture2D();
tex.setMinFilter(Texture.MinFilter.Trilinear);
tex.setAnisotropicFilter(Integer.MAX_VALUE);
tex.setName(name);
tex.setImage(image);
material.setTexture("ColorMap", tex);
return material;
}
private Geometry createPicture(Image image) {
Material material = createMaterialFromImage("mat", image);
Geometry geometry =new Geometry("picture", new Box(1f, 1f, 0.01f));
geometry.setMaterial(material);
return geometry;
}
Geometry picture = new Geometry("picture", new Box(1.5f, 0.01f, 1f));
Texture fireTex = assetManager.loadTexture("Textures/fire.png");
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
material.setTexture("ColorMap", fireTex);
picture.setMaterial(material);
My problem was that I wasn’t positioning the objects correctly so they were overlapping making me thing that the texture was not stretching… I also have another question - When I was testing it on android I was getting errors AWTLoader not found. Am I missing some library for android?