loadSerializedObject problem

Started by jumong, September 16, 2010, 04:21:31 AM

Previous topic - Next topic

jumong

I try to load big md2 file
The file size is 665Kbyte.

So I did like follow
    -In desktop JPCT
        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
        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

EgonOlsen

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.

jumong

#2
Like this?

Object3D obj = Loader.loadMD2(new ZipInputStream(con.getResources().openRawResource(R.raw.obj)), 1);

obj is Zip file.

Otherwise, Can you explain in detail.
help

EgonOlsen

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.

jumong

#4
but error still occur. Is there any idea?
Is there another method that load big serialized md2 file?

EgonOlsen

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.