Tutorial with bones?

Can you tell me where in jmetest can i found som example of managing the bones?

The idea would be something like TestMilkJmeWrite but with some input.

ie: while i press the left arrow the man is running, and when i release it he is not :wink:



What modification should i do to TestMilkJmeWrite to test it?



Thanks

What you have to do is fined the controller and Enable/Disable it.

"Badmi" wrote:
What you have to do is fined the controller and Enable/Disable it.

Maybe you can specify a little more with some code ://

what happens in jME is that spatial have controllers associated with them to "control" that spatial (lack of a better word really)



The control can be anything from literally moving the spatial from one place to another, playing the next animation, to stopping the animation.



In your case i believe, stopping the animation is what you want to do:




private Node playerNode;
private Controller playerC;

public void update(float time) {
  input.update(time);
 
  // check if the turn left button is not pressed and disable the controller
  if (KeyBindingManager.getKeyBindingManager().isValidCommand("Turn Left", true) == false) {
    playerC.setActive(false);
  } else {
    playerC.setActive(true);
    playerC.setMinTime(0);
    playerC.setMaxTime(39);
  }
}

public void initGame() {
  JmeBinaryReader jbr = new JmeBinaryReader();
  playerNode = jbr.loadBinary(someURL);
  playerC = playerNode.getChild(0).getController(0);
}



Thats basically it.

DP

Unless you are asking if you can manipulate a joint (bone) manually, for rag doll type effects. If so, not yet.

"DarkProphet" wrote:
what happens in jME is that spatial have controllers associated with them to "control" that spatial (lack of a better word really)

The control can be anything from literally moving the spatial from one place to another, playing the next animation, to stopping the animation.

In your case i believe, stopping the animation is what you want to do:



private Node playerNode;
private Controller playerC;

public void update(float time) {
  input.update(time);
 
  // check if the turn left button is not pressed and disable the controller
  if (KeyBindingManager.getKeyBindingManager().isValidCommand("Turn Left", true) == false) {
    playerC.setActive(false);
  } else {
    playerC.setActive(true);
    playerC.setMinTime(0);
    playerC.setMaxTime(39);
  }
}

public void initGame() {
  JmeBinaryReader jbr = new JmeBinaryReader();
  playerNode = jbr.loadBinary(someURL);
  playerC = playerNode.getChild(0).getController(0);
}



Thats basically it.

DP

My model is done in milk. When i did it, i grouped the faces to do the mapping process. When i do the node.getChild(x) it brings to me the some group of model and i am not interested in them (what means a "controller" asigned to a child??)

In milkshape, seted up some keyframes using bones and all i want to do i to say "while x key is pressed, go from keyframe 1 to keyframe 2", or go to frame 1 to frame x (i should know what frames are the keyframes).

Hi… me again ://

Have found another thing… (dont forget to answer the last thing :slight_smile: )



After setting the bones animation in milkshape, the movement in milkshape is right, but when i load this mesh with jme (with no controllers or anything else), the animation that plays by defult by jme, shows some bones with diferent movement tha the milkshape anim mode (look one of the arms).



here is the mesh if somebody want to try it in milkshape and later in jme.



http://nicolasl.sion.com/man3.ms3d

It’s fixed if you update the JmeBinaryWriter and JmeBinaryReader from the CVS. I fixed it a few days ago.

"Cep21" wrote:
It's fixed if you update the JmeBinaryWriter and JmeBinaryReader from the CVS. I fixed it a few days ago.

fixed! The model is now moving correctly :D

Now is left the explanation of the keyframes ://
Debugging i checked every geometricalControllers of every child (the groups in the model in milkshape) and all of them are empty! Could this be? What i am doing wrong?

It’s there somewhere, I promise :slight_smile: No ghost controllers hehe. Try looking at either the root’s controller, or the root’s first child’s controller. You would control it by setting minTime and maxTime for the keyframes. So to go from 10 to 20, set minTime(10) and maxTime(20)

"Cep21" wrote:
It's there somewhere, I promise :) No ghost controllers hehe. Try looking at either the root's controller, or the root's first child's controller. You would control it by setting minTime and maxTime for the keyframes. So to go from 10 to 20, set minTime(10) and maxTime(20)

Yeah! It was in the first node XD
Thanks again!
"Cep21" wrote:
It's there somewhere, I promise :) No ghost controllers hehe. Try looking at either the root's controller, or the root's first child's controller. You would control it by setting minTime and maxTime for the keyframes. So to go from 10 to 20, set minTime(10) and maxTime(20)

Cep and dark: tried with the mintime and maxtime in various ways and with many values but i get always the same result. While the key is pressed, the animations its full played.
In my model i want to play from frame 0 to 10 and set minTime(10) and maxTime(20) in the simpleupdate (using the exactly example you both said) but no min or max time is setted ://

that means you haven’t obtained the right controller to control the animation. I think…



Keep searching for that controller…its there somewhere I promise.



The best way to know where it is is to convert the jME to XML and read the XML for KeyFrameSomethingRatherSomething…



Cep, can you confirm this?



DP

Hi… I converted to xml using MilkToJme and later BinaryToXML. MilkToJme converts its ok. But BinaryToXML throws me "Unable to convert:java.io.IOException: Unknown data type:16".



Surely the model is ok because i can see it in the jme engine (and also milksphape dont cry when i open it). Could be a BinaryToXML problem?



Wel… by now, i will look for the controllers using the debuggers and watches. If the model is usefull for someone, here it is:



http://nicolasl.sion.com/man3.ms3d

Me again… i done a simple ball model, with a simple bone inside, and when saving the .jme to xml says the same problem.

I know what’s causing both problems. In 2 hours, you’ll have a fix. :wink:

"Cep21" wrote:
I know what's causing both problems. In 2 hours, you'll have a fix. ;)

My god! "You live for this stuff!" :D :D

I tried best I could to test it out. It works for the model you gave me at least.



Update JmeBinaryReader / JmeBinaryWriter / BinaryToXML / JointController / and MilkToJme





After you load your model, use


JointController jc=MilkToJme.findController(model);



to get your controller. (no more guess work where it is).

Then, don't use setMin/max time to change the animation. Instead, use

JointController.setTimes(int,int)


The first frame is the frame 1, and the last frame is well the last frame. Set that to the frames you want to transform between. It should work for your model. Let me know if you find ants.

PS: For example, use setTimes(6,10) to make him just do his "lower to upper" animation. Support for RT_CYCLE and RT_CLAMP is coming soon.

Cep… thanks again. It works great.

Now this is just something that can be improved:



Testing the modification, i saw that setTimes() must be defined outside simpleUpdate(), or else the animation keeps playing in the first frame.



Something like doesnt work like it is expected:



if key_right pressed

setActive(true)

setTimes(1,10) //keeps playing frame 1

if key_left pressed

setActive(true)

setTimes(11,20) //keeps playing frame 11



What do you think?



Ahhh… another thing i found is when i set setTimes(x,20) and x is not the first frame of the total frames, if you look carefully you can see the first frames before x playing very quickly when you call setActive the first time. The model does not run directly to the desired frame… it shows how it iterates the first frame until it reaches de x frame.

Some things i found:


protected void simpleUpdate() {
key.update();
testCont.setActive(false);
  if (KeyBindingManager.getKeyBindingManager().isValidCommand("one")) {
         if (!key1) {
            key1 = true;
            key2 = false;
            testCont.setTimes(1, 10);
         }
         testCont.setActive(true);
      }

      if (KeyBindingManager.getKeyBindingManager().isValidCommand("two")) {
         if (!key2) {
            key2 = true;
            key1 = false;
            testCont.setTimes(11, 30);
         }
         testCont.setActive(true);
      }
   }



works ok, forget the issue of the setTimes() playing the first frame.

Now when i press "one", the model starts to do one animation and when i press "two" the bones most of times do something like "reacomodate" in some funny way becoming the model totally screwed until it reaches the first frame of the animation number "two" (try the code above and will see).
I guess it has something to do with the issue of the model not going directly to the desired first frame of the wanted animation.