Last active
December 18, 2024 21:59
-
-
Save xDShot/7dcf5f25c48f787718dba237ef109f7f to your computer and use it in GitHub Desktop.
Source Engine mdl pattern for ImHex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| #pragma MIME application/source.mdl | |
| #include <std/mem.pat> | |
| using byte = u8; | |
| using int = s32; | |
| struct Vector | |
| { | |
| float x, y, z; | |
| }; | |
| struct Quaternion | |
| { | |
| float x, y, z, w; | |
| }; | |
| struct RadianEuler | |
| { | |
| float x, y, z; | |
| }; | |
| struct matrix3x4_t{ | |
| float m00; float m01; float m02; float m03; | |
| float m10; float m11; float m12; float m13; | |
| float m20; float m21; float m22; float m23; | |
| }; | |
| struct mstudiobone_t | |
| { | |
| int sznameindex; | |
| char Name[] @ $-4 + sznameindex; | |
| int parentbone; // parent bone | |
| int bonecontroller[6]; // bone controller index, -1 == none | |
| Vector pos; | |
| Quaternion quat; | |
| RadianEuler rot; | |
| Vector posscale; | |
| Vector rotscale; | |
| matrix3x4_t poseToBone; | |
| Quaternion qAlignment; | |
| int flags; | |
| int proctype; | |
| int procindex; // procedural rule | |
| int physicsbone [[hidden]]; // index into physically simulated bone | |
| int surfacepropidx; // index into string tablefor property name | |
| int contents; // See BSPFlags.h for the contents flags | |
| int unused[8]; // remove as appropriate | |
| }; | |
| struct mstudiobonecontroller_t | |
| { | |
| int bone; // -1 == 0 | |
| int type; // X, Y, Z, XR, YR, ZR, M | |
| float start; | |
| float end; | |
| int rest; // byte index value at rest | |
| int inputfield; // 0-3 user set controller, 4 mouth | |
| int unused[8]; | |
| }; | |
| struct mstudiobbox_t | |
| { | |
| int bone; | |
| int group; // intersection group | |
| Vector bbmin; // bounding box | |
| Vector bbmax; | |
| int szhitboxnameindex; // offset to the name of the hitbox. | |
| int unused[8]; | |
| char Name[] @ $ - 0x44 + szhitboxnameindex; | |
| }; | |
| struct mstudiohitboxset_t | |
| { | |
| int sznameindex; | |
| char Name[] @ $-4 + sznameindex; | |
| int numhitboxes; | |
| int hitboxindex; | |
| mstudiobbox_t HitBoxes[numhitboxes] @ $ -0x0C + hitboxindex; | |
| }; | |
| bitfield STUDIOMDL_FLAGS { | |
| AUTOGENERATED_HITBOX : 1; | |
| USES_ENV_CUBEMAP : 1; | |
| FORCE_OPAQUE : 1; | |
| TRANSLUCENT_TWOPASS : 1; | |
| STATIC_PROP : 1; | |
| USES_FB_TEXTURE : 1; | |
| HASSHADOWLOD : 1; | |
| USES_BUMPMAPPING : 1; | |
| USE_SHADOWLOD_MATERIALS : 1; | |
| OBSOLETE : 1; | |
| UNUSED : 1; | |
| NO_FORCED_FADE : 1; | |
| FORCE_PHONEME_CROSSFADE : 1; | |
| CONSTANT_DIRECTIONAL_LIGHT_DOT : 1; | |
| FLEXES_CONVERTED : 1; | |
| BUILT_IN_PREVIEW_MODE : 1; | |
| AMBIENT_BOOST : 1; | |
| DO_NOT_CAST_SHADOWS : 1; | |
| CAST_TEXTURE_SHADOWS : 1; | |
| padding : 1; | |
| VERT_ANIM_FIXED_POINT_SCALE : 1; | |
| padding : 11; | |
| } [[right_to_left]]; | |
| struct studiohdr2_t | |
| { | |
| int numsrcbonetransform; | |
| int srcbonetransformindex; | |
| int illumpositionattachmentindex; | |
| float flMaxEyeDeflection; | |
| int linearboneindex; | |
| int sznameindex; | |
| int m_nBoneFlexDriverCount; | |
| int m_nBoneFlexDriverIndex; | |
| int reserved[56]; | |
| }; | |
| struct studiohdr_t | |
| { | |
| int id; | |
| int version; | |
| int checksum; | |
| char name[64]; | |
| int length; | |
| Vector eyeposition; // ideal eye position | |
| Vector illumposition; // illumination center | |
| Vector hull_min; // ideal movement hull size | |
| Vector hull_max; | |
| Vector view_bbmin; // clipping bounding box | |
| Vector view_bbmax; | |
| STUDIOMDL_FLAGS flags; | |
| int numbones; // bones | |
| int boneindex; | |
| int numbonecontrollers; // bone controllers | |
| int bonecontrollerindex; | |
| int numhitboxsets; | |
| int hitboxsetindex; | |
| int numlocalanim; // animations/poses | |
| int localanimindex; // animation descriptions | |
| int numlocalseq; // sequences | |
| int localseqindex; | |
| int activitylistversion; // initialization flag - have the sequences been indexed? | |
| int eventsindexed; | |
| int numtextures; | |
| int textureindex; | |
| int numcdtextures; | |
| int cdtextureindex; | |
| int numskinref; | |
| int numskinfamilies; | |
| int skinindex; | |
| int numbodyparts; | |
| int bodypartindex; | |
| int numlocalattachments; | |
| int localattachmentindex; | |
| int numlocalnodes; | |
| int localnodeindex; | |
| int localnodenameindex; | |
| int numflexdesc; | |
| int flexdescindex; | |
| int numflexcontrollers; | |
| int flexcontrollerindex; | |
| int numflexrules; | |
| int flexruleindex; | |
| int numikchains; | |
| int ikchainindex; | |
| int nummouths; | |
| int mouthindex; | |
| int numlocalposeparameters; | |
| int localposeparamindex; | |
| int surfacepropindex; | |
| int keyvalueindex; | |
| int keyvaluesize; | |
| int numlocalikautoplaylocks; | |
| int localikautoplaylockindex; | |
| float mass; | |
| int contents; | |
| int numincludemodels; | |
| int includemodelindex; | |
| int virtualModel [[hidden]]; | |
| int szanimblocknameindex; | |
| int numanimblocks; | |
| int animblockindex; | |
| int animblockModel [[hidden]]; | |
| int bonetablebynameindex; | |
| int pVertexBase [[hidden]]; | |
| int pIndexBase [[hidden]]; | |
| byte constdirectionallightdot; | |
| byte rootLOD; | |
| byte numAllowedRootLODs; | |
| byte unused[1]; | |
| int unused4; | |
| int numflexcontrollerui; | |
| int flexcontrolleruiindex; | |
| float flVertAnimFixedPointScale; | |
| int unused3[1]; | |
| int studiohdr2index; | |
| int unused2[1]; | |
| }; | |
| struct cdtextures_t | |
| { | |
| int idx; | |
| char cdtexture[] @ std::mem::read_signed($-4, 4); | |
| }; | |
| studiohdr_t StudioHdr @ 0x00; | |
| studiohdr2_t StudioHdr2 @ StudioHdr.studiohdr2index; | |
| mstudiobone_t Bones[StudioHdr.numbones] @ StudioHdr.boneindex; | |
| mstudiobonecontroller_t BoneControllers[StudioHdr.numbonecontrollers] @ StudioHdr.bonecontrollerindex; | |
| mstudiohitboxset_t HitBoxSets[StudioHdr.numhitboxsets] @ StudioHdr.hitboxsetindex; | |
| cdtextures_t CdTextures[StudioHdr.numcdtextures] @ StudioHdr.cdtextureindex; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment