Skip to content

Commit c2a8e2d

Browse files
committed
Update README.md
1 parent 57d8d40 commit c2a8e2d

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ If you prefer to read example code immediately, you can find example scenes in [
2222
+ [Segment-Segment intersection point](Scenes/README.md/#8-segment-segment-intersection-point)
2323
+ [Polygon offset](Scenes/README.md/#9-polygon-offset)
2424
+ [Multiple polygon centroid](Scenes/README.md/#10-multiple-polygon-centroid)
25+
+ [Polygon triangulation](Scenes/README.md/#11-polygon-triangulation)
2526

2627
## Model classes
2728

@@ -100,6 +101,22 @@ The library uses namespaces heavily. I like to **name things as they are**. An e
100101
+ `Path ClipperPath(this Polygon this_, float scale)`
101102
+ `Vector2[] PointsFromClipperPath(Path path, float scale)`
102103

104+
* [`TriangleNetAddOns`](AddOns/TriangleNetAddOns.cs)
105+
106+
+ Bridges the gap between library `Model.Polygon` objects and `Triangle.NET` models (meshes, voronoi diagrams).
107+
+ `TriangleNet.Geometry.Polygon TriangleNetPolygon(this Polygon this_)`
108+
+ `Rect Bounds(this TriangleNet.Voronoi.Legacy.SimpleVoronoi this_)`
109+
+ `Paths ClipperPathsFromVoronoiRegions(List<TriangleNet.Voronoi.Legacy.VoronoiRegion> voronoiRegions, float scale = 1.0f)`
110+
+ `Vector2 VectorFromPoint(TriangleNet.Geometry.Point point)`
111+
+ `Vector2[] PointsFromVertices(ICollection<TriangleNet.Geometry.Point> vertices)`
112+
113+
* [`UnityEngineAddOns`](AddOns/UnityEngineAddOns.cs)
114+
115+
+ Contains a single `Model.Polygon` (yet enormously useful) extension that triangulates the corresponding polygon, and hooks up the result into a `UnityEngine.MeshFilter` component. This is the core functionality embedded into `Source.Mesh` component (see example scene [Polygon triangulation](Scenes/README.md/#11-polygon-triangulation) for more).
116+
+ `UnityEngine.Mesh Mesh(this EPPZ.Geometry.Model.Polygon this_, string name = "")`
117+
+ `UnityEngine.Mesh Mesh(this EPPZ.Geometry.Model.Polygon this_, TriangulatorType triangulator, string name = "")`
118+
+ `UnityEngine.Mesh Mesh(this EPPZ.Geometry.Model.Polygon this_, Color color, TriangulatorType triangulator, string name = "")`
119+
103120
## License
104121

105122
> Licensed under the [**MIT License**](https://en.wikipedia.org/wiki/MIT_License).
File renamed without changes.

Scenes/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
+ [Segment-Segment intersection point](#8-segment-segment-intersection-point)
1515
+ [Polygon offset](#9-polygon-offset)
1616
+ [Multiple polygon centroid](#10-multiple-polygon-centroid)
17+
+ [Polygon triangulation](#11-polygon-triangulation)
1718

1819
These test scenes are designed to experience / proof the **eppz! Geometry** library features. Hit play, then manipulate the geometry in Scene window while in game mode (watch out to move the points directly instead their parent container). Every relevant code is in the corresponding `Controller_#.cs`, so you can see **how to use the API**.
1920

@@ -168,6 +169,16 @@ centroid.position = Geometry.CentroidOfPolygons(polygons));
168169
```
169170
See [`Controller_10.cs`](Controllers/Controller_10.cs) for the full script context.
170171

172+
## 11. Polygon triangulation
173+
174+
This scene uses a `Source.Mesh` component to simply **triangluate a polygon**. If both `Source.Polygon` and `UnityEngine.MeshFilter` component is present on a `GameObject`, you can use this setup. It uses an extension method `Polygon.Mesh()` that hooks up `Triangle.NET` mesh output into a `UnityEngine.MeshFilter` (with some additional issue resolved regarding self intersecting polygons).
175+
176+
```C#
177+
// Assign trianglated mesh.
178+
meshFilter.mesh = polygon.Mesh(color, triangulator);
179+
```
180+
See [`Source/Mesh.cs`](Source/Mesh.cs) source for the details.
181+
171182
## License
172183

173184
> Licensed under the [**MIT License**](https://en.wikipedia.org/wiki/MIT_License).

0 commit comments

Comments
 (0)