[MD3] Using "-1" for model frame numbers to hide them
Posted: Mon Nov 26, 2018 7: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
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.
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!)
After consulting the MODELDEF wiki article, I learned that
Easy. MODELDEF code:When using FrameIndex, setting frame number to -1 disables rendering of the associated model.
Code: Select all
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
}
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 all
//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
}