A high-performance parser for Valve Map Format (VMF) files written in Rust.
VMF (Valve Map Format) is a text-based file format used by Source Engine level editors like Hammer to store map data. This library provides a fast, memory-efficient parser.
- Version information and metadata
- World geometry (solids, brushes, sides)
- Entities (point entities, brush entities)
- Displacement surfaces (terrain)
- Visibility groups
- View settings
- Cameras
- Cordons
[dependencies]
mnk_vmf = "0.1.0"use mnk_vmf::VMF;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open and parse a VMF file
let vmf = VMF::open("map.vmf")?;
let data = vmf.parse()?;
// Iterate through parsed blocks
for value in data {
match value {
VMFValue::World(world) => {
println!("World contains {} solids", world.solids.len());
}
VMFValue::Entity(entity) => {
println!("Entity: {:?}", entity.classname);
}
_ => {}
}
}
Ok(())
}use mnk_vmf::{VMF, VMFValue};
let vmf = VMF::open("map.vmf")?;
let data = vmf.parse()?;
for value in data {
if let VMFValue::World(world) = value {
for solid in &world.solids {
println!("Solid ID: {}", solid.id);
for side in &solid.sides {
println!(" Material: {}", side.material);
println!(" Plane: {:?}", side.plane);
}
}
}
}cargo build --releasecargo testnote: This crate uses over 150 tests, and almost everything is covered.
cargo benchLicensed under either of
- Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (http://opensource.org/licenses/MIT)
at your option.
Contributions are welcome! Please feel free to submit issues or pull requests.