Strange behavior

Started by Nemetz, July 18, 2011, 03:22:59 PM

Previous topic - Next topic

Nemetz

Hi!
Found some strange thing. Whean i'm creating new object with, for example size = 32 by exmaple , which Mr. Egon gave me, like this

upperLeftFront = new SimpleVector(-size, -size, -size);
upperRightFront = new SimpleVector(size, -size, -size);

and adding texture:

this.addTriangle(upperLeftBack, 0, 0, upperLeftFront, 0, 1,
upperRightBack, 1, 0, textureId, seq);
this.addTriangle(upperRightBack, 1, 0, upperLeftFront, 0, 1,
upperRightFront, 1, 1, textureId, seq);

Texture size  is 128x128
Everything is ok, looks pretty.
But whan i'm trying to make a small box (size smaler than 12), i have an exception:

[ 1310995133186 ] - ERROR: Polygon index out of range - object is too large!
I/jPCT-AE ( 4560): java.lang.RuntimeException: [ 1310995133186 ] - ERROR: Polygon index out of range - object is too large!
I/jPCT-AE ( 4560): at com.threed.jpct.Logger.log(Logger.java:189)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5858)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5616)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5611)
I/jPCT-AE ( 4560): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5580)
I/jPCT-AE ( 4560): at com.Box.addTextureDown(Box.java:127)

Do you have any suggestions?
UPD:
Trying texture size 64*54, and 32*32, and still have the same result.

EgonOlsen

This has nothing to do with texture size and the wording of the exception actually says it all. You are trying to add too many polygons to a smaller object. Maybe you are adding more triangles than you think you do or something like this. It might help to post the full source code if it's not too large.

Nemetz

#2
There are just code from your message here......
http://www.jpct.net/forum2/index.php/topic,393.msg2093.html#msg2093
UPD. So i'm adding 2 polygons for each side, that means what i have 12 polygons in object.
Mybe this is an issue? If quantity of polygons less than object size, engine throws exception?

Nemetz

Thats true...
For example, if you have a box with 12 polygons, you can't make it size less than 12.
If I can't make one object smaller, then i can make all world object bigger))))

EgonOlsen

I don't get your problem...you can't create a box with less than 12 polygons (2 polygons for each side, 6 sides => 12 polygon). Maybe you are mixing size and polygon count here somehow?

Nemetz

here you can see this
http://www.jpct.net/forum2/index.php/topic,2148.msg16077.html#msg16077
if we made, size of box less than 12, for example 10, we've got error:

E/AndroidRuntime( 9493): FATAL EXCEPTION: GLThread 10
E/AndroidRuntime( 9493): java.lang.ArrayIndexOutOfBoundsException
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5394)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5170)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5165)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5134)
E/AndroidRuntime( 9493): at com.threed.jpct.example.TextureBox.addTextureDown(TextureBox.java:99)
E/AndroidRuntime( 9493): at com.threed.jpct.example.TextureBox.<init>(TextureBox.java:67)
E/AndroidRuntime( 9493): at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:217)
E/AndroidRuntime( 9493): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1356)
E/AndroidRuntime( 9493): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)


But if size will be 15, everything works fine.

EgonOlsen

I don't get your problem here...you have six calls to addTextureXXX and each one adds two triangles? Why are you wondering that six*two=twelve triangles don't fit into an object that has only 10 triangles? What remains strange is, that jPCT-AE doesn't notice this but bombs out with an ArrayIndexOutOfBoundsException...it should actually give you a better error message than that. I'll fix that.

EgonOlsen

Quote from: Nemetz on August 02, 2011, 11:16:28 AM
here you can see this
http://www.jpct.net/forum2/index.php/topic,2148.msg16077.html#msg16077
if we made, size of box less than 12, for example 10, we've got error:

E/AndroidRuntime( 9493): FATAL EXCEPTION: GLThread 10
E/AndroidRuntime( 9493): java.lang.ArrayIndexOutOfBoundsException
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5394)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5170)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5165)
E/AndroidRuntime( 9493): at com.threed.jpct.Object3D.addTriangle(Object3D.java:5134)
E/AndroidRuntime( 9493): at com.threed.jpct.example.TextureBox.addTextureDown(TextureBox.java:99)
E/AndroidRuntime( 9493): at com.threed.jpct.example.TextureBox.<init>(TextureBox.java:67)
E/AndroidRuntime( 9493): at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:217)
E/AndroidRuntime( 9493): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1356)
E/AndroidRuntime( 9493): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)



Which version is that? The line numbers are totally off and the ArrayIndexOutOfBoundsException will be catched in the latter versions of AE anyway. Is that some really old version, that you are using here? This stack trace also doesn't match the one that you've posted above, which gives the proper line numbers and error message... ???

Nemetz

I use last version, 1.23.
The code from this simple example i posted in this message
http://www.jpct.net/forum2/index.php/topic,2148.msg16077.html#msg16077

EgonOlsen

Quote from: Nemetz on August 02, 2011, 05:18:32 PM
I use last version, 1.23.
I'm not sure if 1.23 still behaves that way (1.22 does for sure)...anyway, your first stack trace has to be from 1.24 alpha then...otherwise, this doesn't make any sense. So at least 1.24 gives you the proper error message, which is totally correct. You can't create a 6 sided box with only 10 triangles no matter what you do. I still can't see the problem here...