Skip to content

Model features

kaldrum requested to merge kaldrum/model-features:model-features into next

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 the extended frames are more than the original. 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.

(also #1234 has been fixed with this)

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

model features examples.zip

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

Here are builds for windows and linux:

srb2win.exe

lsdl2srb2

Edited by kaldrum

Merge request reports