-
Notifications
You must be signed in to change notification settings - Fork 42
Migrate to the new animation system #412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| * A single track of pose animation associated with a certain mesh. | ||
| */ | ||
| public final class PoseTrack implements Track, ClonableTrack { | ||
| public final class PoseTrack extends MorphTrack { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this could be a first step towards solving #409 (comment).
AFAICT you'd need to define MorphTargets for the target Geometry instead of custom Poses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jME morph targets work a bit differently. If I remember correctly, they are hardware accelerated. But there was some reason that they don't really work with our way of thinking... Was it that we would then have millions of morph targets per model? And it just didn't work out... Something like this? And the hardware acceleration worked only up until 7 morph targets...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it's similar to what I do in blender, 1 morph target per frame and weights like (0,0,0,1,0,0...), so quite a few.
But maybe MorphTrack could otherwise be shoe-horned into doing what we need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I mean if it works and the performance is ok. Absolutely then yes. I could have just made a quick call back then.
By the way, F5 displays FPS, F6 gives kinda detailed information about the frames being rendered. There can maybe see how the new animations compare to the old, performance wise. Not super accurate but can give some sort of pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
The problem is that the whole PoseTrack thing is even harder to understand than KMF itself. All those previous and next frame refs in FrameInfo and Pose, all the maps and copy paste calls in:
| Pose p = new Pose(index + ": " + frame + ", " + entry.getKey().previousPoseFrame + " - " + entry.getKey().nextPoseFrame, frameOffsets.get(frame).get(entry.getKey()).toArray(new Vector3f[frameOffsets.get(frame).get(entry.getKey()).size()]), array); |
There also seems to be quite some redundancy:
https://gist.github.com/Trass3r/cdd614ec24c48f94969389492117fa0d#file-piranha_swim-xml-L163
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we were already passing through this code, it works cause in getDataAtTime we never set the output weights parameter and then setMorphState is a no-op:
private void interpolateMorphTrack(double t, MorphTrack track) {
Geometry target = track.getTarget();
float[] weights = target.getMorphState();
track.getDataAtTime(t, weights);
target.setMorphState(weights);Btw the shader is indeed limited to a handful of morph targets to blend but you don't really need that many, and the system also falls back to CPU morph target merging as needed:
https://github.com/jMonkeyEngine/jmonkeyengine/blob/af375391ea385a061444ca03262e1a4720c3274d/jme3-core/src/main/java/com/jme3/anim/MorphControl.java#L157-L158
1f5e2f5 to
42ff471
Compare
| this.times = times; | ||
| public PoseTrack(Geometry target, float[] times, PoseTrack.PoseFrame[] frames) | ||
| { | ||
| super(target, times, new float[times.length], 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iirc this fixes loading into Maud, but when playing the animation it just shows the base mesh.
55ec3da to
219b9fa
Compare
|
What is the status of this? I didn't try the code yet, do the different animation modes still work? |
|
So far I couldn't spot any regressions. |
|
On 3.6 jME there will be native tweens for the deprecated loop modes. So lets look at this then. |
|
Would we need to use AnimLayer then? |
|
Hmm, not sure, it was this PR https://github.com/jMonkeyEngine/jmonkeyengine/pull/1849/files. |
|
088220e to
3ccd06c
Compare
cb48603 to
1781f34
Compare
|
Yeah, I finally got around to test this. It seems to work. I tried to use the Tween.cycle in the AnimationLoader rather than tamper with the Global Animation Speed. But that resulted in doors spawning as opened. Well, need to check this at some point. So yes, fine by me. Ready to merge? |
Found this old #362 branch and rebased fwiw.