16 releases (8 breaking)

0.9.0 Feb 19, 2022
0.8.2 Nov 20, 2021
0.7.0 Nov 20, 2021
0.6.1 Feb 15, 2021
0.1.1 Mar 27, 2020

#1100 in Parser implementations

Download history 138/week @ 2024-02-26

85 downloads per month

MIT/Apache

105KB
2.5K SLoC

PMXUtil

A PMX reader and writer written in Rust

What can this crate do

all of pmx related jobs.

Conformance Test

PMX 2.0 I/O tested by

  1. read original file and write it to another file
  2. compare these file by cargo test
  3. compare these file by WinMerge

WIP

  • improving docs

How to Use

Create reader instance and read

let mut loader= ModelInfoStage::open("/path/to/pmxfile").unwrap();
let header = loader.get_header();
println!("{:#?}", header);
let (model_info, ns) = loader.read_pmx_model_info();
print!("{:#?}", model_info);
let (vertices, ns) =ns.read_pmx_vertices();
print!("{}", vertices);
let (faces, ns) = ns.read_pmx_faces();
println!("{}", faces);
let (textures, ns) = ns.read_texture_list();
println!("{}", textures);
let (materials, ns) = ns.read_pmx_materials();
println!("{:#?}", materials);

Create Writer instance and write

you can choose text encoding UTF-8 or UTF-16LE but MMD only support UTF-16LE.

        use pmx_util::writer::Writer;
        let mut writer =Writer::begin_writer("/path/to/pmxfile").unwrap();
        writer.set_model_info(
            &ModelInfo{
                name:"A Model Name in your local language".to_owned()
                name_en:"A Model Name in english".to_owned()
                comment:"Comment in you local language".to_owned()
                comment_en:"Comment in english".to_owned()
            }
        );
        writer.add_vertices(&vertices);
        writer.add_faces(&faces);
        writer.add_textures(&textures);
        writer.add_materials(&materials);
        writer.add_bones(&bones);
        writer.add_morphs(&morphs);
        Writer::write(writer);

Note

more example for https://github.com/t18b219k/n_pmx_viewer

Dependencies

~3MB
~118K SLoC