Animation issues

Hello there ,



When i load an animation ( for example a walk character ) , i have 2 states on my animationcontrol :

_null <== my character has his arms streched

_walking <== my character is walking in a infinite loop



when i code a walking by using the walking animation , my character is trying in everyloop to come back to the null statement , so the point is that the animation is ugly , how do we code a loop animation by telling to not use the null statement ?



Thank you .



P.S : I used the code in helloanimation.

is the _null animation another animation or is there a stand position at the beginning of your walking animation?

i made the stand animation ‘null’ statement doesn’t correspond to any animation , just to the mesh when there is no animation on it ,



but on my code there is everytime an animation , if the character does nothing it plays the " stand" animation , that’s why i feel strange that the null statement is coming there.

I don’t get it,

could you post code and a video of what’s happening?

i’m sorry nehon i’m not at home for now ,



but i think the character is trying to play his null statement and his animation that’s a lot of strange lol ,



maybe i did a mistake somewhere into the code i’ll check it out.



After reading again my post i may have done a very bad explanation of my problem so i’ll try to schematize it :



_ I have a ‘stand animation’ which is calling for when my character does nothing

_ i have a 'walk animation ’

_ i have a ’ run animation ’



when i walk , the begining of the loop is not what i was except to have , first the character is at his " null " statement (arms streched ) then he walks and the loop is okay after that.



When i release the walk button , the character goes again by his " null " statement and then his “stand animation”.



Is there a way in the code to call the “null” statement like the animation and make a test with it ?

I found something that may help for you to answer ,

it seems that the blend option is causing the problem i’m telling you , if i put the blend to 0 then no problem at all but i loose the interpolation between a walk and a stand , it seems that when the blend option is > 0 the null statement is coming just for a few moment then disappering …



edit : I’m now sure that blend is the issue , i just replaced from helloanimation oto by my model and where oto doesn’t have the issue my character has , i guess oto null statement has the same position than oto_stand tell me if i’m wrong.

Is there a way to blend 2 animations without considering the null statement ?



For now i have Walk animation / Stand animation , by activate blending the schema is like this :





Push button walk : WALK

Release button Walk : Null statement for 0.5 sec ( the second parameter of my setanim ) => Stand animation.



I would like to have :



Push button walk : WALK

Release Button walk : Blending for 0.5 sec on Stand Animation.





Thank you

well…blendAnim(“Stand”, 0.5f);

It does not work?

Could you post some code?

if by blendAnim you mean channel.setanim then no it doesn’t work ,





here is the code i do all my tests

thanks.



[java]





import com.jme3.animation.AnimChannel;

import com.jme3.animation.AnimControl;

import com.jme3.animation.AnimEventListener;

import com.jme3.animation.LoopMode;

import com.jme3.app.SimpleApplication;

import com.jme3.input.KeyInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;

import com.jme3.light.DirectionalLight;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Node;



/** Sample 7 - how to load an OgreXML model and play an animation,

  • using channels, a controller, and an AnimEventListener. /

    public class HelloAnimation extends SimpleApplication

    implements AnimEventListener {



    Node player;

    private AnimChannel channel;

    private AnimControl control;



    public static void main(String[] args) {

    HelloAnimation app = new HelloAnimation();

    app.start();

    }



    @Override

    public void simpleInitApp() {

    viewPort.setBackgroundColor(ColorRGBA.LightGray);

    initKeys();



    /
    * Add a light source so we can see the model /

    DirectionalLight dl = new DirectionalLight();

    dl.setDirection(new Vector3f(-0.1f, -1f, -1).normalizeLocal());

    rootNode.addLight(dl);



    /
    * Load a model that contains animation /

    player = (Node) assetManager.loadModel("Models/Personnages/Youko/Youko.mesh.xml");

    player.setLocalScale(0.5f);

    rootNode.attachChild(player);



    /
    * Create a controller and channels. /

    control = player.getControl(AnimControl.class);

    control.addListener(this);

    channel = control.createChannel();

    channel.setAnim("youko_stand");

    }



    /
    * Use this listener to trigger something after an animation is done. /

    public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {

    if (animName.equals("youko_marche")) {

    /
    * After "youko_marche", reset to "stand". /

    channel.setAnim("youko_stand", 0.50f);

    channel.setLoopMode(LoopMode.Loop);

    channel.setSpeed(1f);

    }

    }



    /
    * Use this listener to trigger something between two animations. /

    public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {

    // unused

    }



    /
    * Custom Keybindings: Mapping a named action to a key input. /

    private void initKeys() {

    inputManager.addMapping("youko_marche", new KeyTrigger(KeyInput.KEY_SPACE));

    inputManager.addListener(actionListener, "youko_marche");

    }



    /
    * Definining the named action that can be triggered by key inputs. /

    private ActionListener actionListener = new ActionListener() {

    public void onAction(String name, boolean keyPressed, float tpf) {

    if (name.equals("youko_marche") && !keyPressed) {

    if (!channel.getAnimationName().equals("youko_marche")) {

    /
    * Play the "youko_marche" animation! */

    channel.setAnim("youko_marche", 0f);

    channel.setLoopMode(LoopMode.Loop);

    }

    }

    }

    };



    }

    [/java]

ok, well looking at your code, the behavior you describe is normal

the onAnimCycleDone method is called each time an anim CYCLE is finished.

So as it is, the stand anim is called each time you end a walk cycle.

get rid of the onAnimCycleDone method and use this :

[java]

private ActionListener actionListener = new ActionListener() {

public void onAction(String name, boolean keyPressed, float tpf) {

if (name.equals("youko_marche") && keyPressed) {

if (!channel.getAnimationName().equals("youko_marche")) {

/** Play the "youko_marche" animation! /

channel.setAnim("youko_marche", 0f);

channel.setLoopMode(LoopMode.Loop);

}

}

if (name.equals("youko_marche") && !keyPressed) {

if (channel.getAnimationName().equals("youko_marche")) {

/
* After "youko_marche", reset to "stand". */

channel.setAnim("youko_stand", 0.50f);

channel.setLoopMode(LoopMode.Loop);

channel.setSpeed(1f);

}

}

}

[/java]

I should have start by that ==> http://img121.imageshack.us/i/youkopb.png/ this is the issue i get , as you can see the blending has the " null " statement into it.



Thank you for the code but it still doesn’t work and have a strange behavior

ok could you upload your mesh.xml and skeleton.xml file please?

I bumped into your issue too.

The problem occur when changing an animation in the onAnimCycleDone method, and that the previous animation is in Loop mode.

I’m on it.

Perhaps we can make a test case for this? I don’t want the fix to be a “hack” if you get what I mean.

No I don’t what do you mean?

@danath actually there is no bug.

what you call the “null pose” is the first frame of your animation. What happen, is that you blend from an anim set in loopMode, but your anim is not made to be seamlessly looped, so when you blend, the “blended from anim” is looped.

Set the loop mode to “dontLoop” just before changing the animation like this and it should work fine

[java]

public void onAnimCycleDone(AnimControl control, AnimChannel channel, String animName) {

if (animName.equals(“youko_marche”)) {

/** After “youko_marche”, reset to “stand”. */

channel.setLoopMode(LoopMode.DontLoop);

channel.setAnim(“youko_stand”, 0.50f);

channel.setLoopMode(LoopMode.Loop);

channel.setSpeed(1f);

}

}

[/java]