What to do with Error: Couldn't build()

Started by Darai, October 12, 2015, 05:00:07 PM

Previous topic - Next topic

Darai

Hi guys,

I am now writing my code for some time and suddenly I am getting "Error: Couldn't build() ..."

It writes me, that I should check if I have:
1) the object assigned to a world ... which I solve by calling world.addObject(object) right on the previous line
2) if the TextureManager has all the necesary textures loaded ... which I check by calling TextureManager.getInstance().getTextureID(this.texName)

Well I don't know if that is all I can do to check what is wrong. I also don't know if this is all that can cause this error. So, do you have any suggestions what to do next in situation like this?

Thanks,
Martin.

EgonOlsen

There should be an exception printed out to the log before this actual message...

Darai

Sure there is,
10-12 16:14:35.278: W/System.err(18100): java.lang.ArrayIndexOutOfBoundsException: length=14; index=14
10-12 16:14:35.278: W/System.err(18100): at com.threed.jpct.Vectors.addVertex(Vectors.java:85)
10-12 16:14:35.278: W/System.err(18100): at com.threed.jpct.Object3D.setBoundingBox(Object3D.java:2557)
10-12 16:14:35.278: W/System.err(18100): at com.threed.jpct.Object3D.calcBoundingBox(Object3D.java:1208)
10-12 16:14:35.278: W/System.err(18100): at com.threed.jpct.Object3D.build(Object3D.java:1252)
10-12 16:14:35.278: W/System.err(18100): at com.threed.jpct.Object3D.build(Object3D.java:1222)
10-12 16:14:35.278: W/System.err(18100): at com.threed.jpct.World.renderScene(World.java:1045)
10-12 16:14:35.279: W/System.err(18100): at daraisoft.astro3d.renderer.AstroRenderer.onDrawFrame(AstroRenderer.java:62)
10-12 16:14:35.279: W/System.err(18100): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
10-12 16:14:35.279: W/System.err(18100): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
10-12 16:14:35.279: E/jPCT-AE(18100): [ 1444659275279 ] - ERROR: Couldn't build() object (object1531)! Check if the object is assigned to a world and if the TextureManager has all required textures loaded.
10-12 16:14:35.340: E/AndroidRuntime(18100): FATAL EXCEPTION: GLThread 1297
10-12 16:14:35.340: E/AndroidRuntime(18100): Process: daraisoft.astro3d, PID: 18100
10-12 16:14:35.340: E/AndroidRuntime(18100): java.lang.RuntimeException: [ 1444659275279 ] - ERROR: Couldn't build() object (object1531)! Check if the object is assigned to a world and if the TextureManager has all required textures loaded.
10-12 16:14:35.340: E/AndroidRuntime(18100): at com.threed.jpct.Logger.log(Logger.java:206)
10-12 16:14:35.340: E/AndroidRuntime(18100): at com.threed.jpct.Object3D.build(Object3D.java:1274)
10-12 16:14:35.340: E/AndroidRuntime(18100): at com.threed.jpct.Object3D.build(Object3D.java:1222)
10-12 16:14:35.340: E/AndroidRuntime(18100): at com.threed.jpct.World.renderScene(World.java:1045)
10-12 16:14:35.340: E/AndroidRuntime(18100): at daraisoft.astro3d.renderer.AstroRenderer.onDrawFrame(AstroRenderer.java:62)
10-12 16:14:35.340: E/AndroidRuntime(18100): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
10-12 16:14:35.340: E/AndroidRuntime(18100): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

Do you know what can cause this?

EgonOlsen

There's no room for the bounding box...strange...how do you create the object?

Darai

By copying the object (Object3D newOne = original.cloneObject();)  and it was a simple 2-triangle square.

After that, I am just adding it to the world and building it:
world.addObject(newOne);
newOne.build(false);

But you know what? It stopped... It was yelling that error on me for the whole yesterday and when I reinstalled the game today it is not doing that any more.

Hmm... I came here for your help, because this was a new error for me after I used the same method for introducing new objects into the world over and over again for the last year without any problems. I probably did something differently and just didn't realize the moment I fixed that. It is little bit funky. Since I am using xml files saved in the asset directory I have to sometimes fully uninstall the app from the device and install it again to apply the changes, so maybe the problem was somewhere there in the assets.

If it will return, I'll study it more. But thanks, if you will have any clue, what I could do wrong I would appreciate your hint.

EgonOlsen

...not sure what happened there. Make sure to call build() before clone(). Maybe that fixes it.

Darai

Hmm... it is back, and I was so happy yesterday.
So to be sure, the correct order is:

Object3D original = new Object3D();

world.addObject(original);
original.build(false);

Object3D[] copies = new Object3D[5]();
for(c:copies){
c = original.cloneObject();
world.addObject(c);
c.build(false);
}

The original, does it have to be added to the world even though I will never use it in the world?
The clones, do I have to build them even though the original is already built?

kingston

Hi, I know it's been so long, but how were you able to solve this problem?
"Error: Couldn't build() ..."

I have the same "ArrayIndexOutOfBoundsException:"

EgonOlsen

Can you post the code snippet that fails?