Author Topic: Error Loading .obj file  (Read 1788 times)

Offline elmatos

  • byte
  • *
  • Posts: 2
    • View Profile
Error Loading .obj file
« on: September 30, 2013, 08:29:51 pm »
Hi there!

First of all i would like to thank the developer(s) for this awesome tool!

Now getting to the point of this post:

I was trying to load an .obj file like the title says but i'm having the following exception thrown:

09-30 18:03:48.067: E/AndroidRuntime(2378): FATAL EXCEPTION: GLThread 5227
09-30 18:03:48.067: E/AndroidRuntime(2378): java.lang.ArrayIndexOutOfBoundsException: length=8392; index=8392
09-30 18:03:48.067: E/AndroidRuntime(2378):    at com.threed.jpct.Loader.loadOBJ(Loader.java:386)
09-30 18:03:48.067: E/AndroidRuntime(2378):    at com.threed.jpct.Loader.loadOBJ(Loader.java:229)
09-30 18:03:48.067: E/AndroidRuntime(2378):    at com.project.MyClass$MyRenderer.onSurfaceChanged(object_3D.java:177)
09-30 18:03:48.067: E/AndroidRuntime(2378):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1512)
09-30 18:03:48.067: E/AndroidRuntime(2378):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

I used the example class hello world and only changed some code on the onSurfaceChanged (see bellow)

if (fb != null) {
   fb.dispose();
}
fb = new FrameBuffer(gl, w, h);

if (master == null) {

   world = new World();
   world.setAmbientLight(20, 20, 20);

   sun = new Light(world);
   sun.setIntensity(250, 250, 250);

   // Create a texture
   Texture texture = new Texture(BitmapHelper.rescale(BitmapHelper.convert(getResources().getDrawable(R.drawable.objectTexture)), 64, 64));
   TextureManager.getInstance().addTexture("texture", texture);


   Object3D[] s = Loader.loadOBJ(getResources().openRawResource(R.raw.object3d), null, 1);  <<--Error occurs where
   Object3D = Object3D.mergeAll(s);
   Object3D.setTexture("texture");
   Object3D.strip();
   Object3D.build();
   
   world.addObject(Object3D);


   Camera cam = world.getCamera();

(unchanged content...)


The .obj file can de downloaded in the following link:
http://www35.zippyshare.com/v/24809331/file.html

I would be much appreciated for some help in this matter  :)


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Error Loading .obj file
« Reply #1 on: September 30, 2013, 08:53:55 pm »
That was a bug in the loader. It expected the obj-files to have at least some kind of header. Should be fixed in this jar: jpct.de/download/beta/jpct_ae.jar

Offline elmatos

  • byte
  • *
  • Posts: 2
    • View Profile
Re: Error Loading .obj file
« Reply #2 on: October 01, 2013, 03:12:36 pm »
It's working now! ;D

Thank you very much for the help  ;)