File tree Expand file tree Collapse file tree 5 files changed +57
-1
lines changed
Expand file tree Collapse file tree 5 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 11# eppz! ` Geometry `
22
3+ * 1.0.1
4+
5+ + Test scenes
6+ + `11. Polygon triangulation (1)`
7+ + `11. Polygon triangulation (2)`
8+ + `Polygon.UpdatePointPositionsWithSource()`
9+ + Update child transforms
10+
311* 1.0.0
412
513 + Triangulation
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ public static Polygon PolygonWithSource(Source.Polygon polygonSource)
6868 {
6969 Polygon rootPolygon = Polygon . PolygonWithPointTransforms ( polygonSource . points , polygonSource . coordinates ) ;
7070
71- // Collect sub-olygons if any.
71+ // Collect sub-polygons if any.
7272 foreach ( Transform eachChildTransform in polygonSource . gameObject . transform )
7373 {
7474 GameObject eachChildGameObject = eachChildTransform . gameObject ;
@@ -161,6 +161,17 @@ public Polygon(int pointCount = 1)
161161 public void UpdatePointPositionsWithSource ( Source . Polygon polygonSource ) // Assuming unchanged point count
162162 {
163163 UpdatePointPositionsWithTransforms ( polygonSource . points , polygonSource . coordinates ) ;
164+
165+ // Update sub-polygons if any.
166+ foreach ( Transform eachChildTransform in polygonSource . gameObject . transform )
167+ {
168+ GameObject eachChildGameObject = eachChildTransform . gameObject ;
169+ Source . Polygon eachChildPolygonSource = eachChildGameObject . GetComponent < Source . Polygon > ( ) ;
170+ if ( eachChildPolygonSource != null )
171+ {
172+ eachChildPolygonSource . polygon . UpdatePointPositionsWithTransforms ( eachChildPolygonSource . points , eachChildPolygonSource . coordinates ) ;
173+ }
174+ }
164175 }
165176
166177 public void UpdatePointPositionsWithTransforms ( Transform [ ] pointTransforms , Source . Polygon . Coordinates coordinates ) // Assuming unchanged point count
Original file line number Diff line number Diff line change 1+ using UnityEngine ;
2+ using System . Collections ;
3+ using System . Collections . Generic ;
4+
5+
6+ namespace EPPZ . Geometry . Source
7+ {
8+
9+
10+ /// <summary>
11+ /// Utility component to create point transforms from mesh vertices
12+ /// suitable to feed data into `Source.Polygon.points` component.
13+ /// </summary>
14+ [ ExecuteInEditMode ]
15+ public class Points : MonoBehaviour
16+ {
17+
18+
19+ public float scale = 0.1f ;
20+
21+
22+ [ ContextMenu ( "Create" ) ]
23+ void Create ( )
24+ {
25+ int index = 1 ;
26+ foreach ( Vector3 eachVertex in GetComponent < MeshFilter > ( ) . mesh . vertices )
27+ {
28+ GameObject point = GameObject . CreatePrimitive ( PrimitiveType . Sphere ) ;
29+ point . transform . parent = transform ;
30+ point . transform . localPosition = eachVertex ;
31+ point . transform . localScale = Vector3 . one * scale ;
32+ point . name = "Point " + index . ToString ( "00" ) ;
33+ index ++ ;
34+ }
35+ }
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments