public void updateDesign() { if (initShape == null) { initShape = ShapeObject.CreateBasic(); } Polygon pg = new Polygon(boundaryPts); initShape.SetMeshable(pg); if (grammar == null) { grammar = new Grammar(); grammar.inputs.shapes.Add(initShape); grammar.AddRule(new Rules.PivotTurn("A", "A", 2)); grammar.AddRule(new Rules.DivideTo("A", new string[] { "A", "B" }, 30, 2), false); grammar.AddRule(new Rules.DivideTo("A", new string[] { "A", "A" }, 60, 0), false); grammar.AddRule(new Rules.Hide(new string[] { "B" }), false); grammar.AddRule(new Rules.Extrude("A", "A", 30), false); grammar.AddRule(new Rules.CreateBuilding("A", pm3, particleSystem), false); } grammar.Execute(); }
// Use this for initialization void Start() { Vector3[] pts = new Vector3[5]; pts[0] = new Vector3(-80, 0, 46); pts[1] = new Vector3(-80, 0, -11); pts[2] = new Vector3(-10, 0, -54); pts[3] = new Vector3(103, 0, 25); pts[4] = new Vector3(96, 0, 70); Polygon pg = new Polygon(pts); Form f = pg.ExtrudeToForm(new Vector3(0, 30, 0)); Vector3 nml = pts[4] - pts[0]; nml.Normalize(); Plane pln = new Plane(nml, new Vector3()); Meshable[] forms = f.SplitByPlane(pln); ShapeObject so0 = ShapeObject.CreateBasic(); so0.SetMeshable(forms[0]); so0.transform.position -= new Vector3(-20, 0, -20); ShapeObject so1 = ShapeObject.CreateBasic(); so1.SetMeshable(forms[1]); }
public static ShapeObject CreateMeshable(Meshable mb) { ShapeObject so = ShapeObject.CreateBasic(); Vector3 ld = mb.direction; so.SetMeshable(mb, ld); return(so); }
public static ShapeObject CreateMeshable(Meshable mb, Vector3?direction = null) { ShapeObject so = ShapeObject.CreateBasic(); //Debug.Log("direction=" + direction.Value); so.SetMeshable(mb, direction); return(so); }
public static ShapeObject CreatePolygon(Vector3[] pts) { Polygon pg = new Polygon(pts); ShapeObject so = ShapeObject.CreateBasic(); Vector3? ld = PointsBase.LongestDirection(pts); so.SetMeshable(pg, ld); return(so); }
public static ShapeObject CreateExtrusion(Vector3[] pts, float d) { Vector3 magUp = new Vector3(0, d, 0); Polygon pg = new Polygon(pts); Extrusion ext = pg.Extrude(magUp); ShapeObject so = ShapeObject.CreateBasic(); Vector3? ld = PointsBase.LongestDirection(pts); so.SetMeshable(ext, ld); return(so); }
public static ShapeObject CreateExtrusion(Vector3[] pts, float d) { Vector3 magUp = new Vector3(0, d, 0); Polygon pg = new Polygon(pts); Form ext = pg.Extrude(magUp); Debug.Log("ext.verticesCount" + ext.vertices.Length.ToString()); Debug.Log("ext.trianglesCount" + ext.triangles.Length.ToString()); Debug.Log("ext.polygonCount" + ext.components.Count.ToString()); ShapeObject so = ShapeObject.CreateBasic(); Vector3? ld = PointsBase.LongestDirection(pts); so.SetMeshable(ext, ld); return(so); }