I am using some characters from here http://www.cubixstudio.com/Products.htm
I use the standard code to convert the 3ds model and then play key frames. But during an animation such as running or jumping, when the leg is rotated to the extreme, it will be rotated to the other extreme(+180 degrees).
I tried many models and animation they have this same problem. Is this a problem related to the importer?
can someone help?
thanks
code on importing model
public static Node loadModel(String file) throws IOException{
Node model = null;
FormatConverter formatConverter;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String format = file.substring(file.lastIndexOf(".") + 1, file.length());
String binary = file.substring(0, file.lastIndexOf(".") + 1) + "jbin";
URL url = null;//TestModel.class.getClassLoader().getResource(binary);
// verify the presence of the jbin model
if(url==null) {
url = TestModel.class.getClassLoader().getResource(file);
System.err.println("file is "+file);
System.err.println("URL is "+url);
format = file.substring(file.lastIndexOf(".") + 1, file.length());
// evaluate all compatable model formats
if(format.equalsIgnoreCase("3ds")) {
formatConverter = new MaxToJme();
} else if(format.equalsIgnoreCase("md2")) {
formatConverter = new Md2ToJme();
} else if(format.equalsIgnoreCase("md3")) {
formatConverter = new Md3ToJme();
} else if(format.equalsIgnoreCase("ms3d")) {
formatConverter = new MilkToJme();
} else if(format.equalsIgnoreCase("ase")) {
formatConverter = new AseToJme();
} else if(format.equalsIgnoreCase("obj")) {
formatConverter = new ObjToJme();
} else {
logger.log(Level.WARNING, "Problem loading model: Unrecognised file type");
return model;
}
try {
// load in model
formatConverter.setProperty("mtllib", url);
formatConverter.convert(url.openStream(), byteArrayOutputStream);
model = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
// output model in jbin format
BinaryExporter.getInstance().save((Savable) model, new File(TestModel.class.getClassLoader().getResource(binary).toURI()));
} catch(Exception e) {
logger.log(Level.WARNING, "Problem loading model: " + e.getMessage());
}
} else {
try {
// load model in jbin format
model = (Node) BinaryImporter.getInstance().load(url.openStream());
} catch(IOException e) {
logger.log(Level.WARNING, "Problem loading model: " + e.getMessage());
}
}
return model;
}
code on animation
public void playAnimation(){
JointController controller = (JointController) model.getController(0);
//animation
int startFrame=0, endFrame=5;
// int startFrame=381, endFrame=428;
//int startFrame =153, endFrame=171;
controller.setSpeed(.5f);
controller.setRotation(2, 4.3f, 1, 1, 1);
//controller.setNewAnimationTimes(startFrame, endFrame);
controller.setTimes(startFrame, endFrame);
controller.setRepeatType(Controller.RT_CYCLE);
controller.setActive(true);
}