jPCT-AE - a 3d engine for Android => Support => Topic started by: cocojack on March 24, 2013, 11:49:27 am

Title: Can't load serialized object Android
Post by: cocojack 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 (http://"http://thefree3dmodels.com/stuff/aircraft/dassault_mirage_v/15-1-0-3262") 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));
         catch(IOException e)
         {throw new RuntimeException(e);}
         airplane = Loader.loadSerializedObject(serStream);

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

Code: [Select]
airplane = Loader.loadSerializedObject(serStream);
i dont know what I did wrong this time :(
greezs coco
Title: Re: Can't load serialized object Android
Post by: EgonOlsen 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?
Title: Re: Can't load serialized object Android
Post by: cocojack on March 24, 2013, 12:12:15 pm
Code: [Select]
private Object3D airplane = null;

Code: [Select]
public void onSurfaceChanged(GL10 gl, int width, int height)

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();

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");
Logger.log("loaded next entry");
catch(IOException e)
throw new RuntimeException(e);
Logger.log("loading serialized obj");
airplane = Loader.loadSerializedObject(serStream);
Logger.log("setting texture");

Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
sv.y -= 100;
sv.z -= 100;

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?
Title: Re: Can't load serialized object Android
Post by: cocojack 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));

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