Manage frames of an imported model

how can i manage frames form an imported model?

i imported a model ( MD2 ) that has animation inside it. i want to manage that animations frames by my keyboard keys ( like all games ).

i have same experience in 2D games that save frames in several arrays ( for example 0-10 walking , 10-20 running and …) and switch among this frames with keyboard and mouse input. how can i do that here? :stuck_out_tongue: ( sorry for my english )

no body knows? i thought it is one the basic issues in game programming!

Um, not many people use the MD2 importer any more, including me.  I use OgreXML for my animated models and for that there are separate animations that can be stored for a model.



Code for this would look like:

animControl.setAnimation("Walk");
animControl.setAnimation("Run");



I would suggest switching to this system because there are current developers active for this importer.  You'll probably have to dig into the code for the MD2 importer to actually use it how you want.

At the very beginning I also started with md2. It is quite a time ago. Maybe you can post your model and I could have a look.



But usually it is always the same. You load the model. If everything went right, you will have an GeometricController connected to your Node/Spatial (have a look at Node.getControllers()) As md2 uses VertexAnimations it should be a KeyframeController connected to the node or one of the node's children. Have a look in debugger. Once you get the KeyframeController you can set the frames with the method KeyframeController.setNewAnimationTimes(start,end)



Have a look in the jmetest-package: jmetest.renderer.loader.TestMd2JmeWrite



This example should tell you everything you need.



PS:  Where do you get the model from? Did you export it, or was it already in md2-format?

Good luck

@ SomethingNew : thx mate, i will test that :wink:

@ ttrocha: thx for your help. in that example , the writer know the time for each cycle for example "kc.setNewAnimationTimes(39,44);". he know 33 -> 44 is Running cycle but if i didn't make the model and i didn't know the cycle's time , how can i manage animation?

"SomethingNew" said that OgreXML has separate animations and it is really amazing. is he right about MD2? expired?

Well, you have to know the frame-intervals for the animations…sometimes to the md2-file there is an txt-file included that tells you about the animation-frames. Another ooption might be to import it into blender or milkshape in order to get the times.



md2-import is not maintained anymore but that does not mean it is not working. OgreXML-Importer has seperate actions that can be set like somethingnew told. Nevertheless you first need a model with a skeleton that have all this actions. A conversion of your md2-model to ogre wouldn't be possible as yours don't have a skeleton which is needed for Ogre.

thx for your complete information  :smiley:

now let's go to make Warcraf IV :stuck_out_tongue: XD