[MD3] Using "-1" for model frame numbers to hide them

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

[MD3] Using "-1" for model frame numbers to hide them

Postby Cherno » Mon Nov 26, 2018 8:24 pm

Scenario: HUD weapon consisting of two models: The weapon itself and a muzzleflash. Naturally, the muzzleflash should only be visible in a single firing frame of the weapon.

After consulting the MODELDEF wiki article, I learned that

When using FrameIndex, setting frame number to -1 disables rendering of the associated model.


Easy. MODELDEF code:

Code: Select allExpand view
Model AITD_Shotgun               // Name of actor in DECORATE
{
   Path "models/weapons/shotgun"    // Path to model in PK3
   Model 0 "shotgun_v.md3"    // Model index, model file
   Model 1 "shotgun_v_muzzleflash.md3"
   SurfaceSkin 0 0 "models/PAL1.png"
   SurfaceSkin 1 0 "models/PAL1.png"

        //idle:
   FrameIndex SHGA A 0 0         // The sprite lump, sprite frame, model index, frame number
   FrameIndex SHGA A 1 -1//"-1" for frame number should disable the muzzleflash model for that frame

        //firing (+ muzzleflash):
   FrameIndex SHGA B 0 1
   FrameIndex SHGA B 1 1//muzzleflash model should be visible in this frame
}


Problem: The "-1" doesn't just disable or hide the model; It seems like it calls something akin to "A_Lower" to move the model downwards out of view.

Solution, or rather workaround so far, is to have separate MODELDEFS entries for all those instances where a model needs to be visible, so it is only defined and used in those entries. This of course breaks interpolation (model animation frames between separate MODELDEF entries for the same actor are not interpolated) so the states need some ugly workarounds, too.

Code: Select allExpand view
//frames without muzzleflash model
Model AITD_Shotgun
{
        Model 0 "shotgun_v.md3"
   [...]

        //idle
   FrameIndex SHGA A 0 0         // The sprite lump, sprite frame, model index, frame number
}
*/

/*
//frames with muzzleflash model
Model AITD_Shotgun
{
        Model 0 "shotgun_v.md3"
   Model 1 "shotgun_v_muzzleflash.md3"
   [...]
       
        //muzzleflash
   FrameIndex SHGA B 0 1
   FrameIndex SHGA B 1 1
}


I assume that the "-1" behavior works as intended and the wiki article is somewhat out of date or just unclear on the exact meaning of "disables rendering". If so, is my workaround the only way to make model show only temprorarily? I would guess that things like muzzleflashes for HUD weapons and such are quite common. (Yes, it is possible to make the muzzleflash part of the weapon model and move it via bone out of sight and in front of the muzzle when needed... HOWEVER due to the way interpolation works this makes the muzzleflash mesh move towards it's keyframe positions, so it's also not possible after all!)
User avatar
Cherno
 
Joined: 06 Dec 2016

Re: [MD3] Using "-1" for model frame numbers to hide them

Postby Cherno » Tue Nov 27, 2018 6:09 pm

Found another odd behavior: An animated model part keeps being rendered and will move toward it's first frame's position when a sprite frame which doesn't include that model is being called. Normally, and true for non-animated model parts, the model would just disappear. At least that's what I think is happening and it's very aggravating because it causes the workaround Imentioned above to also fail since effectivels the same thing as the "-1 frame number method" is happening, namely that a model part that should be hidden is still visible.
User avatar
Cherno
 
Joined: 06 Dec 2016


Return to Assets (and other stuff)

Who is online

Users browsing this forum: No registered users and 1 guest