Author Topic: loadSerializedObject problem  (Read 2608 times)

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
loadSerializedObject problem
« on: September 16, 2010, 04:21:31 am »
I try to load big md2 file
The file size is 665Kbyte.

So I did like follow
     -In desktop JPCT
        
Code: [Select]
InputStream fis = new FileInputStream("obj.md2");
OutputStream fos = new FileOutputStream("obj.ser");
DeSerializer de = new DeSerializer();
Object3D myobj = Loader.loadMD2(fis, 1);
myobj.build();
de.serialize(myobj, fos, true);
     -In jpct-ae
        
Code: [Select]
Object3D obj = Loader.loadSerializedObject(con.getResources().openRawResource(R.raw.obj));but android attached error.

09-16 10:28:11.699: WARN/System.err(448):     java.io.IOException
09-16 10:28:11.699: WARN/System.err(448):     at android.content.res.AssetManager.readAsset(Native Method)
09-16 10:28:11.709: WARN/System.err(448):     at android.content.res.AssetManager.access$700(AssetManager.java:36)
09-16 10:28:11.718: WARN/System.err(448):     at android.content.res.AssetManager$AssetInputStream.read(AssetManager.java:574)
09-16 10:28:11.718: WARN/System.err(448):     at com.threed.jpct.DeSerializer.read(DeSerializer.java:421)
09-16 10:28:11.729: WARN/System.err(448):     at com.threed.jpct.DeSerializer.readInt(DeSerializer.java:404)
09-16 10:28:11.729: WARN/System.err(448):     at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:29)
09-16 10:28:11.739: WARN/System.err(448):     at com.threed.jpct.Loader.loadSerializedObject(Loader.java:97)
09-16 10:28:11.739: WARN/System.err(448):     at com.threed.jpct.example.MainActivity$MyRenderer.onSurfaceChanged(MainActivity.java:289)
09-16 10:28:11.749: WARN/System.err(448):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1325)
09-16 10:28:11.749: WARN/System.err(448):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
09-16 10:29:55.998: ERROR/AndroidRuntime(448): FATAL EXCEPTION: GLThread 8
09-16 10:29:55.998: ERROR/AndroidRuntime(448): java.lang.RuntimeException: [ 1284604091761 ] - ERROR: Can't deserialize object: null
09-16 10:29:55.998: ERROR/AndroidRuntime(448):     at com.threed.jpct.Logger.log(Logger.java:159)
09-16 10:29:55.998: ERROR/AndroidRuntime(448):     at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:188)
09-16 10:29:55.998: ERROR/AndroidRuntime(448):     at com.threed.jpct.Loader.loadSerializedObject(Loader.java:97)
09-16 10:29:55.998: ERROR/AndroidRuntime(448):  at com.threed.jpct.example.MainActivity$MyRenderer.onSurfaceChanged(MainActivity.java:289)
09-16 10:29:55.998: ERROR/AndroidRuntime(448):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1325)
09-16 10:29:55.998: ERROR/AndroidRuntime(448):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)



What am I doing wrong?
help
« Last Edit: September 16, 2010, 04:30:49 am by jumong »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: loadSerializedObject problem
« Reply #1 on: September 16, 2010, 08:39:10 am »
It's obviously unable to read anything from that file. Didn't you got a message in the log that tells you that uncompressed raw resources may not exceed 1mb in size?
Try to zip it and load it via a zipped inputstream you at least rename it to .zip or .mp3 so that Android thinks its compressed.

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
Re: loadSerializedObject problem
« Reply #2 on: September 16, 2010, 09:12:35 am »
Like this?

Code: [Select]
Object3D obj = Loader.loadMD2(new ZipInputStream(con.getResources().openRawResource(R.raw.obj)), 1);
obj is Zip file.

Otherwise, Can you explain in detail.
help
« Last Edit: September 16, 2010, 09:14:28 am by jumong »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: loadSerializedObject problem
« Reply #3 on: September 16, 2010, 10:22:50 am »
Yes, like that. And i'm typing on the phone right now and for the next 10 days..i can't explain anything in detail right now.

Offline jumong

  • byte
  • *
  • Posts: 19
    • View Profile
Re: loadSerializedObject problem
« Reply #4 on: September 16, 2010, 10:28:47 am »
but error still occur. Is there any idea?
Is there another method that load big serialized md2 file?
« Last Edit: September 16, 2010, 10:44:18 am by jumong »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: loadSerializedObject problem
« Reply #5 on: September 16, 2010, 12:02:23 pm »
That is the right way to do it. It fails the first time it accesses your file to read the version number, so this is not a problem with the approach itself but with your file or your apk or whatever.