Model Animation

Hey,

  I am having a major problem with model animation, i have only a few days to get this done before deadline so any help will be much appreciated. My model animation moves around but when i want it to prefrom an action, ie. set the keyframe it doesnt do anything. My model is an MS3D model, does anyone know wahts the best way to do this?



Thanks

What is the basic way for doing this, I have the bot moving in my general direction by using spatal.lookAt() and just increment and decrement the x and z coordinates, just how can i set the animation to walk and run etc. i have it all animateded using the milkshape 3d apllication, can anybody give me a basic idea how to do this? It doesnt have to be code, just a explaination even how to do it, what im using so far is


    ((JointController)fighter.getController(0)).setTimes(28,78);          



Am I on the right track or completely of the ball, Im getting a bit panicy at the moment,  :( :cry:

Thanks

look at the test class jmetest.renderer.TestImposterNode



find the lines


((KeyframeController) freakmd2.getChild(0).getController(0)).setSpeed(10);
((KeyframeController) freakmd2.getChild(0).getController(0)).setRepeatType(Controller.RT_WRAP);

Mucker, your solution should work just fine - have you tried copying and modifying TestMilkJmeWrite to see if that works for you, and work your way finding your problem from there? MilkToJme autoamtically sets the repeat type RT_WRAP, so that shouldn't be the problem (unless you changed it, obviously!)

Sorry Hevee, but i dont really understand you, is TestMilkJmeWrite a class of some sort because i cant find it in the doc, and also for the other method you mention should i have it in the method i use to loading the MS3d model which is given below



   



public  Node loadModel() {

         

         //FormatConverter milktojme = new MilkToJme();

                      MilkToJme milktojme = new MilkToJme();//the converter

         //Node node = null; //Where to dump mesh.

         ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();

         //milktojme.setProperty("texdir","Game/character/zombie/");//For loading the raw file

         

//          File Path for the model (dump file in toplevel of classpath)

         

         URL url = Bot.class.getClassLoader().getResource("character/zombie/zombie05.MS3D");

         

               

         try {

            milktojme.convert(url.openStream(), bytearrayoutputstream);

         

         } catch(Exception err)  {

             System.out.println("Could not open Model file: "+err);

         }

         try {

         

                      BinaryImporter binaryImporter = new BinaryImporter();

             ByteArrayInputStream in=new ByteArrayInputStream(bytearrayoutputstream.toByteArray());

         

             //importer returns a Loadable, cast to TriMesh

             node = (Node)binaryImporter.load(in);

         } catch(Exception err)  {

             System.out.println("Error loading md3 model:"+err);

         }

          /////////////////////////////////////////////////////////////// new mess code

         

      node.setModelBound(new BoundingSphere());

         node.updateModelBound();



                  return node;

   }

   



Sorry bou that, i get what u mean, i have checked that class on the cvs and mine seems to be the same, what i do in my code for example …


if(getDistance() < 300 && i == 1 )
          {
             
             if(getDistance()>=200)//predpos != nextWayPoint)
             {
                ((JointController)predator.getController(0)).setModelUpdate(true);
                ((JointController)predator.getController(0)).setSpeed(0.25f);
                ((JointController)predator.getController(0)).setTimes(0,21);
                updateCycle();
                
          }
 
             else
             {
                i = 0;
                bot.fire(fighter, target, timer, terrainPage);
                ((JointController)predator.getController(0)).setTimes(120,121);
             }
          }





if the bot is greater then a distance of 200 to me, it should go through the walk animation, ie. look like its walking to me, the update cycle method is for moving the bot in my direction, and if the bot is less then 200 it will stop put its arm up and start shooting directly at me, the animation with the bot stopping and putting its arm up, works fine for me coz its only one key frame, the walk animation has got 20 keyframes and it doesnt work, i hop that makes sense :)

Am i doing this the right way, or is it more complicated? Sorry bou all the posts

mucker said:

Am i doing this the right way, or is it more complicated? Sorry bou all the posts


np, but just to remind you, you can use edit function

You seem to be on the right track, but you should really try modifying TestMilkJmeWrite to see if that works for you, it will show you if you have a problem with your model (maybe some importing trouble, the ms3d importer might not like multiple root bones, if you have those in your model) or rather with the code around the snippet you present here, such that your animation changing code is never called the way you expect. Breakpoints can help you a lot with finding out more about that.

ok, my bot is moving but it is going through all its animations, so it looks a bit stupid, i am using this code…



 

 bot.getController.setActive(true);





I tried using bot.getController.setMax(30); hoping that it will only let the bot animate to frame keyframe 30, also i dont really understand what you mean in the previous post, my code looks very similar to the code on cvs

mucker said:

i dont really understand what you mean in the previous post, my code looks very similar to the code on cvs

There's a small difference between "very similar" and "exactly the same". This difference might be your problem. Find it.

Also, don't change your code from using setTimes() to setMaxTime()/setMinTime() for now.

setMaxTime() (i assume you are referencing that with your setMax(30)?) sets the actual time in the animation to loop to, considering animation speed/fps. This is probably not what you expect.

setTimes() (mis-named, but correct javadoc) actually sets the frame positions, which may be easier to reference for you than times. It's all in the javadoc. i.e., replace

bot.getController.setMax(30)

with

bot.getController.setTimes(1,30)

.

Thanx very much, that was very helpful.



Just a quick question, how can i implement  clonig so that i can clone 10 bots with the same animation which will be spread around the terrain? I could brute force code it but that wouldnt look well

yepp, very easily (i've done it yesterday, but i didn't get the part with animation working yet  ):

create an array for your objects (meaning "bots") of the type "Spatial" and copy your "Source" in it. that's it (and assign the Array-Positions to the rootNode or whatever node that's going to be rendered)



cheers