Crate partio [] [src]

partio

Rust implementation of the C++ library partio (copyright 2010-2011 Disney Enterprises, Inc. All rights reserved).

See https://github.com/wdas/partio for the original source code repository.

This is the initial source code release of partio a tool we used for particle reading/writing.

Class Model

The goal of the library is to abstract the particle interface from the data representation. That is why Partio represents particles using three classes that inherit and provide more functionality

Using partio

extern crate partio;

use partio::DataWriter;

fn make_data() -> partio::ParticlesSimple {
    // use builder to create defaults
    let builder: partio::ParticlesSimpleBuilder = partio::ParticlesSimpleBuilder::new();
    let mut foo: partio::ParticlesSimple = builder.finalize();
    // add attributes
    foo.add_attribute("position", partio::ParticleAttributeType::VECTOR, 3);
    foo.add_attribute("life", partio::ParticleAttributeType::FLOAT, 2);
    foo.add_attribute("id", partio::ParticleAttributeType::INT, 1);
    // add some particle data
    for i in 0..5 {
        let index: partio::ParticleIndex = foo.add_particle();
        // position
        let pos_0: f64 = 0.1_f64 * (i + 0) as f64;
        let pos_1: f64 = 0.1_f64 * (i + 1) as f64;
        let pos_2: f64 = 0.1_f64 * (i + 2) as f64;
        foo.data_write(&pos_0);
        foo.data_write(&pos_1);
        foo.data_write(&pos_2);
        // life
        let life_0: f64 = -1.2_f64 + i as f64;
        let life_1: f64 = 10.0_f64;
        foo.data_write(&life_0);
        foo.data_write(&life_1);
        // id
        let ref mut id: u64 = index as u64;
        foo.data_write(&id);
    }
    foo // return
}

fn test_save_load(p: &partio::ParticlesSimple, filename: &str) {
    println!("Testing with file '{}'", filename);
    match p.write(filename) {
        Ok(_) => println!("{} written", filename),
        Err(err) => println!("Error: {:?}", err),
    }
}

fn main() {
    let foo: partio::ParticlesSimple = make_data();
    println!("{:?}", foo);
    test_save_load(&foo, "test.bgeo");
}

Structs

FixedAttribute
ParticleAttribute
ParticlesSimple
ParticlesSimpleBuilder

Enums

ParticleAttributeType

Traits

DataWriter

Type Definitions

ParticleIndex