Hi,
I am trying to write an Object3D to a file to be loaded later by another program. The serializing of the Object3D to a file works fine, but when I try to read the file and cast it into an Object3D it gives me this error
C:\ObjectEditor>java Viewer h
Exception in thread "main" java.io.WriteAbortedException: writing aborted; java.
io.NotSerializableException: com.threed.jpct.PolygonManager
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:19
45)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at Viewer.main(Viewer.java:21)
There is more to the error output, but what it is saying is that the PolygonManger is not serializable. I know this, but how do you serialize an Object3D without its PolygonManger? The object that I am trying to serialize has gotten getPolygonManger() called on it. When the Object has not had getPolygonManager() called on it, the Object3D serializes fine.
I tried out creating another Object3D and setting this object's mesh to the object that am I trying to serialize. Then I serialize the new object3d, and it obviously works fine, but all my textures naturally disappear. I don't want that. So, how do I serialize an object to a file with all its texture information?
thanks
jman
Hi
To get it to work you would have to either set it to null again or make the poly manager transient in object3d befor reading the object(when you start adding userobjects thats probably going to be the same problem)...
-or-
you could also just create a dummy world, put that object3d into it and use the xml serializer that the jpct loader offers? :)
I'll fix this in 1.16
Ok, thanks, v1.16 can't come fast enough for me! ;D
Thanks also for the suggestions Jonas. I did try out writing the world to xml, and it does work fine. Maybe I'll use that until 1.16, or I will work on another part of my project until then.
Jman
This beta should fix the problem: http://www.jpct.net/download/beta/jpctapi116pre6.zip (http://www.jpct.net/download/beta/jpctapi116pre6.zip)
speeking of serialization, still no serialVersionUID's in jPCT classes ^^
Oh yes, that one... ;D I can add it, but i promise you what will happen next: I will forget to increase the value after doing a change that requires it...
no problem, it is definetely better than serialVersionUID's changing automatically without a need ;)
Hey thanks, for the putting up a beta. I tried it out and it works. The polygonmanager serializes fine.
Jman