ArrayIndexOutOfBoundsException in IDList if no Light is attached to RootNode

Hi,



if there is no Light Used, i get an index out of bounds in the class IDList (in following code, the light is in a comment, uncomment it to make it work with out Exception). Is it possible to catch this earlyier and give a hint to the user that light is missing?



[java]

import com.jme3.app.SimpleApplication;

import com.jme3.light.DirectionalLight;

import com.jme3.material.Material;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.Spatial;

import com.jme3.scene.shape.Box;



/** Sample 3 - how to load an OBJ model, and OgreXML model,

  • a material/texture, or text. /

    public class HelloAssets extends SimpleApplication {



    public static void main(String[] args) {

    HelloAssets app = new HelloAssets();

    app.start();

    }



    @Override

    public void simpleInitApp() {

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

    fixedWallMaterial.setTexture("m_ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));

    Box fixedWallMesh = new Box(Vector3f.ZERO, 2.5f, 2.5f, 2.5f);

    for(int i=0; i < 81; ++i) {

    Spatial wall = new Geometry("Box"+i, fixedWallMesh );

    wall.setMaterial(fixedWallMaterial);

    wall.getLocalTranslation().setY(20);

    wall.getLocalTranslation().setX(i * 5 + 2);

    rootNode.attachChild(wall);

    }

    Box fixedWallMesh2 = new Box(Vector3f.ZERO, 2.5f, 2.5f, 2.5f);

    Material fixedWallMaterial2 = assetManager.loadMaterial("Textures/Terrain/Rock/Rock.j3m");

    for(int i=0; i < 81; ++i) {

    Spatial wall = new Geometry("Box#"+i, fixedWallMesh2 );

    wall.setMaterial(fixedWallMaterial2);

    wall.getLocalTranslation().setX(i * 5 + 2);

    rootNode.attachChild(wall);

    }



    /
    * You must add a light to make the model visible */

    //DirectionalLight sun = new DirectionalLight();

    // sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));

    // rootNode.addLight(sun);



    }

    }



    [/java]

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.ArrayIndexOutOfBoundsException: 16
at com.jme3.renderer.IDList.moveToNew(IDList.java:26)
at com.jme3.renderer.lwjgl.LwjglRenderer.setTexture(LwjglRenderer.java:1414)
at com.jme3.material.Material.render(Material.java:512)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:333)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:100)
at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:147)
at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:464)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:444)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:604)
at com.jme3.renderer.RenderManager.render(RenderManager.java:624)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:112)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:162)
at java.lang.Thread.run(Thread.java:662)


Greetings,
snare

PS: i am missing a "preview post" button :/
2 Likes

We were looking for a way to reproduce that bug since jME3’s inception. You’re a champion!



It happens because the texture stuff gets set up, but the mesh is never rendered, so the texture stuff is not cleaned up.

I am glad that i could help :slight_smile:



Keep up the good work



snare