keyframe animation

Started by ciropan, February 05, 2012, 01:49:50 PM

Previous topic - Next topic

ciropan

I'm trying animation keyframe, but my object stand still.
Why?

                               thing = loadModel(R.raw.omino_1, 1f);

Animation anim = new Animation(4);
anim.createSubSequence("idle");
                anim.addKeyFrame(thing.getMesh());
       
anim.createSubSequence("walk");
anim.addKeyFrame(loadModel(R.raw.omino_1, 1f).getMesh());
anim.addKeyFrame(loadModel(R.raw.omino_2, 1f).getMesh());
anim.addKeyFrame(loadModel(R.raw.omino_3, 1f).getMesh());

thing.setAnimationSequence(anim);
world.addObject(thing);
...




private Object3D loadModel(int objId, float scale) {
Resources res = getResources();
        Object3D[] model = Loader.load3DS(res.openRawResource(objId), 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.rotateMesh();
            temp.setRotationMatrix(new Matrix());
            o3d = Object3D.mergeObjects(o3d, temp);
            o3d.build();
        }
        return o3d;
    }



public void doAnim() {
        ind += 0.1f;
        if (ind >= 1f) {
                ind = 0;
        }
       
        Logger.log("frame: "+ind);
        thing.animate(ind, thing.getAnimationSequence().getSequence("walk"));        
}

What is the problem?
Can you help me, please?

EgonOlsen

That way, you are calling build() before the animation has been assigned, which makes jPCT-AE compile the object into static mode. Try to replace the call to o3d.build(); int the loadModel-method by o3d.calcNormals(); o3d.calcBoundingBox(); and call build() only on the final object after setting the animation. I guess i should add a log message to handle this case better.