Need help for .3ds animation


1) I made a keyframe-animator model on 3dsmax and export to .3ds format, i follow the downloaded source code examples "renderer.loader", but i find that my model only loop once and then stop....

2) for milkshpae model, if i make it too big, it cannot be loaded, the console said : "unknown source";

can anyone help?




public class Maxzhulei extends SimpleGame {
URL modelpath = null;
public static void main(String[] args)
    {  Maxzhulei app = new Maxzhulei(); if (args.length > 0) { app.setModelToLoad(args[0]); }
        app.setDialogBehaviour(AbstractGame.FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG);
        app.start(); }
private void setModelToLoad(String string)
        { try { modelpath = (new File(string)).toURL();} catch (MalformedURLException e){ }    }

protected void simpleInitGame() {
        if (modelpath == null) {modelpath = Maxzhulei.class.getClassLoader().getResource("feiji.3DS");}
        try {
            MaxToJme change = new MaxToJme();
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            change.convert(new BufferedInputStream(model.openStream()), output);
            Node jiedian = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(output.toByteArray()));
            jiedian.setLocalScale(0.1f);
            if (jiedian.getChild(0).getControllers().size() != 0) jiedian.getChild(0).getController(0).setSpeed(20);
            Quaternion rotate = new Quaternion();
            rotate.fromAngleAxis(FastMath.PI / 2, new Vector3f(-1, 0, 0));
            rootNode.setLocalRotation(rotate);
            jiedian.setLocalTranslation(new Vector3f(0,0,0));
            rootNode.attachChild(jiedian); }
            catch (IOException e) {System.out.println("Damn exceptions:" + e);e.printStackTrace();}
    }

}}

I know that this post is almost 2 years old, but I came across the same problem and fix hopefully it will save you 20 minutes of debugging…





After printing out the 3ds model structure i found out that the controller for my 3ds animation is on the top level.

The example loader TestMaxJmeWrite.java assumes the controller is in the first child, but that is not the case for my model, and probably other 3ds models.



TestMaxJmeWrite.java code:





if (r1.getChild(0).getControllers().size() != 0)

                r1.getChild(0).getController(0).setSpeed(20);







corrected code





Node r1 = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));

ArrayList<Controller> al = r1.getControllers();

if (al.size()>0){

Controller c = al.get(0);

System.out.println("controller:"+c);

c.setRepeatType(Controller.RT_CYCLE);

c.setSpeed(1f);

c.setMinTime(0f);

c.setMaxTime(14f);

c.setActive(true);

}







printout example:



head:TDS Scene (com.jme.scene.Node)controllers:1

controller:com.jme.animation.SpatialTransformer@9a8a68