In the simplest case, a material loads one image file and slaps it onto the geometry's surface. Let's see what that looks like.
Make a copy of
Main.java
and name the classTexturesOpaqueTransparent.java
. Remember to also refactor the first line of themain()
method toTexturesOpaqueTransparent app = new TexturesOpaqueTransparent();
.Copy the provided
assets/Interface/Monkey.png
image to your project'sassets/Interface
directory. This will be our texture.Replace the blue cube code in the
simpleInitApp()
method with the following:Sphere sphereMesh = new Sphere(16, 16, 1); Geometry sphereGeo = new Geometry("lit textured sphere", sphereMesh); Material sphereMat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md"); sphereMat.setTexture("DiffuseMap", assetManager.loadTexture("Interface/Monkey.png")); sphereGeo.setMaterial(sphereMat); sphereGeo.move(-2f, 0f, 0f); sphereGeo.rotate(FastMath.DEG_TO_RAD * -90, FastMath.DEG_TO_RAD *...