ClassCastException when attempting to create KeyframeController from Controller

Hello all,



  I'm having a problem with using the KeyframeController class to animate 3ds files.  I am able to load the example character.3ds and run.ms3d files, but cannot convert the Controller to KeyframeController. 


KeyframeController kc = new KeyframeController();
kc = (KeyframeController)units[0].node.getChild(0).getController(0);



When I try the above code I get:
java.lang.ClassCastException: com.jmex.model.animation.JointController
        at Lesson8.initGame(Lesson8.java:336)

I am able to simply use the Controller class, but would like to utilize some of the functions that the keyframecontroller extends.  Is there any workaround for this?

Looks like it doesn't use key frame animation, it's a com.jmex.model.animation.JointController not a KeyFrameController.

I have the same problem as stated above, i have a ms3d model, and it has some animation keyframes, so if the loader returns JointController, anything i could do to convert it to KeyframeController? or changing the controller maybe?

gr33nl1nk said:

I have the same problem as stated above, i have a ms3d model, and it has some animation keyframes, so if the loader returns JointController, anything i could do to convert it to KeyframeController? or changing the controller maybe?

No. That would require more work than you probably think, because JointController implements skeletal animation, whereas KeyframeController is for morph target animation.
You could certainly convert from skeletal to morph target animation programmatically (but not vice versa!) but would loose all of the benefits of skeletal animation, and re-code a lot of stuff your artist's modeling application does at the click of a button.
So in that case you should probably have imported the model in a morphing format (like md2) to begin with - most artists release models that come in a skeletal animated format like ms3d in a morph target animation format such as md2 as well.

thanks, now i understand that each model format has its own controller, now i need to know which controller controls which format, but i think i'd rather post this on another topic…

what exactly do you want to do? i mean, the keyframe controller can do nothing but animate from frame a to frame b. the jointcontroller can do the same.

im just still not sure which format i want to use, because my artist using autodesk maya 8, and he had trouble exporting from maya format to ms3d,. . so, im considering other format that can be exported from maya, either collada or md5, but in another thread (see: http://www.jmonkeyengine.com/jmeforum/index.php?topic=7251.msg57700#msg57700), neakor said that i have no choice other than md5, what do you use for your game, hamster?

so far, 3ds (found & selfmade), md2 (found) and ms3d (found & selfmade) models. we are quite happy with milkshape (very good for its price) as an editor and converter. while other formats do offer more possibilites, we don't care about that at all :wink: because anything we want to do can be done with the good old joints (until now)