M2Header

Struct M2Header 

Source
pub struct M2Header {
Show 46 fields pub magic: [u8; 4], pub version: u32, pub name: M2Array<u8>, pub flags: M2ModelFlags, pub global_sequences: M2Array<u32>, pub animations: M2Array<u32>, pub animation_lookup: M2Array<u16>, pub playable_animation_lookup: Option<M2Array<u16>>, pub bones: M2Array<u32>, pub key_bone_lookup: M2Array<u16>, pub vertices: M2Array<u32>, pub views: M2Array<u32>, pub num_skin_profiles: Option<u32>, pub color_animations: M2Array<u32>, pub textures: M2Array<u32>, pub transparency_lookup: M2Array<u16>, pub transparency_animations: M2Array<u32>, pub texture_flipbooks: Option<M2Array<u32>>, pub texture_animations: M2Array<u32>, pub color_replacements: M2Array<u32>, pub render_flags: M2Array<u32>, pub bone_lookup_table: M2Array<u16>, pub texture_lookup_table: M2Array<u16>, pub texture_units: M2Array<u16>, pub transparency_lookup_table: M2Array<u16>, pub texture_animation_lookup: M2Array<u16>, pub bounding_box_min: [f32; 3], pub bounding_box_max: [f32; 3], pub bounding_sphere_radius: f32, pub collision_box_min: [f32; 3], pub collision_box_max: [f32; 3], pub collision_sphere_radius: f32, pub bounding_triangles: M2Array<u32>, pub bounding_vertices: M2Array<u32>, pub bounding_normals: M2Array<u32>, pub attachments: M2Array<u32>, pub attachment_lookup_table: M2Array<u16>, pub events: M2Array<u32>, pub lights: M2Array<u32>, pub cameras: M2Array<u32>, pub camera_lookup_table: M2Array<u16>, pub ribbon_emitters: M2Array<u32>, pub particle_emitters: M2Array<u32>, pub blend_map_overrides: Option<M2Array<u32>>, pub texture_combiner_combos: Option<M2Array<u32>>, pub texture_transforms: Option<M2Array<u32>>,
}
Expand description

M2 model header structure Based on: https://wowdev.wiki/M2#Header

Fields§

§magic: [u8; 4]

Magic signature (“MD20”)

§version: u32

Version of the M2 file

§name: M2Array<u8>

Name of the model

§flags: M2ModelFlags

Flags

§global_sequences: M2Array<u32>

Global sequences

§animations: M2Array<u32>

Animations

§animation_lookup: M2Array<u16>

Animation lookups (C in Classic)

§playable_animation_lookup: Option<M2Array<u16>>

Playable animation lookup - only present in versions <= 263

§bones: M2Array<u32>

Bones

§key_bone_lookup: M2Array<u16>

Key bone lookup

§vertices: M2Array<u32>

Vertices

§views: M2Array<u32>

Views (LOD levels) - M2Array for BC and earlier, count for later versions

§num_skin_profiles: Option<u32>

Number of skin profiles for WotLK+ (when views becomes a count)

§color_animations: M2Array<u32>

Color animations

§textures: M2Array<u32>

Textures

§transparency_lookup: M2Array<u16>

Transparency lookups

§transparency_animations: M2Array<u32>

Transparency animations

§texture_flipbooks: Option<M2Array<u32>>

Texture flipbooks - only present in BC and earlier

§texture_animations: M2Array<u32>

Texture animations

§color_replacements: M2Array<u32>

Color replacements

§render_flags: M2Array<u32>

Render flags

§bone_lookup_table: M2Array<u16>

Bone lookup table

§texture_lookup_table: M2Array<u16>

Texture lookup table

§texture_units: M2Array<u16>

Texture units

§transparency_lookup_table: M2Array<u16>

Transparency lookup table

§texture_animation_lookup: M2Array<u16>

Texture animation lookup table

§bounding_box_min: [f32; 3]

Bounding box min corner

§bounding_box_max: [f32; 3]

Bounding box max corner

§bounding_sphere_radius: f32

Bounding sphere radius

§collision_box_min: [f32; 3]

Collision bounding box min corner

§collision_box_max: [f32; 3]

Collision bounding box max corner

§collision_sphere_radius: f32

Collision bounding sphere radius

§bounding_triangles: M2Array<u32>

Bounding triangles

§bounding_vertices: M2Array<u32>

Bounding vertices

§bounding_normals: M2Array<u32>

Bounding normals

§attachments: M2Array<u32>

Attachments

§attachment_lookup_table: M2Array<u16>

Attachment lookup table

§events: M2Array<u32>

Events

§lights: M2Array<u32>

Lights

§cameras: M2Array<u32>

Cameras

§camera_lookup_table: M2Array<u16>

Camera lookup table

§ribbon_emitters: M2Array<u32>

Ribbon emitters

§particle_emitters: M2Array<u32>

Particle emitters

§blend_map_overrides: Option<M2Array<u32>>

Blend map overrides (BC+ with specific flag)

§texture_combiner_combos: Option<M2Array<u32>>

Texture combiner combos (added in Cataclysm)

§texture_transforms: Option<M2Array<u32>>

Texture transforms

Implementations§

Source§

impl M2Header

Source

pub fn parse<R: Read + Seek>(reader: &mut R) -> Result<Self>

Parse the M2 header from a reader

Source

pub fn write<W: Write>(&self, writer: &mut W) -> Result<()>

Write the M2 header to a writer

Source

pub fn version(&self) -> Option<M2Version>

Get the version of the M2 file

Source

pub fn new(version: M2Version) -> Self

Create a new M2 header for a specific version

Source

pub fn convert(&self, target_version: M2Version) -> Result<Self>

Convert this header to a different version

Trait Implementations§

Source§

impl Clone for M2Header

Source§

fn clone(&self) -> M2Header

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for M2Header

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.