Crates.io | smesh |
lib.rs | smesh |
version | |
source | src |
created_at | 2024-06-22 11:43:17.359632 |
updated_at | 2024-12-22 11:00:06.963229 |
description | A fast and ergonomic surface-mesh/halfedge-mesh implementation and polygon mesh manipulation library based on pmp |
homepage | |
repository | https://github.com/Bendzae/SMesh |
max_upload_size | |
id | 1280394 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
[!CAUTION] Library is still work in progress
SMesh is a polygon mesh manipulation library based on the Surface Mesh data structure and the pmp library and the halfedge-mesh implementation of the blackjack project.
The libary uses a slotmap based implementation of the Surface Mesh which takes heavy inspiration from blackjacks halfedge-mesh implementation.
The goal of this library is to provide a flexible mesh abstraction and set of operations to be used for procedural modeling and procedural generation of 3D meshes.
parameterized procedural mesh generation
cargo run --example tree
mesh extrusion and manipulation example with the visual debug tools enabled
cargo run --example extrude
Preface: Mesh elements in SMesh are identified by a unique typesafe id, which can be of type:
VertexId
, HalfedgeId
and FaceId
.
SMesh has a simple api to add vertices to your mesh and connect them to faces: Add vertices
let mut smesh = SMesh::new();
let v0 = smesh.add_vertex(vec3(-1.0, -1.0, 0.0)); // Returns a unique VertexId
let v1 = smesh.add_vertex(vec3(1.0, -1.0, 0.0));
let v2 = smesh.add_vertex(vec3(1.0, 1.0, 0.0));
let v3 = smesh.add_vertex(vec3(-1.0, 1.0, 0.0));
Build face
smesh.add_face(vec![v0, v1, v2, v3])?;
SMesh provides a chainable api to query mesh elements using the typical halfedge-mesh relationships:
get outgoing halfedge of a vertex
let outgoing_halfedge_query = v0.halfedge(); // returns a MeshQueryBuilder<HalfedgeId>
you can execute the query on a smesh instance by using .run(&smesh)
let outgoing_halfedge = v0.halfedge().run(&smesh)?; // returns a HalfedgeId
chaining queries
let vertex = v0.halfedge_to(v1).cw_rotated_neighbour().dst_vert().run(&smesh)?; // returns a VertexId
Coming soon...
Please check the examples for more :)
I aim to provide a flexible rust implementation of the Surface Mesh with a focus on usefulness for procedural mesh generation. Other goals are: