I have import the model as followed:
MaxToJme C1 = new MaxToJme();
ByteArrayOutputStream BO = new ByteArrayOutputStream();
URL maxFile = Lesson1.class.getClassLoader().getResource(
"pic/1/walk.3ds");
C1.convert(new BufferedInputStream(maxFile.openStream()), BO);
model = (Node) BinaryImporter.getInstance().load(
new ByteArrayInputStream(BO.toByteArray()));
rootNode.attachChild(model);
Some animation is included in the model, but I don't know how to attach it and play it.
Someone please tell me detailed source code, much thx…
From TestBloom, which happen to have a nice 3ds model with animation:
try {
MaxToJme C1=new MaxToJme();
ByteArrayOutputStream BO=new ByteArrayOutputStream();
URL maxFile=TestMaxJmeWrite.class.getClassLoader().getResource("jmetest/data/model/char.3ds");
C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
Node r = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
r.getController(0).setRepeatType(Controller.RT_WRAP);
r.setLocalScale(.1f);
if (r.getChild(0).getControllers().size()!=0)
r.getChild(0).getController(0).setSpeed(20);
Quaternion temp=new Quaternion();
temp.fromAngleAxis(FastMath.PI/2,new Vector3f(-1,0,0));
r.setLocalRotation(temp);
r.setLocalTranslation(new Vector3f(0,3,0));
rootNode.attachChild(r);
} catch (IOException e) {
logger.log(Level.SEVERE, "Error loading max file", e);
}
I don't think 3ds contains animation. Try ogre xml or md5 format.
As far as I know 3DS supports keyframe vertex animations, but not skeletal animations.
There should be some test-cases for 3d models with animations. The engine converts the models into an own format, so the code for playing/controlling should be format-independent.
Thanks for you help! Maybe the only way to play the Skeletal animation is change 3D model tool now.