Model features
This merge request aims to add various (somewhat) requested features to md3 models.
Three new animation flags have been added, in addition to the existing +i:
+e: for extend, this allows any spr2 animation to go past its allotted frames as determined from the sprites. This only works if there are more frames in the extended model animation than the original sprite animation. These extended frames behave essentially as custom interpolation frames: The frames are squeezed into the same timeframe as normal, but the animation plays faster, filling in the extra ones evenly through the animation. A 4-frame animation extended to 8 frames will play 2 frames in the same amount of time a sprite would just play 1. This allows you to do much higher fps animations than before without nearly as big a risk of distorting the model with linear interpolation. In the same vein, interpolated frames work well with these changes, as now you can better control the transitory frames.
Side note - this has some weird (but i do think correct) behavior with spr2defaults: it will treat the whole animation as the original animations length, repeating when necessary, instead of adapting the animation to the new number of frames. For example, if stand is 4 frames, and you don't include a run animation, it will loop through the stand frames 4 times, a total of 16 frames in the regular timespan.
+n: for no zero angle, this prevents the model from being forced to face the camera. this works on both spr2 models and regular sprite models
+o: for force zero angle, this does the opposite, all frames in the animation are always facing the camera
If these are omitted, the behavior should stay exactly the same as before.
All of these flags can be added simultaneously and with the existing interpolation flag, except for the n and o flags, which are mutually exclusive. If both are found, the second will be prioritized. The logic only checks for the presence of three flags max on sprite2 models, and two on sprite models.
All of these are valid ways to set up the flags:
- SPR2_ANIM+i
- SPR2_ANIM+nie
- SPR2_ANIM+io
- SPR2_ANIM+ei
- SPR+n
- SPR+io
- SPR+ni
These are invalid:
- SPR2_ANIM+no - the zero angle force flag will be used
- SPR2_ANIM+eoni - the no zero angle flag will be used, the interpolation flag will be omitted
- SPR+ie - this should work fine, but the extend flag will not have any effect
- SPR+ei- the interpolation flag will not be used
A showcase of these is in the video.
SRB2 v2.2.14 nightly 2024-04-20 18-25-37.mp4
The STND animation and the RUN animation have the +e flag, with stand having 3 frames (instead of 1) and run having 8, instead of 4.
The ROLL animation and the TRNS animation have the +n flag, allowing viewing of the animation from any angle for either, overriding the default sprite behavior.
The WAIT animation has the +o flag, which makes it always face the camera.
The example blend file in the zip folder shows these changes in effect on the frame markers. The blender addon for exporting things to md3 is at this google drive link https://drive.google.com/drive/folders/1Hv6IaRByirP9L-KaODKf4-COkC2rKoZj, io_export_md3.py The exported md3 is also present in the included zip folder. Example model by fznmeatpopsicle.
In addition to this, I added a feature to sprite models that allows multiple to be included in the same file. If you add a marker on the first frame of the animation with the name of the sprite it should be replacing, you can place the models animations (sequentially) at any frame, not just the first.
For example, if you wanted to include both blue and red crawlas in one file, you can add the marker "POSS" at the first set of frames, and then the marker SPOS where you want the red crawla's animations to start. These will read from the same texture, so if you have reused objects with the same textures (not the case of the crawla here, making this a somewhat bad example), you can throw all of them in the same file. An example blend file of this, as well as an md3 containing both crawlas and their textures is in the zip folder.
These support the long sprite names, to a point, as md3 frame names are limited to 16 charactes max, including internal chars that show frame number characters at the end. If the name is too long, the old behavior can still be used, and a name prefix is no longer required to use the interpolation/zero angle flags
Models.dat lines for md3s are included.
Furthermore, I've made it so that states are the main avenue for determining what model frames to use, not sprites. This makes it so if two states reuse a sprite, a model doesn't necessarily have to use the same animation for both, it can use the default spr2 assigned to the state. For example, this would now let every character have a jump animation separate from their roll.
The last change i made, due to adding the ability to extend the frames, is to the way that all player models animate. There was an 'interpolation limit' in place, which gave a sort of ease in/out to animations around 9 tics and longer. Because modelers can now define their own in between frames, I don't think this forced behavior is necessary or particularly useful to have. I kept it on the sprites, where animations cant be extended, but otherwise it has been entirely removed.
Example showing an affected model:
Original behavior
SRB2 v2.2.13 2024-04-18 18-23-47.mp4
With changes
SRB2 v2.2.13 2024-04-18 18-22-41.mp4
For modelers wanting to test this out: under the "View exposed artifacts" section, click on the appropriate operating system under the "Artifact" table. Then, find the "bin" folder. Within this should be a compiled build for your OS - srb2win.exe for Windows, lsdlsrb2 for Linux, and srb2.app for MacOS.