Animations in JME

Hi everyone,



recently I’ve been trying to add proper object animation importing from blender.

This feature has already been there for some time. The only problem was that only the animated object was moving - not its children.



And then I thought about some kind of SpatailAnimation class (which would work more like BoneAnimation) for Spatial objects.



I thought it won’t be a problem. Only implement the SpatialAnimation and SpatialTrack and add it to AnimControl.

But when I looked deeper into the matter I saw it is impossible with only those two classes.

I should also implement my own controller for spatial animation and my own channel for several animations.



And I thought about small refactoring of classes inside com.jme3.animation package :slight_smile:

Here are my ideas.



1. Animation class.

There should be abstract Animation class and every kind of animation (BoneAnimation, MeshAnimation, SpatialAnimation) should derive it.



2. The controller.

The AnimControl should not focus on BoneAnimation only.

Instead of member:

[java]HashMap<String, BoneAnimation> animationMap;[/java]

it should have

[java]HashMap<String, Animation> animationMap;[/java]

and be able to play every kind of animation.



3. The tracks

I can see there is an abstract Track class. Only PoseTrack extends it and BoneTrack doesn’t.

Maybe it should (as well as future SpatialTrack I hope :slight_smile: ).



4. Animation channels.

Maybe AnimChannel should be made abstract. Its current functionality moved to BoneAnimChannel.

And then other kinds of animation could implement their own channels when necessary.





The advantage of these changes is that users will be able to create their own types of animations when needed.



And please tell me how do I use MeshAnimation for example. I cannot use it with AnimControl at the moment as I see.



Tell me guys what you think about these changes. Especially Kirill. You’re the boss here :wink:

It’s possible that all those ideas cannot be implemented because of some reasons I am not aware of.

If so, please tell me :slight_smile:

If I am not very clear - also tell me.



Cheers,

Kaelthas

1 Like

Hey,

When you speak about spatial animation you mean translation, rotation and scale right, no mesh deformation?

Because, Cinematics are done for that.

Also I can understand, doing an anim in blender and then importing it to the engine would be cool, but, maybe the way to go is to load those into cinematics.

Also I made the Cinematic API alone and the design has never really been reviewed, so if you want to look into it, I’m open to suggestions, maybe some things could be changed/adapted.

Anyway I think implementing both Spatial animation and Cinematics would just be confusing for the users.



The meshDeform doesn’t work yet it’s a planned feature (pose animation), it’s just some jME2 ported classes for now, because it was working pretty well.

I didn’t know about the Cinematics.

OK I’ll look into it and if it fits to blender’s needs I’ll use this instead of creating new stuff.



But anyway I still think that animations could use some refactoring :wink:

@nehon:

1. Animation class.
There should be abstract Animation class and every kind of animation (BoneAnimation, MeshAnimation, SpatialAnimation) should derive it.

I really think he got a point ! <- In which I'm (still) developing a timeline plugin for the SDK. I'm also concerning about the animation of spartial , bone animation and other movement which has some common things, like the transition or the curve control of movement (really dont know what to call them). They all have the time range (start-end time), start-end pos/rot/scale, can have the same ease-in or ease-out attribute, and all can be blend with others!!!
To help all this kind of animation to work in the plugin, I've kind of making am abstract class called BlendAni (Animation class which can be blend). It has the methods and properties that I told you...
But I think making an abstract class for further development is necessary cause in game everything is animation ... Particles can have animation too (not just the movement, the color and sprite change). And we may need an animation format in the furture ?

@atomix: What you are doing is exactly what cinematics do, a cinematics plugin for jMP is long planned, would be cool if you could have a look into it. Theres even a cinematics plugin already I think but no code in it.



For animations one can argue that cinematics are global while animation is local but the systems should definitely share code and behave similar.

@normen:

I did read almost every lines of code in the Cinematic class :stuck_out_tongue:

After that , I start the BlendAni like a copy of that code just for my cinematic plugin cause it need some more specific technical detail have to implement to work with other library …



The official plugin still empty ?? :stuck_out_tongue: I 've wanted to contribute my plugin but…



In my code, I’ve used the library Jaret Timebars for the display and control the curve handle for animation Ease in-out and Transition for animation Blend…

I haven’t develop an opensource software before (shame on me), so I don’t know it’s good if JME SDK depends on that library …

Its fine as long as its no GNU GPL library.

It’s GNU GPL …:stuck_out_tongue:



So may be I will show some progress of my Cinematic plugin and others in another topic in the next days. Thanks for the answer normen!

OK I’ve looked into the Cinematics.

But I think it doesn’t meet the blender’s needs :frowning:



There are Position, Rotation and Scales tracks which at firs I thought would be a solution.

But unfortunately they are not.

For example PositionTrack has start and end point of the track and the object is moving between those points.

But in blender you can have different movement vector in each frame :frowning:

The same applies to rotation and scale.



Using motion track would solve only translation in object animation imported from blender.

If the object is scaled and/or rotated it won’t be visible in jme.



The only thing I could do is to implement one more track.

But I think that such functionality is more suitable for animations rather than for cinematics.

Cinematics were really made to make cutscenes, not really to make ingame animations.

We talked about it with Kirill, we should definitely implement your changes, and remove the rotation/translation/scale part of the cinematics.



This way we would have locals animations that we could use both in game and in cutscenes , and still some global anims with cinematics.

@nehon said:you speak about spatial animation you mean translation, rotation and scale right, no mesh deformation?
Because, Cinematics are done for that.

I am working on spatial animation in Cinematics. So when I tried to use e.g. PositionTrack (same goes for RotationTrack, ScaleTrack) it reads that these classes are deprecated and I should use SpatialAnimation class. When I tried to use SpatialAnimation it also reads that it's deprecated and I should use SpatialTrack, BoneTrack & MeshTrack. So:
- About Position/Rotation/ScaleTrack, does it make sense to use them or are they gonna be removed at some point (I suggest they won't)? Is this what you mean by:
@nehon said:We talked about it with Kirill, we should definitely implement your changes, and remove the rotation/translation/scale part of the cinematics.


- Is SpatialTrack the latest implementation approach for spatial animation (i.e. for translation/rotation/scale)? To my understanding it doesn't look as straight-forward as Position/Rotation/ScaleTrack (that's why I use them although I suppose I should use the latest implementation). Specifically, in the Position/Rotation/ScaleTrack implementation one specifies a duration, an end position/translation/scale and (with the start position/translation/scale being the one that is current at the start instant of the cinematic event), the in-between one is interpolated. But I cannot get a grip of how the SpatialTrack works. Is there an analogy with the Position/Rotation/ScaleTrack? Is there an example that demonstrates the use of SpatialTrack?

- Also MeshTrack doesn't seem to exist (yet?). Is it for the mesh deformation you mention above?
@yannischris said:
@nehon:

I am working on spatial animation in Cinematics. So when I tried to use e.g. PositionTrack (same goes for RotationTrack, ScaleTrack) it reads that these classes are deprecated and I should use SpatialAnimation class. When I tried to use SpatialAnimation it also reads that it's deprecated and I should use SpatialTrack, BoneTrack & MeshTrack. So:
- About Position/Rotation/ScaleTrack, does it make sense to use them or are they gonna be removed at some point (I suggest they won't)? Is this what you mean by:


- Is SpatialTrack the latest implementation approach for spatial animation (i.e. for translation/rotation/scale)? To my understanding it doesn't look as straight-forward as Position/Rotation/ScaleTrack (that's why I use them although I suppose I should use the latest implementation). Specifically, in the Position/Rotation/ScaleTrack implementation one specifies a duration, an end position/translation/scale and (with the start position/translation/scale being the one that is current at the start instant of the cinematic event), the in-between one is interpolated. But I cannot get a grip of how the SpatialTrack works. Is there an analogy with the Position/Rotation/ScaleTrack? Is there an example that demonstrates the use of SpatialTrack?

- Also MeshTrack doesn't seem to exist (yet?). Is it for the mesh deformation you mention above?

Sorry it's an error in the javadoc.
Actually what you need is AnimationFactory, it's a convenience class that use a key framed approach (you set transformation for a spatial at a given time, or keyframe), and allow in the end to generate a proper animation for the spatial.
Then the usage is exactly the same than for bone animations via AnimControl and AnimChannel.

Look at TestCinematic for an example, that's how the teapot is animated.
http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/animation/TestCinematic.java

So, is SpatialTrack a future thing that is going to do the same as Position/Rotation/MotionTrack?



I will have a closer look to AnimControl and AnimChannel, but honestly Position/Rotation/MotionTrack seems to be far more simple and straight-forward ;). Am I going to have a problem if I just go ahead and use those instead? They seem to be working fine for me at the moment. Do they have any known bugs? Are they going to be removed in the future?

@yannischris said:
So, is SpatialTrack a future thing that is going to do the same as Position/Rotation/MotionTrack?

I will have a closer look to AnimControl and AnimChannel, but honestly Position/Rotation/MotionTrack seems to be far more simple and straight-forward ;). Am I going to have a problem if I just go ahead and use those instead? They seem to be working fine for me at the moment. Do they have any known bugs? Are they going to be removed in the future?

More straight forward, but deprecated : this means, you use them at your own risk, there won't be any bugfix if any, and the class will probably disappear in the official release.

Really you should give a try to ANimationFactory, it does handle the complicated stuff for you and is pretty straight forward too.
The advantage of using animation over Position/rotation/scaleTrack is that the interpolation is baked into the animation instead of computed at runtime.
It does consume more memory (not that much) , but it's very faster.

SpatialTrack is used in the core Animation system and has nothing to do with the deprecated Position/Rotation/ScaleTrack. Really you don't need to use it directly.

OK I am definitely have a closer look at it, and hope that I can gain the same functionality as with the Position/RotationTrack (i.e. start position/rotation, end position/rotation, and interpolation of a specified duration between them).



Thank you nehon for the useful tips!