Author Topic: Can't load serialized object Android  (Read 1150 times)

Offline cocojack

  • byte
  • *
  • Posts: 15
    • View Profile
Can't load serialized object Android
« on: March 24, 2013, 11:49:27 am »
Hello, im working on some tutorials to get into JPCT-AE.
At the moment i'm trying to load a texture of an airplane into my android app.

I've downloaded a model of an airplane and serialized it with jBrush v0.3.


my code:
Code: [Select]
         ZipInputStream serStream = new ZipInputStream(masterContext.getResources().openRawResource(R.raw.dassault_mirage));
         try{serStream.getNextEntry();}
         catch(IOException e)
         {throw new RuntimeException(e);}
         airplane = Loader.loadSerializedObject(serStream);
         airplane.setTexture("texture");

on start, this code part gets a runtime exception:
java.lang.RuntimeException: [ 1364121233198 ] - ERROR: Can't deserialize object: length=256; regionStart=-1; regionLength=257

at
Code: [Select]
airplane = Loader.loadSerializedObject(serStream);
i dont know what I did wrong this time :(
greezs coco

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Can't load serialized object Android
« Reply #1 on: March 24, 2013, 12:02:43 pm »
Looks like as if something is wrong with your input stream. Can you post the full stack trace?

Offline cocojack

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Can't load serialized object Android
« Reply #2 on: March 24, 2013, 12:12:15 pm »
Attributes
Code: [Select]
private Object3D airplane = null;


Code: [Select]
@Override
public void onSurfaceChanged(GL10 gl, int width, int height)
{
Logger.log("onSurfaceChanged");
Logger.setLogLevel(Logger.LL_DEBUG);

if (fb != null) fb.dispose();

fb = new FrameBuffer(gl, width, height);

if (masterActivity == null)
{
world = new World();
world.setAmbientLight(120, 120, 120);
sun = new Light(world);
sun.setIntensity(250, 250, 250);
SimpleVector sv = new SimpleVector();
sv.set(0,-100,-100);
sun.setPosition(sv);

Texture texture = new Texture( BitmapHelper.rescale(BitmapHelper.convert(masterContext.getResources().getDrawable(R.drawable.dassault_mirage)), 64, 64));
TextureManager.getInstance().addTexture("texture", texture);

ZipInputStream serStream = new ZipInputStream(masterContext.getResources().openRawResource(R.raw.dassault_mirage));
Logger.log("loaded serStream");
try{
serStream.getNextEntry();
Logger.log("loaded next entry");
}
catch(IOException e)
{
Logger.log("io-Exeption");
throw new RuntimeException(e);
}
Logger.log("loading serialized obj");
airplane = Loader.loadSerializedObject(serStream);
Logger.log("setting texture");
airplane.setTexture("texture");



world.addObject(airplane);
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(airplane.getTransformedCenter());
sv.set(airplane.getTransformedCenter());
sv.y -= 100;
sv.z -= 100;
sun.setPosition(sv);
MemoryHelper.compact();
}
}

content of serStream :
Code: [Select]
serStream ZipInputStream  (id=830038260848)
buf (id=830038130704)
charBuf (id=830038138048)
closed false
crc CRC32  (id=830038130184)
currentEntry null
entriesEnd false
entryIn 0
eof false
hasDD false
hdrBuf (id=830038131240)
in PushbackInputStream  (id=830038087616)
inf Inflater  (id=830038131336)
inRead 0
lastRead 0
len 0
nameBuf (id=830038136280)
nativeEndBufSize 0
debug output:
Code: [Select]
03-24 12:53:29.515: E/AndroidRuntime(8727): FATAL EXCEPTION: GLThread 12093
03-24 12:53:29.515: E/AndroidRuntime(8727): java.lang.RuntimeException: [ 1364126009517 ] - ERROR: Can't deserialize object: length=256; regionStart=-1; regionLength=257
03-24 12:53:29.515: E/AndroidRuntime(8727): at com.threed.jpct.Logger.log(Logger.java:189)
03-24 12:53:29.515: E/AndroidRuntime(8727): at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:244)
03-24 12:53:29.515: E/AndroidRuntime(8727): at com.threed.jpct.Loader.loadSerializedObject(Loader.java:93)
03-24 12:53:29.515: E/AndroidRuntime(8727): at com.securitywarefare.engin.MyRenderer.onSurfaceChanged(MyRenderer.java:101)
03-24 12:53:29.515: E/AndroidRuntime(8727): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
03-24 12:53:29.515: E/AndroidRuntime(8727): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


could it be that the files doesnt load correctly to my android device?
« Last Edit: March 24, 2013, 12:55:10 pm by cocojack »

Offline cocojack

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Can't load serialized object Android
« Reply #3 on: March 24, 2013, 01:07:09 pm »
It works now, may anyone can explain what is the difference between those:

terrain = Loader.loadSerializedObject(masterContext.getResources().openRawResource(R.raw.dassault_mirage));
terrain.setTexture("texture");

forgot to mention that I use this document to get in jpct-ae : http://www.jpct.net/forum2/index.php?topic=2667.0