Cycle through animations in glTF files
I searched the user documentation and looked at the help screen and searched for open issues, but could not find it, so I apologize if this feature exists.
Since glTF can have multiple animations per file, it would be good if the name of the current animation would be displayed somewhere and if there was a way (a single hotkey would be enough) to cycle through them.
You are correct, you can either select an animation or select all animations but using the command line only. You need to restart F3D to select another animation.
That being said, adding this feature should be trivial!
I think it would also be good if there was a way to list the names of all the animations in the file with a command line switch. E.g. passing --list-animations would show something like this:
0: Idle
1: Walk
2: Die
--verbose already provide that
Hi, I have been in recent communication with the F3D team on Discord, in which I mentioned my interest working on this Github issue.
I have set up my local development environment, as well as taken a look at the VTK Users Guide and accompanying examples. I am new to learning graphics software, so I am familiarizing myself with the core concepts such as actors, mappers, renderers, pipeline, etc.
Right now, I am trying to understand which part of the F3D codebase my modifications for this issue should reside in. I'm assuming it has something to do with: library/VTKExtensions/Rendering? I have also found some related content for text such as vtkTextSource(), vtkTextMapper(), vtkTextProperty(), TextActor, etc. I'm also looking into how to extract animation data from gltf files.
Since I am new to open source contributions, I will appreciate any additional tips!
Here's 2 tracks to investigate if you fancy venturing blindly into the weeds (I don't know how animations actually work myself):
- animations can be selected with
--animation-indexfrom the command line. This option is declared here https://github.com/f3d-app/f3d/blob/2f95ee30cc1d36f5f522558656926d13ed952dd9/application/F3DOptionsParser.cxx#L333 and is stored internally as"scene.animation.index"in the options. It's then read here: https://github.com/f3d-app/f3d/blob/2f95ee30cc1d36f5f522558656926d13ed952dd9/library/src/animationManager.cxx#L80 - animation can be started/stopped pressing space within the app, which is handled here: https://github.com/f3d-app/f3d/blob/2f95ee30cc1d36f5f522558656926d13ed952dd9/library/src/interactor_impl.cxx#L340-L344
If you'd rather have a more directed plan I'm sure @mwestphal can provide an overview of how multiple animation are implemented and how UI would need to tie into it.
@snoyer pointers are indeed on point.
What you need to do is add a new interaction bindings (in f3d/library/src/interactor_impl.cxx) that will cycle through available animations, which are recovered in the "vtkImporters" level.
It is a litle bit complicated because options like "scene.animation.index" are not great for cycling since you do not know the highest value possible.
It can be done though, you can look how cycling scalars is implemented.
@kathleenhang Ill let you investigate but feel free to ask any follow up questions.
Thanks for the tips @snoyer, @mwestphal ! Very helpful.
I'll appreciate feedback on my recent commits: https://github.com/kathleenhang/f3d/tree/kathleenhang-902
The code isn't functional. However, it will be helpful to know if I'm on the right track. I'm simply experimenting with the codebase to better understand how it all interconnects. Therefore, some aspects might not make sense.
- I have done a keybind to "W" for cycling through the animations.
- CycleAnimationsFor{FILE_TYPE}() increments through the circular rotated array indices of {FILE_TYPE}
- GetAnimationDescription() displays information for current animation keyframe
- Animation options are set after "W" key is pressed
My question is: When a user imports their GLTF file into F3D, where does the data flow? I would assume it goes through vtkF3DGenericImporter which would contain a vtkGLTFReader. That would then allow me to access the data structure array containing each individual animation keyframe within the imported GLTF file. Finally, I could retrieve the file name property from each keyframe to display onto the frontend.
I'll answer in detail but please open a pr directly, that will make it simpler to discuss the code :)
@pfirsich F3D nightly binary release now contains the feature!
https://github.com/f3d-app/f3d/releases/tag/nightly