Persistence and an eye for detail saves the day!!!
In the last post I mentioned of 2 implementations I tried. Still not sure why the first one doesn't work, but I managed to solve the second one.
Besides o3d.calcNormals(), o3d.calcBoundingBox() is also needed! Was in one of the posts, but not specially highlighted, hence the oversight.
Now my code snippet looks like this
And loadModel looks like this
Hope this helps someone!
In the last post I mentioned of 2 implementations I tried. Still not sure why the first one doesn't work, but I managed to solve the second one.
Besides o3d.calcNormals(), o3d.calcBoundingBox() is also needed! Was in one of the posts, but not specially highlighted, hence the oversight.
Now my code snippet looks like this
Code Select
bear = loadModel(res.openRawResource(R.raw.bearb), 1);
Animation anim = new Animation(4);
anim.createSubSequence("walk");
anim.addKeyFrame(loadModel(res.openRawResource(R.raw.bear_walk1b), 1).getMesh());
anim.addKeyFrame(loadModel(res.openRawResource(R.raw.bear_walk2b), 1).getMesh());
anim.addKeyFrame(loadModel(res.openRawResource(R.raw.bear_walk3b), 1).getMesh());
anim.addKeyFrame(loadModel(res.openRawResource(R.raw.bear_walk4b), 1).getMesh());
bear.setAnimationSequence(anim);
bear.build();
world.addObject(bear);
And loadModel looks like this
Code Select
private Object3D loadModel(InputStream filename, float scale) {
Loader.setVertexOptimization(false);
Object3D[] model = Loader.load3DS(filename, scale);
Object3D o3d = new Object3D(0);
Object3D temp = null;
for (int i = 0; i < model.length; i++) {
temp = model[i];
temp.setCenter(SimpleVector.ORIGIN);
temp.rotateX((float)( -.5*Math.PI));
temp.rotateY((float)(-Math.PI));
temp.rotateMesh();
temp.setRotationMatrix(new Matrix());
o3d = Object3D.mergeObjects(o3d, temp);
o3d.calcBoundingBox();
o3d.calcNormals();
}
return o3d;
}
Hope this helps someone!