Author Topic: Loading textures in serialized objects  (Read 1437 times)

Offline thiamant

  • byte
  • *
  • Posts: 19
    • View Profile
Loading textures in serialized objects
« on: September 09, 2010, 07:10:29 pm »
Hello, I'm new to jPCT and trying to load an OBJ model in JPCT-AE.

The problem is that I'm serializing the object like this:
Code: [Select]
TextureManager texMan = TextureManager.getInstance();
DeSerializer des = new DeSerializer();

char c = File.separatorChar;
File dir = new File("raw");
String[] files = dir.list();
for (int i = 0; i < files.length; i++) {
String name = files[i];
if (name.toLowerCase().endsWith(".jpg")) {
texMan.addTexture(name, new Texture("raw" + c + name));
}
}

Object3D[] objs = Loader.loadOBJ("raw/raw.obj","raw/raw.mtl", 1);
OutputStream os = new FileOutputStream("raw.ser");

objs[0].build();
des.serialize(objs[0], os, true);
But when loading the model in Android with Loader.loadSerializedObject(...) the textures won't appear.
My question: How does this exactly work? Does this call look for textures in any specific directory?
Do I have to load them once again in Android manually?
Where should I put them? I have lots of them in the model.

Thanks in advance.
« Last Edit: September 09, 2010, 07:12:51 pm by thiamant »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Loading textures in serialized objects
« Reply #1 on: September 10, 2010, 07:56:40 am »
The names will be serialized but not the textures. So on Android, you load the textures and add them with the same names that they had in desktop jPCT to the TextureManager. Then load the serialized data. The textures will then automatically getting assigned.

Offline thiamant

  • byte
  • *
  • Posts: 19
    • View Profile
Re: Loading textures in serialized objects
« Reply #2 on: September 10, 2010, 01:01:51 pm »
Thanks I understand now. The problem is that the texture sizes are not a power of 2 (it's raising an error). Is there any easy way of resizing them without any side effects in the model?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: Loading textures in serialized objects
« Reply #3 on: September 10, 2010, 01:09:28 pm »
Just resize them. The texture coordinates are normalized anyway. It won't have any side effects except for the reduced resolution.