• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library of mesh generation utilities.

Genmesh

Build Status Docs Crates.io

genmesh is a library for building vertex pipelines. The goal is help facilitate polygon assembly. This is done by building on top of the of the Iterator trait. A pipeline stage is a lazy iterator the consumes the input, and produces a new polygon based on the stage.

This also provides some generators for creating primitives at runtime.

Currently supported stages

  • vertex maps a function to each vertex in a polygon
  • triangulate triangles Quads to Triangles
  • vertices turns a poly pipeline into a vertices pipeline

Primitive generators

  • Cone
  • Cube
  • Cylinder
  • Plane
  • SphereUV
  • Torus

Vertex attributes

  • pos: position
  • normal: normal

Utility

  • LruIndexer translate a vertex into a index, emitting a new vertex if the current vertex is not in the Lru cache.
  • Neighbors work with mesh as a whole by querying normals and neighbors on either vertex or polygon levels.

Primitives

  • Triangle
  • Quad
  • Polygon an enum of both Triangle and Quad

Example

    let vertex_data: Vec<MyVertex> = Cube::new()
        .vertex(|v| MyVertex::new(v.pos, [0., 0.]))
        .map(|Quad{x: v0, y: v1, z: v2, w: v3}| {
            Quad::new(MyVertex::new(v0.a_Pos, [0., 0.]),
                      MyVertex::new(v1.a_Pos, [1., 0.]),
                      MyVertex::new(v2.a_Pos, [1., 1.]),
                      MyVertex::new(v3.a_Pos, [0., 1.]))
        })
        .triangulate()
        .vertices()
        .collect();

Here Cube generates six faces, one per side this is presented as a Quad<Vertex3<f32>>.

vertex maps a function to each vertex in each face, in this case we want to convert from genmes's internal vertex format to our own. We now have a Quad<MyVertex>>.

We can do a polygon level transform and modify the polygon as a whole. In the example we add a valid texture coordinate to each face. Since genmesh is just an extension of iterators we can do a polygon level transform using just map.

triangulate will convert the Quad<MyVertex> to a Triangle<MyVertex>>. This will produce two polygons and six vertices. Some of the verticies are cloned in order to complete this operation.

verticies now unwraps each triangle and returns the vertices in-order. This will obviously produce 3 results for each polygon.

collect is a standard Iterator operation.

More Repositories

1

wgpu

A cross-platform, safe, pure-Rust graphics API.
Rust
12,115
star
2

gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
Rust
5,350
star
3

wgpu-rs

Rust bindings to wgpu native library
Rust
1,690
star
4

naga

Universal shader translation in Rust
Rust
1,530
star
5

wgpu-native

Native WebGPU implementation based on wgpu-core
Rust
836
star
6

metal-rs

Rust bindings for Metal
Rust
567
star
7

rspirv

Rust implementation of SPIR-V module processing functionalities
Rust
442
star
8

portability

Vulkan Portability Implementation
C
383
star
9

gfx-ocean

Compute based ocean simulation with gfx_hal 🌊
Rust
116
star
10

meetup

Rust Graphics meetups
68
star
11

d3d12-rs

Rust wrapper for D3D12
Rust
36
star
12

gfx-memory

[DEPRECATED] Memory management library of gfx_hal
Rust
26
star
13

gfx-extras

DEPRECATED: Extra libraries to help working with gfx-hal
Rust
21
star
14

nv-flip-rs

Bindings to Nvidia Labs's ꟻLIP image comparison and error visualization library
Rust
19
star
15

wgpu-rs.github.io

Hosting for wgpu.rs website
HTML
17
star
16

gfx-render

Rust
16
star
17

gfx-rs.github.io

Blog for the gfx-rs project
HTML
15
star
18

gfx_scene

deprecated
Rust
15
star
19

gfx_gl

An OpenGL loader tailored to gfx-rs's needs.
Rust
14
star
20

wanari

Khronos ANARI implementation in Rust based on wgpu-rs
Rust
9
star
21

range-alloc

Rust
6
star
22

draw_state

deprecated
Rust
6
star
23

subscriber

Tracing subscribers to help with wgpu
Rust
5
star
24

gfx_macros

deprecated
Rust
4
star
25

stories

wgpu stories blog
Ruby
4
star
26

cherry

Fork of Android Cherry tool for Vulkan CTS tracking
Go
2
star
27

ci-build

Automated action for building/hosting components we need in CI
2
star