Serialize Object3D on android

Started by luftiguru, September 12, 2013, 07:12:58 PM

Previous topic - Next topic

luftiguru

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!

EgonOlsen

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.

luftiguru

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!

EgonOlsen

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.

luftiguru

Works like a charm!  :)
Thanks for your always fast and helpful answers. Keep up the good work!