zturtleman / mm3d

Maverick Model 3D is a 3D model editor and animator for games.
https://clover.moe/mm3d
GNU General Public License v2.0
110 stars 22 forks source link

Add option to save MD3 animation.cfg when not in "player model" mode #147

Closed quakemmo closed 3 years ago

quakemmo commented 3 years ago

Is this the intended behavior?

I created an .mm3d model with a basic skeletal animation. It works nicely. I then converted the animation to frame animation and used the "Export" feature to export to a MD3 file.

When opening the MD3 file in the MM3D software, no animations are there and animation.cfg has not been created.

Is this working as intended, for the frame animations? What about animation.cfg?

Thanks!

Trying to make an animated model that is not a composite Q3 player model.

zturtleman commented 3 years ago

animation.cfg is only saved for player models. The only other animated models in Quake 3 (like shotgun_hand.md3) have hard coded frame numbers. When you say MD3 has no animations do you mean the file only has one frame?

Currently Maverick saves animation names in MD2 model frame names but not MD3. I've started to adding it locally but I haven't finished it. This allows Maverick to display animations list when viewing the MD3 but Quake 3 itself doesn't use or allow accessing the frame names.

quakemmo commented 3 years ago

Thanks for your reply.

When you say MD3 has no animations do you mean the file only has one frame?

Actually I was wrong. My MM3D file has 2 animations, of 10 frames each. The exported MD3 file has one frame animation of 20 frames, called "AnimFrames".

Splitting the AnimFrames animation into two different ones and renaming them to proper names works. Except it's not saved. After reopening the file, it's still one AnimFrame animation of 20 frames.

quakemmo commented 3 years ago

@zturtleman Any chance you could finish adding the possibility of saving frame anim names and animation.cfg for non player models?

That would help tons. I understand ioq3 isn't going to be able to use it as is.

If you can also add saving the player model regardless of group names as mentionned in the previous issue I opened, it would be icing on the cake.

I'd gladly donate if there's a way.

zturtleman commented 3 years ago

Looking at MD3 frame names again; I misremembered. Misfit/Maverick already save the animation names in the MD3 frames but frame names are ignored when loading MD3 models and hard coded "AnimFrames" name is used.

The main hold up (for loading MD3 frame names as animations, based on the MD2 importer) is that MD2 export/import has a hack to add an underscore between animation names ending with a number and the frame number ("example1" (first frame) -> "example100" vs "example1_00") and then removes the underscore when loading the model. Otherwise Misfit/Maverick removes all trailing numbers and "example100", "example200" become one animation ("example"). Adding an underscore in MD3 frame names would break exporting models for Sonic Robo Blast 2 which is the only thing that I know uses MD3 frame names.

I've started working on more robust frame name parsing so that adding an underscore at export isn't needed. I need to more thoroughly test it and fix edge cases. (Which is complicated by licensing since I plan to also use this frame name parsing code in a non-GPL project. It would be a problem if changes to it are submitted to Maverick as GPL. So I guess it needs it's own file with zlib license or something.)

I'll look into adding an MD3 export option to write animation.cfg for non-player models (which is used by Tremulous for instance) and also loading it. (Which would not need to load/parse MD3 frame names at all.)

zturtleman commented 3 years ago

I added support for writing animation.cfg for non-player MD3 models in https://github.com/zturtleman/mm3d/commit/7a089b031cd4b0cce92b932074590bbbf7a11226.

It currently requires changing a #if 0 to #if 1 in src/libmm3d/md3filter.cc before compiling it. I plan to add a MD3 export dialog to allow enabling it. (Otherwise load/save upper.md3 in a player model directory would overwrite player animation.cfg.)

quakemmo commented 3 years ago

Only got a chance to test it now - thank you for your work!

If I understand correctly, the proper workflow is to create/animate the model and keep it in MM3D format, then when needed, convert skeletal to frame animations and save it as MD3, then use the MD3 in the game, right?

It kinda works, and the animation.cfg generated seems to be OK - but for some reason, when loading the MD3 model in MM3D, there's only one frame animation and it's called AnimFrames. I think I can still live with that, and only work with the .mm3d file and export as needed, but thought I'd let you know.

Also, sneaky reminder to add the dialog box instead of #if 0 ;)

zturtleman commented 3 years ago

Yeah that's the proper workflow and I'm aware that imported MD3 animation names are still missing. I don't have a time frame for adding the MD3 export dialog.

zturtleman commented 3 years ago

MD3 export dialog with save as player model and save animation.cfg options

Alright, after 4 to 6 hours of work there is now a MD3 export dialog box. With two options to toggle features already present. The Save as a Player Model option is grayed out if the model can't be exported as a player. Added in https://github.com/zturtleman/mm3d/compare/7c81c59dcb5d2b640aff749fbb64a4170fc81a8d...9d76b0f66267699cad499307441bdc9bfb437f2f.

There is still some other options I'd like to add but it's unrelated to this issue. And at least the annoying part (the dialog with bits and pieces of code to copy-and-paste in a dozens of places and player model detection) is out of the way.

Still to be done: Animation name loading from MD3 models but I should probably create a separate issue for it.

quakemmo commented 3 years ago

Thumbs up!

quakemmo commented 3 years ago

I'll open the AnimFrames issue for you.