IllegalArgumentException

I keep getting an IllegalArgumentException when i try to load my textures, here is the code

[java]

package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.scene.shape.Sphere;

import com.jme3.texture.Texture;



/**

  • test
  • @author normenhansen

    */

    public class Main extends SimpleApplication {



    public static void main(String[] args) {

    Main app = new Main();

    app.start();

    }



    @Override

    public void simpleInitApp() {

    Sphere sph = new Sphere(20, 20, 4);

    Geometry geom2 = new Geometry("Sphere", sph);

    Material mat_sphere = new Material(assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");

    mat_sphere.setTexture("GrassTexture", assetManager.loadTexture("Textures/GrassTexture.png"));

    geom2.setMaterial(mat_sphere);

    rootNode.attachChild(geom2);

    }



    @Override

    public void simpleUpdate(float tpf) {

    //TODO: add update code

    }



    @Override

    public void simpleRender(RenderManager rm) {

    //TODO: add render code

    }

    }



    [/java]



    I dont get it, i placed the files in the assets/Textures/ directory and it is png and the name is right. But i have no idea what is wrong. Do spheres have to have something special?

There is no texture named “GrassTexture” in SimpleTextured.j3md… You sure you read the tutorial on materials?

I basically copied it from the material tutorial and its telling me, i changed “GrassTexture” to ColorMap and i still get an error, what can i put there that wont give me an illegalargumentexception?

dev1462 said:
I basically copied it from the material tutorial

Really? to what tutorial do you refer? I really doubt there is such a mistake in the tutorials, but if there is, could you point it out so we can fix it asap.

This can't work with the "GrassTexture" parameter, however it should work with "ColorMap".
Could you post the complete stack trace?

Check that this statement does not return null. (It would be a path problem, the file is not present or the case do not match the actual file name etc...)

assetManager.loadTexture("Textures/GrassTexture.png");

if you call

mat_sphere.setTexture("ColorMap", null);

the engine tries to remove any texture previously bound to the ColorMap parameter, and if this texture does not exist throw an IllegalArgumentException.