7个版本 (4个稳定版)
1.0.3 | 2024年4月12日 |
---|---|
0.2.0 | 2023年4月21日 |
0.1.1 | 2023年4月20日 |
0.1.0 | 2023年4月18日 |
#632 在 解析器实现 中
每月下载量 87
125KB
1.5K SLoC
picocadrs
这是一个用于处理 picoCAD 项目文件的crate。它支持picoCAD项目的反/序列化以及一些其他有用的方法和函数。
示例
use std::ffi::OsString;
use picocadrs::assets::{Color, Model, Point3D}; // Point3D required for point macro
use picocadrs::point;
// Loads the file "test.txt" located in the picoCAD project folder as a model.
// This model now can access any part of that project.
// For this example test.txt is a new picoCAD project that has a single plane added without
// modifying it saved under the name "test".
let model = Model::load(OsString::from("test")).unwrap();
println!("Model name: {}", model.header.name); // "Model name: test"
println!("Amount of meshes: {}", model.meshes.len()); // "Amount of meshes: 1"
let mesh = model.meshes.get(0).unwrap();
println!("Mesh name: {}", mesh.name); // "Mesh name: plane"
println!("Mesh position: {}", mesh.position); // "Mesh position: 0,0,0"
let face = mesh.faces.get(0).unwrap();
println!("Face color: {}", face.color.as_i32()); // "Face color: 6"
println!("Double sided: {}", face.double_sided); // "Double sided: true"
println!("No texture: {}", face.no_texture); // "No texture: false"
print!("\n");
// Of course, you can change these values too.
let mut model = Model::load(OsString::from("test")).unwrap();
model.header.name = "model_name".to_string();
println!("Model name: {}", model.header.name); // "Model name: model_name"
println!("Amount of meshes: {}", model.meshes.len()); // "Amount of meshes: 1"
let mesh = model.meshes.get_mut(0).unwrap();
mesh.name = "some_plane".to_string();
mesh.position = point!(1.5, -1.0, 2.0);
println!("Mesh name: {}", mesh.name); // "Mesh name: some_plane"
println!("Mesh position: {}", mesh.position); // "Mesh position: 1.5,-1,2"
let face = mesh.faces.get_mut(0).unwrap();
face.color = Color::Lavender;
face.double_sided = false;
face.no_texture = true;
println!("Face color: {}", face.color.as_i32()); // "Face color: 13"
println!("Double sided: {}", face.double_sided); // "Double sided: false"
println!("No texture: {}", face.no_texture); // "No texture: true"
依赖项
~1–11MB
~79K SLoC