#procedural #modeling #mesh #graphics #gamedev #2d-3d

procedural_modelling

A framework-agnostic Procedural Modelling crate

3 releases

0.1.2 Apr 1, 2024
0.1.1 Apr 1, 2024
0.1.0 Feb 28, 2024

#33 in Rendering

Download history 146/week @ 2024-02-28 6/week @ 2024-03-06 27/week @ 2024-03-13 4/week @ 2024-03-20 185/week @ 2024-03-27 77/week @ 2024-04-03

267 downloads per month

MIT/Apache

370KB
3.5K SLoC

Procedural Modelling

Build Status GitHub Repo stars Lines of Code

A Framework-Agnostic Procedural Modelling Library.

Uses a datastructure based on half-edge meshes to represent (open) manifold meshes with optional non-manifold vertices. Our goal is to implement operations like Boolean Operations, Subdivisions, Curved Surfaces, and Stitching. The library aims to support the tesselation of 2d surfaces in a modular way that can be used without any of the 3d features.

Currently there are quite a few crates that implement boolean operations and tesselation to achieve some other goal. We want to provide a common implementation to satisfy these very similar requirements and improve code-reuse among these projects so they can focus on their original goal.

WARNING

This crate is still in a very early stage of development. Expect frequent API modifications, bugs, and missing features. Feel free to contribute by opening issues, pull requests or sharing your ideas in Github Discussion.

Usage

drawing

Install using cargo add procedural_modelling.

let mut mesh = MeshVec3::regular_star(1.0, 0.8, 30);
mesh.transform(
    &Transform::from_translation(Vec3::new(0.0, -0.99, 0.0))
               .with_rotation(Quat::from_rotation_z(PI)),
);
let trans = Transform::from_rotation(Quat::from_rotation_y(0.3))
                      .with_translation(Vec3::new(0.4, 0.3, 0.0));
let mut f = mesh.extrude_ex(mesh.edge_between(1, 0).unwrap().id(), trans, true, true);
for _ in 0..5 {
    f = mesh.extrude_face_ex(f, trans, true, true);
}
mesh.to_bevy(RenderAssetUsages::default())

Examples

Or run the examples on your computer like, e.g., cargo run --features="bevy" --profile fast-dev --example box.

For package development, we recommend using the editor-subcrate. This example has a little egui-editor. Run it using cargo watch -w editor/src -w src -x "run -p editor --profile fast-dev". The fast-dev profile will enable optimizations for the dependencies, but not for the package itself. This will slow down the first build significantly, but incremental builds are slightly faster and bevy's performance (bevy is used as the renderer in the examples) improves a lot.

Feature Progress

  • Attributes
    • Positions
    • Normals
    • Smooth Surface Groups
    • Tangents
    • UV Coordinates
    • Custom Attributes
  • Triangulation
    • [(x)] Montone Sweep-Line
    • Constrained Delaunay (using Delaunator)
  • Primitives
    • Polygon, Star
    • Cuboid
    • Cylinder, Cone, Frustum, Tetrahedron, Octahedron
    • Dodecahedron, Icosahedron
    • UV Sphere
    • Cube Sphere
    • Icosphere
    • Torus
  • Builder Primitives
    • Lines
    • Quadratic Bezier Curves
    • Cubic Bezier Curves
    • Curved Surfaces (Bezier Surfaces / Parametric Surfaces / NURBS / Spline Networks...?)
  • Operations
    • Extrude
    • Loft
    • Inset
    • Plane Intersection
    • Union
    • Intersection
    • Difference
    • Symmetric Difference
    • (Anisotropic) Simplification / LODs
    • Stitching
    • Subdivision
    • Morphing
    • Voxelization
  • Tools
    • Geodesic Pathfinding
    • Raycasting
    • Topology Analysis
    • Spatial Data Structures
  • Debug Visualizations
    • Indices
    • Normals
    • Tangents
    • Topology
  • Backends
    • Bevy
    • wgpu

Features

The following features are available:

  • meshopt -- Use Meshopt to optimize the performance of generated meshes.
  • bevy -- Compiles with support for bevy. Necessary for the examples and the editor.

License

Except where noted (below and/or in individual files), all code in these repositories is dual-licensed, allowing you the flexibility to choose between:

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~43–84MB
~1.5M SLoC