Author Topic: Serialize Object3D on android  (Read 2764 times)

Offline luftiguru

  • byte
  • *
  • Posts: 8
    • View Profile
Serialize Object3D on android
« on: September 12, 2013, 07:12:58 pm »
Hello,
I'm working on an android app, where I load .obj meshes loaded via network. This works quite good so far.
Nevertheless, I'd like to cache known meshes on the device to speed up my application.

I tried writing the Object3D[] array which builds the object to a file using java.io.ObjectOutputStream. When I load this file using java.io.ObjectInputStream, I get my Object3D[] back. When I try to add the contained Object3D's to a new created World, I get the error: "ERROR: Object with name 'bottle_part0' already exists!"

Am I doing something obviously wrong?
Is there a chance for a serialization support of Object3D in jPCT-AE?  :)
Thank you!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Serialize Object3D on android
« Reply #1 on: September 12, 2013, 08:50:26 pm »
I don't see how can be caused by adding an object to the world. It can only happen if you call Object3D.setName(<String>); The issue here is, that you seem to serialize the object after adding it to a world. That's not a good idea. You should rather serialize it before adding it to a world.

Offline luftiguru

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Serialize Object3D on android
« Reply #2 on: September 13, 2013, 04:58:11 pm »
Thanks for the hint, I didn't knew I had to serialize Object3D before adding it to my World.

Now, I serialize a clone of my Object3D (using cloneObject() ) right after loading the original .obj file.
I can then add this cached object to a new world where it is rendered.

Nevertheless, now a new problem occurs:
When using the "normally" loaded (via .obj file) Object3D, highlights and shades look fine.
But when I use the cached Object3D, no highlights and shades are rendered. The color of my (monochromatic) texture is simply applied to the whole Object3D. I use exactly the same setup of the world, lights and objects as before.

Do I have to obey a specific order like before? Any hints, what else might be the problem?
Thanks!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Serialize Object3D on android
« Reply #3 on: September 13, 2013, 08:18:24 pm »
I think that we had the same problem lately in another thread, i just can't find it ATM. Try this version: http://jpct.de/download/beta/jpct_ae.jar. It should actually fix the issue.

Offline luftiguru

  • byte
  • *
  • Posts: 8
    • View Profile
Re: Serialize Object3D on android
« Reply #4 on: September 14, 2013, 01:36:10 pm »
Works like a charm!  :)
Thanks for your always fast and helpful answers. Keep up the good work!