Author Topic: Serializing Object3Ds to file  (Read 6421 times)

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Serializing Object3Ds to file
« on: February 10, 2008, 09:34:23 pm »
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

Offline Jonas

  • byte
  • *
  • Posts: 41
    • View Profile
Re: Serializing Object3Ds to file
« Reply #1 on: February 10, 2008, 10:01:22 pm »
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? :)




Simple things should be simple, complex things should be possible - Alan Kay

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Serializing Object3Ds to file
« Reply #2 on: February 10, 2008, 10:28:17 pm »
I'll fix this in 1.16

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Serializing Object3Ds to file
« Reply #3 on: February 11, 2008, 02:33:13 am »
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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Serializing Object3Ds to file
« Reply #4 on: February 11, 2008, 07:30:40 pm »

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Serializing Object3Ds to file
« Reply #5 on: February 12, 2008, 12:12:53 am »
speeking of serialization, still no serialVersionUID's in jPCT classes ^^

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Serializing Object3Ds to file
« Reply #6 on: February 12, 2008, 02:37:32 pm »
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...

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: Serializing Object3Ds to file
« Reply #7 on: February 12, 2008, 02:54:42 pm »
no problem, it is definetely better than serialVersionUID's changing automatically without a need  ;)

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Serializing Object3Ds to file
« Reply #8 on: February 13, 2008, 08:57:37 pm »
Hey thanks, for the putting up a beta. I tried it out and it works. The polygonmanager serializes fine.
Jman