scurest / apicula

Convert Nintendo DS .nsbmd models
BSD Zero Clause License
160 stars 19 forks source link

Model animation playing too fast #65

Open ExcaliburZero opened 5 days ago

ExcaliburZero commented 5 days ago

It looks like the viewer renders at whatever fps the machine running it is able to render at, which can result in model animations playing at much faster rates than they are intended to play at in-game.

It would be good to have a cli flag that the user can provide to cap the frame rate, mainly in order to cap it at 60 fps to see the animation play at the intended speed.

apicula.exe view --max_fps 60.0 m003_00.*

apicula_viewer_fps

ExcaliburZero commented 5 days ago

After trying something, I think might be more of an issue of the animation play speed rather than being the fps of the viewer.

Here is a ~20fps gif comparing the playback of an animation from Dragon Quest Monsters: Joker in apicula (left) compared to Melon DS (right).

Animation

You can see the Metal Slime's moves up and down in the animation. The animation playing in apicula seems to be roughly double the speed of the animation playback in Melon DS.

scurest commented 5 days ago

All animations play at 60fps. If there is something in the file to tell how fast an animation should play, I don't know where it is.

ExcaliburZero commented 4 days ago

I found some relevant comments and code in Spiky's DS Map Editor.

https://github.com/Skareeg/SDSME/blob/14f0e908a4dae9650ba1a52fd2b75fcd5ea7a011/Source/Map_Editor/LibNDSFormats/NSBCA.cs#L100-L105 https://github.com/Skareeg/SDSME/blob/14f0e908a4dae9650ba1a52fd2b75fcd5ea7a011/Source/Map_Editor/LibNDSFormats/NSBCA.cs#L335-L380

If I understand it correctly, it looks like there is a field in the NSBCA file that determines the animation play rate (choosing between 60fps, 30fps, and 20fps?). Or maybe its a duration per frame?

ExcaliburZero commented 3 days ago

I tried implementing my understanding of that code onto this branch of my fork:

https://github.com/scurest/apicula/compare/master...ExcaliburZero:apicula:animation_play_rate

After testing it with a few animations from Dragon Quest Monsters: Joker, it doesn't seem to work. I tested with a model that has several animations that I think should all play at 30fps, and some of them were played at 30 fps but others were played at 60 fps.

I think until someone figures out how the animation playback rate is stored, it would be good to have a cli flag that can be provided to set the animation playback speed. I can put together a PR for that.