Textures not displaying (beginner)

Hi all,



First off, thanks for developing such a good API and making it freely available.



I am new to JME (3.0) and have the problem that my custom textures (stored under src/Textures/Sky) do not display. I am trying to create simple sky however all that I am getting when running the game is a black screen. No exceptions are thrown. The texture in use is a 1024 × 768 JPEG image.



Code is as follows:



// Create the sky. The sky is represented as a sphere and

// anything that the user sees is located within this sphere

Sphere skyMesh = new Sphere(10, 10, 100, false, true);

skySphere = new Geometry(“Sky”, skyMesh);

skySphere.updateModelBound();

skySphere.setQueueBucket(Bucket.Sky);



// Create a sky material and load it

Material skyMaterial = new Material(assetManager, “Common/MatDefs/Misc/Sky.j3md”);

TextureKey key = new TextureKey(“assets/Textures/Sky/sky.jpg”, true);

key.setGenerateMips(true);

// key.setAsCube(true);

Texture tex = assetManager.loadTexture(key);

skyMaterial.setTexture(“m_Texture”, tex);

skyMaterial.setVector3(“m_NormalScale”, Vector3f.UNIT_XYZ);



skySphere.setMaterial(skyMaterial);




I am sure that this issue was addressed before, however I could not find any solution on the forum / wiki. Any help / pointers / solutions would be greatly appreciated.



Thanks for your time :slight_smile:

Since you store your assets in the source directory they will be part of the classpath and so they are available as “/Textures/Sky/sky.jpg”. If you use jMonkeyPlatform, the files in the “assets” folder are also made part of the classpath, so you only need that “assets” prefix when you really create a folder called “assets” in your src directory.

So try

TextureKey key = new TextureKey(“Textures/Sky/sky.jpg”, true);



Cheers,

Normen

1 Like

Thanks for your reply. However this throws NullPointerException, indicating that it can’t find the .jpg :frowning:

if you do not set

skyMaterial.setBoolean(“m_SphereMap”, true);

the sky material loads your image as it was a cube map, maybe that’s the problem

1 Like

@nehon – thanks, but I had also tried that before (no luck). Just tried it again, and I still only get a black screen. I also changed texture files and used various formats; to no avail. Any ideas>



EDIT: I’m an idiot. After having made your change, I hadn’t reset my texture path. It all works now. Thanks a lot!!! Really appreciated :slight_smile: