jPCT-AE - a 3d engine for Android > Support

Can't deserialize object Error

(1/2) > >>

MSL:
Hi,

I am trying to load a serialized file but I am getting Can't deserialize object error.

Code used to load serialized object:
----------------------------------------------------------------------------------------------------------------------------
ZipInputStream zis = new ZipInputStream(mContext.getResources().openRawResource(R.raw.teapot));
try {
   zis.getNextEntry();
} catch (IOException e) {throw new RuntimeException(e);}
cube = Loader.loadSerializedObject(zis);
-----------------------------------------------------------------------------------------------------------------------------
Error:
11-15 15:56:08.478: E/Trace(11279): error opening trace file: No such file or directory (2)
11-15 15:56:08.828: E/AndroidRuntime(11279): FATAL EXCEPTION: GLThread 6828
11-15 15:56:08.828: E/AndroidRuntime(11279): java.lang.RuntimeException: [ 1384511168803 ] - ERROR: Can't deserialize object: length=256; regionStart=-1; regionLength=257
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.Logger.log(Logger.java:189)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:244)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.Loader.loadSerializedObject(Loader.java:93)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:204)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
11-15 15:56:08.828: E/AndroidRuntime(11279):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1266)

-----------------------------------------------------------------------------------------------------------------------------

If I use following code to load:
cube = Loader.loadSerializedObject(mContext.getResources().openRawResource(R.raw.teapot));

Error:
11-15 15:53:34.603: E/Trace(11063): error opening trace file: No such file or directory (2)
11-15 15:53:34.945: E/AndroidRuntime(11063): FATAL EXCEPTION: GLThread 6816
11-15 15:53:34.945: E/AndroidRuntime(11063): java.lang.RuntimeException: [ 1384511014916 ] - ERROR: Can't deserialize object: [ 1384511014915 ] - ERROR: Unsupported version: 6
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.Logger.log(Logger.java:189)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:244)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.Loader.loadSerializedObject(Loader.java:93)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at com.threed.jpct.example.HelloWorld$MyRenderer.onSurfaceChanged(HelloWorld.java:204)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1531)
11-15 15:53:34.945: E/AndroidRuntime(11063):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1266)

----------------------------------------------------------------------------------------------------------------------------

Code used to serialize an object in Desktop JPCT (object is basic Teapot):
----------------------------------------------------------------------------------------------------------------------------
        box = loadModel("models/"+thingName+".obj","models/"+thingName+".mtl", 100);
        try {
            new DeSerializer().serialize(box, new FileOutputStream("models/teapot.ser"), true);
         } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }

   private Object3D loadModel(String filename, String filemtl, float scale) throws IOException {
         InputStream streamModel = getResources().getAssets().open(filename);
         InputStream streamMtl = getResources().getAssets().open(filemtl);

           Object3D[] model = Loader.loadOBJ(streamModel, stearmMtl, scale);
           Object3D o3d = new Object3D(0);
           Object3D temp = null;
           for (int i = 0; i < model.length; i++) {
               temp = model;
               temp.setCenter(SimpleVector.ORIGIN);
               temp.rotateX((float)( -.5*Math.PI));
               temp.rotateMesh();
               temp.setRotationMatrix(new Matrix());
               o3d = Object3D.mergeObjects(o3d, temp);
               o3d.build();
           }
           return o3d;
    }
--------------------------------------------------------------------------------------------------------------------

Any help would be appreciated.

EgonOlsen:
The first error happens because you are loading a file as zip, which hasn't been zipped at all. This doesn't happen automatically. If you want to load a zipped file, you'll have to zip it yourself first.

The second error is actually pretty much self explanatory:


--- Quote ---ERROR: Unsupported version: 6

--- End quote ---

That means that your jPCT-AE is older than the desktop version that you are using. The latest desktop version writes files in version 6, but your jPCT-AE version can't load them. Try to download the latest version an try again.

MSL:
Thanks for your quick response.
I have downloaded both Desktop and Mobile version from the download page... http://www.jpct.net/download.html
I have even tried with the Beta version of JPCT-AE available here
http://jpct.de/download/beta/jpct_ae.jar

Regarding manually Zipping the file loading, I had tried that also. In that case also I got Unsupported version 6.

Can you guide me where can I download the right version if not from above links?

EgonOlsen:
These are the right versions, but maybe your project setup is wrong so that it uses a another, older version. Print out Config.getVersion() and see what you get.

MSL:
Thanks again.. I will check that..

In mean time I got an old version of jpct (1.23) which i used to create a serialized file and it is working like a charm... thanks for your pointer ..  :)

I have one more query. I have evaluated Rajawali 3D engine also. Compared to it the loading time is blazing fast. (4 sec vs 30 sec). However, I noticed one thing. The file size of serialized object is very high. I will give a comparison below:
File Type: obj
File Size: 8.48 MB

Serialized file Size:
JPCT - 12.12 MB
JPCT (Zip) - 2.2 MB

Rajawali - 2.45 MB
Rajawali (Zip) - 1.8 MB

There is not much difference in the Zipped files(0.4 MB) but the difference in serialized formats is very high(~10 MB). Also I was of the assumption that Serialization will reduce the file size (compared to obj). Can you give me some pointers or details on the serialization?

In my case the models will be streamed from server. Typically the models will be of ~10 to 15 MB (obj). I am very much worried about the streaming time because of file size. Can you give any suggestion as to which will be the best way to handle such cases?

p.s: One more interesting thing I noticed was on reopening of the app(after closing the app), Rajawali again takes ~20 sec, but JPCT renders immediately  :o ... It would be very helpful if you an put some light on how JPCT is achieving this....

Thanking you once again ...

Navigation

[0] Message Index

[#] Next page

Go to full version