Class M2Root
An MD20 model body, abstract over the client version. Construct a concrete version with M2Root.for_version(expansion); the per-version M2Root* classes are subclasses. See https://wowdev.wiki/M2.
public class M2Root : IDisposable
- Inheritance
-
M2Root
- Implements
- Derived
- Inherited Members
Constructors
M2Root()
public M2Root()
M2Root(M2Root)
Copy-construct: a deep copy of other (the C++ copy constructor).
public M2Root(M2Root other)
Parameters
otherM2Root
Properties
AttachmentLookupTable
Attachment lookup: attachment id -> index.
public Vector<ushort> AttachmentLookupTable { get; }
Property Value
Attachments
Attachment points (weapons, effects, name plates).
public FamilyVector<M2Attachment> Attachments { get; }
Property Value
BoneLookupTable
Bone lookup: skin sections select bone subsets through it.
public Vector<ushort> BoneLookupTable { get; }
Property Value
Bones
The bones (MAX_BONES nominally 256).
public FamilyVector<M2CompBone> Bones { get; }
Property Value
BoundingBox
The render bounds.
public CAaBox BoundingBox { get; set; }
Property Value
BoundingSphereRadius
The render bounding-sphere radius.
public float BoundingSphereRadius { get; set; }
Property Value
CameraLookupTable
Camera lookup: camera type -> index.
public Vector<ushort> CameraLookupTable { get; }
Property Value
Cameras
Cameras (portrait, character info, flyby).
public FamilyVector<M2Camera> Cameras { get; }
Property Value
CollisionBox
The collision bounds.
public CAaBox CollisionBox { get; set; }
Property Value
CollisionNormals
Collision-hull per-face normals.
public Vector<C3Vector> CollisionNormals { get; }
Property Value
CollisionSphereRadius
The collision bounding-sphere radius.
public float CollisionSphereRadius { get; set; }
Property Value
CollisionTriangles
Collision-hull triangle indices (3 per face).
public Vector<ushort> CollisionTriangles { get; }
Property Value
CollisionVertices
Collision-hull vertices.
public Vector<C3Vector> CollisionVertices { get; }
Property Value
Colors
Color and alpha animations, referenced from skin batches.
public FamilyVector<M2Color> Colors { get; }
Property Value
Events
Timed events (sounds, footsteps, death thud).
public FamilyVector<M2Event> Events { get; }
Property Value
FormatVersion
The MD20 format version (256 vanilla .. 274 Legion+).
public uint FormatVersion { get; set; }
Property Value
GlobalFlags
Global flags, see GlobalFlags.
public GlobalFlags GlobalFlags { get; set; }
Property Value
GlobalLoops
Global-sequence loop lengths (timestamps).
public Vector<M2Loop> GlobalLoops { get; }
Property Value
KeyBoneLookup
Key-bone lookup: key bone slot -> bone index, -1 if none.
public Vector<short> KeyBoneLookup { get; }
Property Value
Lights
Model lights.
public FamilyVector<M2Light> Lights { get; }
Property Value
Materials
Materials: render flags + blending modes.
public Vector<M2Material> Materials { get; }
Property Value
Name
The model's internal name; empty in 9.2+ files.
public string Name { get; set; }
Property Value
ParticleEmitters
Particle emitters.
public FamilyVector<M2Particle> ParticleEmitters { get; }
Property Value
ReplacableTextureLookup
Replacable-texture reverse lookup: replacable id -> texture index or -1.
public Vector<short> ReplacableTextureLookup { get; }
Property Value
RibbonEmitters
Ribbon (trail) emitters.
public FamilyVector<M2Ribbon> RibbonEmitters { get; }
Property Value
SequenceLookups
Animation-id hash table: AnimationData.dbc id -> sequence index, quadratic probing, -1 empty.
public Vector<short> SequenceLookups { get; }
Property Value
Sequences
The animation sequences.
public FamilyVector<M2Sequence> Sequences { get; }
Property Value
TextureLookupTable
Texture lookup: batches select textures through it.
public Vector<ushort> TextureLookupTable { get; }
Property Value
TextureMappingLookupTable
Texture-mapping lookup: -1 environment, 0 first UV set, 1 second (unused since Cata).
public Vector<short> TextureMappingLookupTable { get; }
Property Value
TextureTransforms
UV animations.
public FamilyVector<M2TextureTransform> TextureTransforms { get; }
Property Value
TextureTransformsLookupTable
Texture-transform lookup: batches select UV animations through it, -1 static.
public Vector<short> TextureTransformsLookupTable { get; }
Property Value
TextureWeights
Global transparency weights.
public FamilyVector<M2TextureWeight> TextureWeights { get; }
Property Value
Textures
The texture definitions.
public Vector<M2Texture> Textures { get; }
Property Value
TransparencyLookupTable
Transparency lookup: batches select texture weights through it.
public Vector<ushort> TransparencyLookupTable { get; }
Property Value
Vertices
The global vertex list (Z-up model space).
public Vector<M2Vertex> Vertices { get; }
Property Value
Methods
Dispose()
Release the native object now. Optional: the finalizer releases it on
collection anyway - dispose (or using) when you want native memory back
promptly.
public virtual void Dispose()
EnsureValid()
Validate and raise on the first error instead of returning a report — the assert-style face of validate().
public void EnsureValid()
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
ForVersion(ClientVersion)
A fresh M2Root for an exact client version — the only axis that can name a Classic client, whose files follow the engine its build was cut on rather than its 1.15 / 4.4 version number.
public static M2Root ForVersion(ClientVersion version)
Parameters
versionClientVersion
Returns
ForVersion(Expansion)
A fresh M2Root for the given era, as the family base — the dynamic twin of the typed Era factories.
public static M2Root ForVersion(Expansion era)
Parameters
eraExpansion
Returns
GetHashCode()
Reference-identity hash (the C++ type has no hash to mirror).
public override int GetHashCode()
Returns
Read(byte[])
Deserialize file bytes into this entity, replacing its contents. Offsets resolve against the given buffer; sequence-gated data is read inline.
public void Read(byte[] data)
Parameters
databyte[]
Validate()
Check the logical integrity contracts this file must satisfy to LOAD in the client — companion-array counts, lookup ranges — which write() deliberately never enforces. Call it before writing when you want to know the result will load. A file read from a client and left unmodified reports no errors; warnings mark states real client files ship.
public ValidationReport Validate()
Returns
Write()
Serialize this entity in wowlib's canonical layout (an offset format has no byte-perfect round-trip guarantee; a written entity re-reads equal instead).
public byte[] Write()
Returns
- byte[]
Operators
operator ==(M2Root?, M2Root?)
public static bool operator ==(M2Root? l, M2Root? r)
Parameters
Returns
operator !=(M2Root?, M2Root?)
public static bool operator !=(M2Root? l, M2Root? r)