Giter Site home page Giter Site logo

smesh's Introduction

CI crates.io

SMesh

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.

Examples

screenshot use the visualizer example app to interactively explore library features

cargo run --example visualizer

There is also an example for the bevy mesh integration:

cargo run --example bevy_mesh

Usage

Preface: Mesh elements in SMesh are identified by a unique typesafe id, which can be of type: VertexId, HalfedgeId and FaceId.

Mesh creation

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])?;

Mesh queries

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

Mesh operations

Coming soon...

Please check the examples for more :)

Goals

I aim to provide a flexible rust implementation of the Surface Mesh with a focus on usefulness for procedural mesh generation. Other goals are:

  • Ergonomic and easy-to-use api
  • Port most operations from the pmp library and blackjack
  • Support most operations that are possible in modern 3D modeling software like blender
  • Integration with the bevy game engine
  • Target manifold tri & quad meshes for now

smesh's People

Contributors

bendzae avatar

Stargazers

Jela Miraj avatar Joaquín León avatar Nilay Savant avatar Balazs Horvath avatar David Sanders avatar Simon Voordouw avatar Natalie Cuthbert avatar  avatar Marko Lazić avatar Robert Wahler avatar Shane Celis avatar

Watchers

Balazs Horvath avatar  avatar Joaquín León avatar

Forkers

no-materials

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.