model flags

This commit is contained in:
Robin Appelman 2022-03-17 20:25:02 +01:00
commit 14e006e988
2 changed files with 28 additions and 11 deletions

View file

@ -11,6 +11,7 @@ thiserror = "1.0.30"
static_assertions = "1.1.0"
bitflags = "1.0.4"
itertools = "0.10.3"
tracing = "0.1.29"
[dev-dependencies]
three-d = "0.10.2"

View file

@ -22,18 +22,8 @@ pub struct StudioHeader {
pub view_bb_min: Vector,
pub view_bb_max: Vector,
pub flags: i32, // Binary flags in little-endian order.
// ex (00000001,00000000,00000000,11000000) means flags for position 0, 30, and 31 are set.
// Set model flags section for more information
pub flags: ModelFlags,
/*
* After this point, the header contains many references to offsets
* within the MDL file and the number of items at those offsets.
*
* Offsets are from the very beginning of the file.
*
* Note that indexes/counts are not always paired and ordered consistently.
*/
// mstudiobone_t
bone_count: i32, // Number of mdl sections (of type mstudiobone_t)
bone_offset: i32, // Offset of first mdl section
@ -184,6 +174,32 @@ pub struct StudioHeader {
unused3: i32,
}
bitflags! {
#[derive(BinRead)]
pub struct ModelFlags: u32 {
const AUTOGENERATED_HITBOX = 0x00000001;
const USES_ENV_CUBEMAP = 0x00000002;
const FORCE_OPAQUE = 0x00000004;
const TRANSLUCENT_TWOPASS = 0x00000008;
const STATIC_PROP = 0x00000010;
const USES_FB_TEXTURE = 0x00000020;
const HASSHADOWLOD = 0x00000040;
const USES_BUMPMAPPING = 0x00000080;
const USE_SHADOWLOD_MATERIALS = 0x00000100;
const OBSOLETE = 0x00000200;
const UNUSED = 0x00000400;
const NO_FORCED_FADE = 0x00000800;
const FORCE_PHONEME_CROSSFADE = 0x00001000;
const CONSTANT_DIRECTIONAL_LIGHT_DOT = 0x00002000;
const FLEXES_CONVERTED = 0x00004000;
const BUILT_IN_PREVIEW_MODE = 0x00008000;
const AMBIENT_BOOST = 0x00010000;
const DO_NOT_CAST_SHADOWS = 0x00020000;
const CAST_TEXTURE_SHADOWS = 0x00040000;
const VERT_ANIM_FIXED_POINT_SCALE = 0x00200000;
}
}
impl StudioHeader {
pub fn header2_index(&self) -> Option<usize> {
(self.studio_hdr2_index > 0)