Reverse animation

Hi all,



Im still new to 3d and jme but i have a problem with animation.



What im trying to do is start a walk animation as i start to move  and stop it when i stop moving. ( this is the part that is working )

However when i stop the animation it jumps back instantly to its start posistion wich doesent look very good. So what i really want is for the animation to go in reverse from his current posistion ( so he would lower his leg in a normal way ).  I tryed to do this with setNewAnimationTimes(float beginTime, float endTime) but this doesent seem to work. The javadoc from this method in SpatialTransformer says the following:

Sets the new animation boundaries for this controller. This will start at newBeginTime and proceed in the direction of newEndTime (either forwards or backwards).  Backwards doesent seem to work however as he jumps back to his start posistion again.



this is part of the code i use:

float curTime = controller.getCurTime();

controller.setNewAnimationTimes(curTime, 0);

controller.setRepeatType(Controller.RT_CLAMP);





Any help is appreciated.

hi, this doesnt answer your question , but I just wanted to let you know md5reader2 (md5importer will have it soon)has a blend feature that does just what your speaking of. you can fadeIn/fadeout animations and fadeTo to go from one to another, If you cant use md5 though this doesnt help.

Sounds cool,  since I'm currently just exploring and playing around with JME  i don't really care about model format yet.

Guess i just have to find myself some MD5 models to play around with  :slight_smile:

mud2005 said:

hi, this doesnt answer your question , but I just wanted to let you know md5reader2 (md5importer will have it soon)has a blend feature that does just what your speaking of. you can fadeIn/fadeout animations and fadeTo to go from one to another, If you cant use md5 though this doesnt help.


already done. u can check out the newest version from svn.

Ok i'm using MD5Importer now and the fading looks real nice.



1 more question though.

I'm using the marine model in the tests but the problem is the walk animation keeps translating the position of the model ( and if i use wrap as repeat is it jumps back to the origin at the end of each cycle) , is it possible to make him walk in place to prevent him from jumping all over the place? Or is this model dependent ? 



Thanks

thats something should be done in the modeling stage by artists. i didnt make the model and i have no idea how to modify it either, so im sry i cant help u on that. u might wanna try to find another model.



it is indeed weird how the marine model actually moves during animation.

not necessarily weird, just more realistic from an animation point of view, let me explain, when u do the threadmill style animation the programmer constantly have test and adjust the movement code to avoid/reduce any visible sliding effects on the timing, how ever if u animate your walk loop going forward you avoid having to do these tests and the animator get full control over how the walk would look i.e. feet get planted nicely on the floor and the weight shifting from one leg to the other looks clean.



To grasp what I’m getting at download this md5 project below

CVS Info for project md5reader



in package test.MD5Test2 and add

bodyAnimator.setUpdatingLocalTransform(true);

at line 91

when u start the test press L to get some light or u might miss him :wink: the marine will continue walking into the the darkness. what that method does is update the rotation and translation every update



if u follow him you will notice how clean and correct the steps look.



@neakor their are methods in that loader that I would like to see get ported to your loader but, maybe  when I get better at coding and understand your stuff more I can add them :expressionless: :D.


that sure is a simple thing to implement, ill get it in when i have time. definitely by the end of this weekend.



and mcbeth, what kind features r u looking for? i can add them in if u do a feature request.

off the top of my head



*update rotation/translation for moving models

*attach to bone - done :slight_smile:

*model instancing - don't know if yours does that :? , please tell

*animation "listeners" - if haven't tested that yet(will explain later) but what gather from looking at the code and conversation with the author is that u can use them to easily detect a particular "time" in an animation that u may want to trigger another animation or stop it. e.g. ANIMATION_CYCLE_ENDED.



not sure the old code does this though still digging and commenting as I go along

*ability play multiple animations on different parts of the same skeleton i.e. fade in a new animation on a specified bone, and it children/parents  e.g. play a walk animation load a ("unholster" and aim a weapon animation without animation on the legs being affected.



thats what I can think of now, I'm using jme and md5reading for a school assignment/learning project, maybe when I'm done, I'll have more ideas.


mcbeth said:


To grasp what I'm getting at download this md5 project below
md5reader.cvs.sourceforge.net/cvsroot/md5reader



hmm i'm having some trouble downloading the project from cvs with eclipse
i keep getting the error "root request missing" when i enter the modulename, what is the correct modulename ?

in your cvs perspective:



host name: md5reader.cvs.sourceforge.net

repository path: /cvsroot/md5reader



when u set it up, collapse the local and chose md5reader2 for checkout

:-o i had cvsroot/md5reader  instead of /cvsroot/md5reader …  works fine now thanks.



However adding

bodyAnimator.setUpdatingLocalTransform(true);


doesent seem to prevent him from jumping back and forward, infact he doesent even listen to the repeat type  :?

i tryed to find out why he doesent listen to the updatelocaltransform and he seems to be switching it on and off when the animation cycle is ended

hold on let me compare, I use a local copy that I never kept consistent with cvs, I just assumed that there won't that many changes, um if it is caused by a cvs change, it's a damaging change :-o

ok something has definitely been changed in cvs :-o :-o :-o :-o

-added that line to cvs.

-saw your issue

-compared the test code - identical(where it matters :wink: )



made a duplicate of the test plugged it into my relatively untouched version and boom off he went.

Animation of Marine jumps back because it have been animated that way. It is not caused by MD5 Reader. You can try to modify (coding) the frames for the bone responsible for that movement. Probably it is “origin” bone but I am not sure. Simply, after loading model and animation, modify positions of that bone for each frame setting them to new Vector3f() (or equivalent code, I do not remember if they are saved as float buffers, array of vectors or something else).



Some changes to the CVS have been made to correct the several bugs with Texture Flikering and Model Shaking. Though it is possible that part of this changes affected some undocumented features (most of MD5 Reader code, as I recived it originally, was undocumented :slight_smile: ).



Does “boom off he went” refers to the test with your modification like in “boom off it went”?

I  would be glad if you can provide me a diff file created using “diff -Naur your_src_dir current_cvs_src_dir filename.diff”.

Meanwhile I will try to compare first commit source with the current one.



About a changelog file, the problem is that I always almost alone and I divide myself preparing planning documentation, development documentation, api documentation, helping other users, creating models for testing, testing and a little amount of time for coding. So as you can imagine keeping also a changelog is quite hard.

Though, even if still not completed, the future code is the one under org.md5reader2 package in the CVS. Soon I will reimplement all the old features plus many more features. mcbeth proposals are really interesting.

ok something has definitely been changed in cvs
interesting, I was going to also post saying the marine wont continue walk just cycles. I would also like to see your old code and compare it to the new if possible

the version I use  :smiley:



just copy the models from cvs into the src in eclipse



edit



click the smiley :smiley: :smiley: 8)



edit 2



it’s an eclipse project

hehe  :smiley: awesome, the way the cam is aimed by the time you find the marine hes outta there. thanks mcbeth

cool 8)



@mud2005 some of the blending stuff is still a mystery to me can share a bit of what you may know about it I'm trying to figure out a way to apply multi animations on one skeleton i.e. fade new animations onto a specific parts



the md5 format has a tag called animatedComponents that assign values the bones based on the animations keyed to it, that might have been one way to go but derton the author of the blender script never added support for that and simply adds a "flat" value to each bone so all are treated as animated.

and useful old post


chaosdeathfish said:

VERSION 0.2 RELEASE

OK, I've finally had time to do some work on this again, and you're all going to hate me - I've refactored and changed the API quite a lot. The old code is still available at http://www.chaosdeathfish.com/jme/jme-anim/v0.1/ if you're still using it. The new code is available at the original location:

http://www.chaosdeathfish.com/jme/jme-anim

The main new features are:

    [*:58732]Animation blending - self explanatory, allows animations to be blended together and cleanly faded in and out.
    [*:58732]Translation/rotation updating - if this is turned on using setUpdatingLocalTransform( true ) the the local translation and rotation will be updated each update.
    [*:58732]Milkshape3D binary importer - Does what it says on the tin :)
    [*:58732]Easy animation subsets - use animation.subset( name, firstFrame, lastFrame ) where firstFrame is inclusive and lastFrame is exclusive. This creates a new animation from a subset of an existing animation, which is useful for model formats which only have one animation track (e.g. Milkshape3D)
    [/list:u]
    The main change to the API is a complete refactoring of most of the code :) This was mainly to separate out the skeletal/non-skeletal code to avoid hundreds of if checks to see if the object is skeletal. Now most of the core classes (Model, Animation, Animator, AnimationController, KeyFrame, ModelInstance) have a skeletal version which extends the non-skeletal version.

    The other change that'll impact you is a change in the model reading code - MD5MeshReader now extends model.file.ModelReader, and has an empty constructor - the input stream needs to be passed into the readModel method instead.

    The main change that you'll need to make to existing code is:

      [*:58732]Change new ModelInstance( model ) to model.createInstance()
      [*:58732]Change instance.addController( new AnimationController( instance ) ) to instance.addAnimationController()
      [*:58732]Change new AnimationAnimator( animation ) to AnimationUtils.createAnimator( animation )
      [/list:u]
      And also change the way models are loaded. Look at the new version of MD5Test if you need an example.

      The javadocs are still a bit sparse, I'll get around to sorting them out one of these days. Sorry about that :(

      Currently the next thing on my TODO list is to get rid of the vertex and texture arrays used in ModelTriMesh and just use the Buffer versions instead to cut down on the memory usage (that's half the reason for the architecture I've chosen anyway).

      Next I'll probably be back to getting bump shaders and suchlike to work, and hopefully get .mtr scripts working.

      Sorry for the massive post. Any feedback is very much appreciated, as always. In particular, any bugs or features that I may've removed and not realised would be very useful!