Table of Contents

Class M2Root

Namespace
WoWLib.Formats.M2.Root
Assembly
WoWLib.dll

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

other M2Root

Properties

AttachmentLookupTable

Attachment lookup: attachment id -> index.

public Vector<ushort> AttachmentLookupTable { get; }

Property Value

Vector<ushort>

Attachments

Attachment points (weapons, effects, name plates).

public FamilyVector<M2Attachment> Attachments { get; }

Property Value

FamilyVector<M2Attachment>

BoneLookupTable

Bone lookup: skin sections select bone subsets through it.

public Vector<ushort> BoneLookupTable { get; }

Property Value

Vector<ushort>

Bones

The bones (MAX_BONES nominally 256).

public FamilyVector<M2CompBone> Bones { get; }

Property Value

FamilyVector<M2CompBone>

BoundingBox

The render bounds.

public CAaBox BoundingBox { get; set; }

Property Value

CAaBox

BoundingSphereRadius

The render bounding-sphere radius.

public float BoundingSphereRadius { get; set; }

Property Value

float

CameraLookupTable

Camera lookup: camera type -> index.

public Vector<ushort> CameraLookupTable { get; }

Property Value

Vector<ushort>

Cameras

Cameras (portrait, character info, flyby).

public FamilyVector<M2Camera> Cameras { get; }

Property Value

FamilyVector<M2Camera>

CollisionBox

The collision bounds.

public CAaBox CollisionBox { get; set; }

Property Value

CAaBox

CollisionNormals

Collision-hull per-face normals.

public Vector<C3Vector> CollisionNormals { get; }

Property Value

Vector<C3Vector>

CollisionSphereRadius

The collision bounding-sphere radius.

public float CollisionSphereRadius { get; set; }

Property Value

float

CollisionTriangles

Collision-hull triangle indices (3 per face).

public Vector<ushort> CollisionTriangles { get; }

Property Value

Vector<ushort>

CollisionVertices

Collision-hull vertices.

public Vector<C3Vector> CollisionVertices { get; }

Property Value

Vector<C3Vector>

Colors

Color and alpha animations, referenced from skin batches.

public FamilyVector<M2Color> Colors { get; }

Property Value

FamilyVector<M2Color>

Events

Timed events (sounds, footsteps, death thud).

public FamilyVector<M2Event> Events { get; }

Property Value

FamilyVector<M2Event>

FormatVersion

The MD20 format version (256 vanilla .. 274 Legion+).

public uint FormatVersion { get; set; }

Property Value

uint

GlobalFlags

Global flags, see GlobalFlags.

public GlobalFlags GlobalFlags { get; set; }

Property Value

GlobalFlags

GlobalLoops

Global-sequence loop lengths (timestamps).

public Vector<M2Loop> GlobalLoops { get; }

Property Value

Vector<M2Loop>

KeyBoneLookup

Key-bone lookup: key bone slot -> bone index, -1 if none.

public Vector<short> KeyBoneLookup { get; }

Property Value

Vector<short>

Lights

Model lights.

public FamilyVector<M2Light> Lights { get; }

Property Value

FamilyVector<M2Light>

Materials

Materials: render flags + blending modes.

public Vector<M2Material> Materials { get; }

Property Value

Vector<M2Material>

Name

The model's internal name; empty in 9.2+ files.

public string Name { get; set; }

Property Value

string

ParticleEmitters

Particle emitters.

public FamilyVector<M2Particle> ParticleEmitters { get; }

Property Value

FamilyVector<M2Particle>

ReplacableTextureLookup

Replacable-texture reverse lookup: replacable id -> texture index or -1.

public Vector<short> ReplacableTextureLookup { get; }

Property Value

Vector<short>

RibbonEmitters

Ribbon (trail) emitters.

public FamilyVector<M2Ribbon> RibbonEmitters { get; }

Property Value

FamilyVector<M2Ribbon>

SequenceLookups

Animation-id hash table: AnimationData.dbc id -> sequence index, quadratic probing, -1 empty.

public Vector<short> SequenceLookups { get; }

Property Value

Vector<short>

Sequences

The animation sequences.

public FamilyVector<M2Sequence> Sequences { get; }

Property Value

FamilyVector<M2Sequence>

TextureLookupTable

Texture lookup: batches select textures through it.

public Vector<ushort> TextureLookupTable { get; }

Property Value

Vector<ushort>

TextureMappingLookupTable

Texture-mapping lookup: -1 environment, 0 first UV set, 1 second (unused since Cata).

public Vector<short> TextureMappingLookupTable { get; }

Property Value

Vector<short>

TextureTransforms

UV animations.

public FamilyVector<M2TextureTransform> TextureTransforms { get; }

Property Value

FamilyVector<M2TextureTransform>

TextureTransformsLookupTable

Texture-transform lookup: batches select UV animations through it, -1 static.

public Vector<short> TextureTransformsLookupTable { get; }

Property Value

Vector<short>

TextureWeights

Global transparency weights.

public FamilyVector<M2TextureWeight> TextureWeights { get; }

Property Value

FamilyVector<M2TextureWeight>

Textures

The texture definitions.

public Vector<M2Texture> Textures { get; }

Property Value

Vector<M2Texture>

TransparencyLookupTable

Transparency lookup: batches select texture weights through it.

public Vector<ushort> TransparencyLookupTable { get; }

Property Value

Vector<ushort>

Vertices

The global vertex list (Z-up model space).

public Vector<M2Vertex> Vertices { get; }

Property Value

Vector<M2Vertex>

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

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

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

version ClientVersion

Returns

M2Root

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

era Expansion

Returns

M2Root

GetHashCode()

Reference-identity hash (the C++ type has no hash to mirror).

public override int GetHashCode()

Returns

int

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

data byte[]

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

ValidationReport

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

l M2Root
r M2Root

Returns

bool

operator !=(M2Root?, M2Root?)

public static bool operator !=(M2Root? l, M2Root? r)

Parameters

l M2Root
r M2Root

Returns

bool