Crates.io | wow-m2 |
lib.rs | wow-m2 |
version | 0.3.2 |
created_at | 2025-06-14 01:44:28.809976+00 |
updated_at | 2025-08-29 04:00:57.039031+00 |
description | Parser, validator, and converter for World of Warcraft M2 model files with animation support |
homepage | https://github.com/wowemulation-dev/warcraft-rs |
repository | https://github.com/wowemulation-dev/warcraft-rs |
max_upload_size | |
id | 1712029 |
size | 366,823 |
A Rust library for parsing, validating, and converting World of Warcraft M2 model files.
wow-m2
provides comprehensive support for M2 model files across all World of Warcraft expansions from Classic (1.12.1) through The War Within (11.x). The library handles:
.m2
/.mdx
) - 3D character, creature, and object models.skin
) - Level-of-detail and submesh information.anim
) - External animation sequencesAdd to your Cargo.toml
:
[dependencies]
wow-m2 = "0.3.0"
Or use cargo add:
cargo add wow-m2
use wow_m2::{M2Model, M2Version, M2Converter};
// Load a model
let data = std::fs::read("path/to/model.m2")?;
let mut cursor = std::io::Cursor::new(data);
let model = M2Model::parse(&mut cursor)?;
// Print basic information
println!("Model version: {:?}", model.header.version());
println!("Vertices: {}", model.vertices.len());
println!("Bones: {}", model.bones.len());
// Convert to a different version
let converter = M2Converter::new();
let converted = converter.convert(&model, M2Version::WotLK)?;
// Save the converted model
let output_data = converted.write_to_bytes()?;
std::fs::write("path/to/converted.m2", output_data)?;
use wow_m2::Skin;
// Load a skin file
let data = std::fs::read("path/to/model00.skin")?;
let mut cursor = std::io::Cursor::new(data);
let skin = Skin::parse(&mut cursor)?;
// Access submesh information
for submesh in &skin.submeshes {
println!("Submesh {}: {} vertices, {} triangles",
submesh.id, submesh.vertex_count, submesh.triangle_count);
}
The library supports parsing versions by both numeric format and expansion names:
use wow_m2::M2Version;
// Using version numbers
let version = M2Version::from_string("3.3.5a")?; // WotLK
// Using expansion names
let version = M2Version::from_expansion_name("wotlk")?;
let version = M2Version::from_expansion_name("MoP")?;
Expansion | Version Range | Support |
---|---|---|
Classic | 1.12.x | ✅ Full |
TBC | 2.4.x | ✅ Full |
WotLK | 3.3.x | ✅ Full |
Cataclysm | 4.3.x | ✅ Full |
MoP | 5.4.x | ✅ Full |
WoD | 6.2.x | ✅ Full |
Legion | 7.3.x | ✅ Full |
BfA | 8.3.x | ✅ Full |
Shadowlands | 9.x | ✅ Full |
Dragonflight | 10.x | ✅ Full |
The War Within | 11.x | ✅ Full |
See the examples/
directory for more detailed examples:
convert_model.rs
- Convert models between versionsanalyze_model.rs
- Analyze model structure and contentsvalidate_model.rs
- Validate model integrityLicensed under either of:
at your option.
See CONTRIBUTING.md for guidelines.