### 28 releases

0.6.2 | Jun 8, 2018 |
---|---|

0.5.0 | May 29, 2017 |

0.4.1 | Sep 5, 2016 |

0.4.0 | Dec 28, 2015 |

0.0.1 | Nov 21, 2014 |

**4,896** downloads per month

Used in **41** crates (17 directly)

**Apache-2.0**

59KB

1.5K
SLoC

# 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 `genmesh`

trait. A pipeline stage is a lazy iterator the consumes the input, and produces a new polygon based on the stage.`Iterator`

This also provides some

for creating primitives at runtime.`generators`

**Currently supported stages**

maps a function to each vertex in a polygon`vertex`

triangles Quads to Triangles`triangulate`

turns a poly pipeline into a vertices pipeline`vertices`

**Primitive generators**

`Cone``Cube``Cylinder``Plane``SphereUV``Torus`

**Vertex attributes**

: position`pos`

: normal`normal`

**Utility**

translate a vertex into a index, emitting a new vertex if the current vertex is not in the`LruIndexer`

cache.`Lru`

work with mesh as a whole by querying normals and neighbors on either vertex or polygon levels.`Neighbors`

**Primitives**

`Triangle``Quad`

an enum of both`Polygon`

and`Triangle``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

generates six faces, one per side this is presented as a `Cube`

.`Quad <Vertex3<f32>>`

maps a function to each vertex in each face, in this case we want to convert from `vertex`

's internal vertex format to our own. We now have a `genmes`

.`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`

will convert the `triangulate`

to a `Quad <MyVertex>`

`Triangle``<`MyVertex`>``>`

. This will produce two polygons and six vertices. Some of the verticies are cloned in order to complete this operation.

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

is a standard Iterator operation.`collect`

#### Dependencies

~1MB

~15K SLoC