Skip to content

Conversation

@Trass3r
Copy link
Collaborator

@Trass3r Trass3r commented Jul 11, 2022

Found this old #362 branch and rebased fwiw.

* A single track of pose animation associated with a certain mesh.
*/
public final class PoseTrack implements Track, ClonableTrack {
public final class PoseTrack extends MorphTrack {
Copy link
Collaborator Author

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?

Copy link
Owner

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...

Copy link
Collaborator Author

@Trass3r Trass3r Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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

@Trass3r Trass3r force-pushed the feature-362 branch 2 times, most recently from 1f5e2f5 to 42ff471 Compare July 13, 2022 16:17
this.times = times;
public PoseTrack(Geometry target, float[] times, PoseTrack.PoseFrame[] frames)
{
super(target, times, new float[times.length], 1);
Copy link
Collaborator Author

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.

@Trass3r Trass3r force-pushed the feature-362 branch 2 times, most recently from 55ec3da to 219b9fa Compare July 22, 2022 14:52
@tonihele
Copy link
Owner

What is the status of this? I didn't try the code yet, do the different animation modes still work?

@Trass3r
Copy link
Collaborator Author

Trass3r commented Aug 14, 2022

So far I couldn't spot any regressions.
But please feel free to test it yourself.

@tonihele
Copy link
Owner

tonihele commented Jan 8, 2023

On 3.6 jME there will be native tweens for the deprecated loop modes. So lets look at this then.

@Trass3r
Copy link
Collaborator Author

Trass3r commented Jan 8, 2023

@Trass3r
Copy link
Collaborator Author

Trass3r commented Jan 31, 2023

Would we need to use AnimLayer then?
jMonkeyEngine/jmonkeyengine#1845

@tonihele
Copy link
Owner

@Trass3r
Copy link
Collaborator Author

Trass3r commented Jan 31, 2023

Some enhancement to new animation system by @Ali-RS in jMonkeyEngine/jmonkeyengine#1845

Added a Loop tween to Tweens factory class. Supports looping by count… by @Ali-RS in jMonkeyEngine/jmonkeyengine#1846

Added Tweens.cycle() and Tweens.invert() methods by @Ali-RS in jMonkeyEngine/jmonkeyengine#1849

@Trass3r
Copy link
Collaborator Author

Trass3r commented Mar 24, 2023

@Trass3r Trass3r force-pushed the feature-362 branch 4 times, most recently from 088220e to 3ccd06c Compare April 16, 2023 00:32
@Trass3r Trass3r force-pushed the feature-362 branch 2 times, most recently from cb48603 to 1781f34 Compare April 25, 2023 09:03
@tonihele
Copy link
Owner

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?

@tonihele tonihele merged commit 0e19663 into tonihele:master May 21, 2023
@Trass3r Trass3r deleted the feature-362 branch May 21, 2023 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants