31
Support / Re: loading .bsp or quake level
« on: November 21, 2011, 10:37:12 am »
I have one more clarifcation.If I convert quake 3 map to .3ds format, do I have to remove lightmap every time so that it will be loaded in Android ?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
private Object3D drawCrabs(){
Object3D crab = null;
Resources res = getResources();
crab = Loader.loadSerializedObject(res.openRawResource(R.raw.crab));
Bitmap image = BitmapFactory.decodeResource(res, R.drawable.crab1);
Texture texture = new Texture(image);
TextureManager.getInstance().addTexture("crabone", texture);
crab.setTexture("crabone");
crab.compile(true, false);
crab.strip();
crab.build();
return crab;
}
Render animation public void onDrawFrame(GL10 gl) {
if (touchTurn != 0) {
touchTurn = 0;
yDelta += 0.02f;
}
if (touchTurnUp != 0) {
touchTurnUp = 0;
}
// animating the model to attack
crab1.animate(anim, crab1.getAnimationSequence().getSequence("attack"));
anim += 0.1f;
if (anim >= 1)
anim = 0;
// end of animation
fb.clear(back);
world.renderScene(fb);
world.draw(fb);
fb.display();
if (System.currentTimeMillis() - time >= 1000) {
// Logger.log(fps + "fps");
fps = 0;
time = System.currentTimeMillis();
}
fps++;
}
What I am missing here.
private InputStream loadZip() {
ZipInputStream is = null;
Resources res = getResources();
is = new ZipInputStream(res.openRawResource(R.raw.crab));
try {
is.getNextEntry();
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println(" the value of is "+is);
return is;
}
I serialized my model and later zipped it manually as you suggested after removing many of the unwanted animation sequences by just leaving one animation and called strip() method on it with the following code. At this time, the size of the model was reduced considerably less.But when I loaded the model with the above method,I am getting the following exception. private void serializeTheModel(String modelName) {
System.out.println("[inside serializeTheModel methiod]") ;
Object3D model = Loader.loadMD2(modelName, 0.1f);
Animation animation = model.getAnimationSequence();
animation.remove(animation.getSequence("stand"));
animation.remove(animation.getSequence("attack"));
animation.remove(animation.getSequence("pain"));
animation.remove(animation.getSequence("jump"));
animation.remove(animation.getSequence("flip"));
animation.remove(animation.getSequence("salute"));
animation.remove(animation.getSequence("taunt"));
animation.remove(animation.getSequence("wave"));
animation.remove(animation.getSequence("point"));
animation.remove(animation.getSequence("crstnd"));
animation.remove(animation.getSequence("crwalk"));
animation.remove(animation.getSequence("crattack"));
animation.remove(animation.getSequence("crpain"));
animation.remove(animation.getSequence("crdeath"));
animation.remove(animation.getSequence("death"));
model.getAnimationSequence().strip();
model.build();
DeSerializer serializer = new DeSerializer();
try {
FileOutputStream fos = new FileOutputStream("crab.ser");
serializer.serialize(model, fos, true);
fos.close();
} catch (IOException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("[ serializing the model is over......]") ;
}
11-03 11:40:14.390: ERROR/AndroidRuntime(566): java.lang.RuntimeException: [ 1320300614202 ] - ERROR: Can't deserialize object: nullWhat I am missing ?
11-03 11:40:14.390: ERROR/AndroidRuntime(566): at com.threed.jpct.Logger.log(Logger.java:189)
11-03 11:40:14.390: ERROR/AndroidRuntime(566): at com.threed.jpct.DeSerializer.deserialize(DeSerializer.java:210)
11-03 11:40:14.390: ERROR/AndroidRuntime(566): at com.threed.jpct.Loader.loadSerializedObject(Loader.java:97)
11-03 11:40:14.390: ERROR/AndroidRuntime(566): at org.me.home.GameActivity$MyRenderer.drawCrabs(GameActivity.java:405)
11-03 11:40:14.390: ERROR/AndroidRuntime(566): at org.me.home.GameActivity$MyRenderer.onSurfaceChanged(GameActivity.java:281)
11-03 11:40:14.390: ERROR/AndroidRuntime(566): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1325)
11-03 11:40:14.390: ERROR/AndroidRuntime(566): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
private void serializeTheModel(String modelName) {
System.out.println("[inside serializeTheModel methiod]") ;
Object3D model = Loader.loadMD2(modelName, 0.1f);
model.getAnimationSequence().strip();
model.compile();
model.build();
DeSerializer serializer = new DeSerializer();
try {
serializer.serialize(model, new FileOutputStream("crab.ser"), true);
} catch (IOException ex) {
java.util.logging.Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("[ serializing the model is over......]") ;
}
After this method execution, the size of the model becomes extremely large.It comes around 2 MB!. I do not have any idea why this is happening.