Author Topic: Strange behavior  (Read 5789 times)

Offline Nemetz

  • int
  • **
  • Posts: 53
    • View Profile
Strange behavior
« on: July 18, 2011, 03:22:59 pm »
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
Code: [Select]
upperLeftFront = new SimpleVector(-size, -size, -size);
upperRightFront = new SimpleVector(size, -size, -size);
and adding texture:
Code: [Select]
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:
Code: [Select]
[ 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.
« Last Edit: July 18, 2011, 03:24:45 pm by Nemetz »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Strange behavior
« Reply #1 on: July 18, 2011, 04:21:15 pm »
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.

Offline Nemetz

  • int
  • **
  • Posts: 53
    • View Profile
Re: Strange behavior
« Reply #2 on: July 18, 2011, 09:59:53 pm »
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?
« Last Edit: July 19, 2011, 11:00:03 am by Nemetz »

Offline Nemetz

  • int
  • **
  • Posts: 53
    • View Profile
Re: Strange behavior
« Reply #3 on: July 19, 2011, 03:46:46 pm »
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))))

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Strange behavior
« Reply #4 on: July 19, 2011, 04:37:52 pm »
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?

Offline Nemetz

  • int
  • **
  • Posts: 53
    • View Profile
Re: Strange behavior
« Reply #5 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:
Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Strange behavior
« Reply #6 on: August 02, 2011, 04:22:22 pm »
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Strange behavior
« Reply #7 on: August 02, 2011, 04:27:11 pm »
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:
Code: [Select]
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... ???

Offline Nemetz

  • int
  • **
  • Posts: 53
    • View Profile
Re: Strange behavior
« Reply #8 on: August 02, 2011, 05:18:32 pm »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Strange behavior
« Reply #9 on: August 02, 2011, 05:29:49 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...