Ali_RS
January 30, 2022, 7:14am
1
Hi
This is a simple function to convert AnimClip to In-Place animation. Works with cyclic animation (walk, run,…).
public void convertToInPlace(AnimClip clip) {
for (AnimTrack track : clip.getTracks()) {
if (track instanceof TransformTrack transformTrack) {
Vector3f[] translations = transformTrack.getTranslations();
if (translations != null) {
Vector3f start = translations[0];
Vector3f end = translations[translations.length - 1];
Vector3f delta = end.subtract(start);
Vector3f factor = delta.divide(translations.length - 1);
Vector3f vTemp = new Vector3f();
for (int index = 0; index < translations.length; index++) {
Vector3f translation = translations[index];
vTemp.set(factor).multLocal(index);
translation.subtractLocal(vTemp);
}
transformTrack.setKeyframesTranslation(translations);
}
}
}
}
@sgold it might be nice to add a similar function in Wes library.
Edit:
Here is an example video:
7 Likes
sgold
January 30, 2022, 5:13pm
2
Good idea!
My first reaction was that the method should only modify tracks whose target is a Spatial
or a root joint. Those are the only tracks likely to include non-zero translations, so perhaps it’s a moot point. What do you think?
1 Like
Ali_RS
January 30, 2022, 5:19pm
3
Yes, agree with you, I also use it only for the root joint in my case.
1 Like
sgold
January 31, 2022, 12:12am
4
I’ve added some code to Wes, but I’m stuck on creating a test/demo app, because all the walk/run animations in jme3-testdata seem to be in-place animations.
@Ali_RS , can you point me to a good test model with Creative Commons licensing, preferably a CC-0?
1 Like
Ali_RS
January 31, 2022, 6:54am
5
What about using Mixamo characters and animations?
They are royalty free for personal, commercial, and non-profit projects.
I already have an account in Mixamo, if you want I can download it (with animations) and convert it to j3o for you.
1 Like
Ali_RS
January 31, 2022, 10:22am
6
May be good to document that it will work best with cyclic animation (walk, run,…).
If animation root motion speed is not linear during the animation then in-place animation may not look good.
See this example:
1 Like
sgold
January 31, 2022, 5:54pm
8
I can download it (with animations) and convert it to j3o for you
What would be the license of the converted model?
1 Like
Ali_RS
January 31, 2022, 6:32pm
9
From what I understand it would be a typical stock model type license with adding credit to Mixamo.
1 Like
sgold
February 10, 2022, 8:06pm
10
I don’t see how I could comply with such a license. Ah well…
Today I released Wes v0.7.0, which includes in-place animation routines and improves support for morph animations.
3 Likes
sgold
February 11, 2022, 11:17pm
12
There’s now an example app that converts a traveling animation to an in-place animation.
It uses the “ninja-fighter” model from @adi.barda ’s 3-D models repo .
1 Like