Time for action – illuminated opaque textures

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.

  1. Make a copy of Main.java and name the class TexturesOpaqueTransparent.java. Remember to also refactor the first line of the main() method to TexturesOpaqueTransparent app = new TexturesOpaqueTransparent();.
  2. Copy the provided assets/Interface/Monkey.png image to your project's assets/Interface directory. This will be our texture.
  3. 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"); ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.