Author Topic: 3D Animation with 3DS from Blender  (Read 2042 times)

Offline loongy

  • byte
  • *
  • Posts: 8
    • View Profile
3D Animation with 3DS from Blender
« on: March 15, 2011, 03:51:25 pm »
I have 3ds model exported from blender and when i put it into jpct ae no errors came out but it didnt animate? i followed code to the word from other posts and cannot figure out what is wrong?
i then decided to export each animation individually and ended up with several different 3ds models and when i used their meshes as animation keyframes and applied all the key frames etc still no result? the object just sits there without animating.
Code: [Select]
animationArray.add(Loader.load3DS(getAssets().open("test1.3ds"), 15.0f)[0]);
animationArray.add(Loader.load3DS(getAssets().open("test2.3ds"), 15.0f)[0]);
animationArray.add(Loader.load3DS(getAssets().open("test3.3ds"), 15.0f)[0]);
man = new WorldObject(animationArray.get(1));
man.setOrigin(new SimpleVector(0, 0, 0));
man.build();
man.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
man.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);

Animation anim = new Animation(animationArray.size());
anim.createSubSequence("walk");
for (int i = 0; i < animationArray.size(); i++) {
System.out.println("adding keyframe number " + i);
Object3D obj = animationArray.get(i);
obj.build();
Mesh msh = obj.getMesh().cloneMesh(true);
msh.strip();
anim.addKeyFrame(msh);
}
man.setAnimationSequence(anim);
man.build();

and then the animation called every frame. this is inside and extended class of Object3D (thus the this.animate(ind, an));

Code: [Select]
public void runAnimation() {
try{
            ind += 0.02f;
            if (ind > 1f) {
                ind -= 1f;
            }
            this.animate(ind, an);
}catch(Exception e){
System.err.println("MoveTest::checkAnimate3DS() " + e.getMessage());
e.printStackTrace();
}
}

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: 3D Animation with 3DS from Blender
« Reply #1 on: March 15, 2011, 08:39:25 pm »
You are calling build() twice on your objects. The first call happens before assigning the animation, so the object is put into static mode. The second can't change that anymore. Try to remove the first call and see if that helps.

Offline loongy

  • byte
  • *
  • Posts: 8
    • View Profile
Re: 3D Animation with 3DS from Blender
« Reply #2 on: March 16, 2011, 07:12:21 am »
This doesn't work. LogCat gives me:

RunTimeException - ERROR: The sizes of the Animations Meshes (16) and the object's Mesh (8) don't match!

what does this mean? and why is it happening?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: 3D Animation with 3DS from Blender
« Reply #3 on: March 16, 2011, 07:55:36 am »
It means that they don't match. Try to do a call to Loader.setVertexOptimization(false); before loading the meshes. If it still doesn't work, your meshes are not using an equal vertex count.