public void UnitMode() { Debug.LogFormat("mode==unit:{0},lastMode==unit:{1}", this.mode == DisplayMode.UNIT, this.lastMode == DisplayMode.UNIT); if (this.lastMode != DisplayMode.UNIT) { Debug.Log("re execute " + grammars[0].name); this.lastMode = DisplayMode.UNIT; this.mode = DisplayMode.UNIT; grammars[0].Execute(); Debug.Log("finish reExecute"); return; } mode = DisplayMode.UNIT; foreach (ShapeObject o in grammars[0].stagedOutputs[grammars[0].stagedOutputs.Count - 1].shapes) { o.Show(false); } if (unitSOS == null) { unitSOS = new List <ShapeObject>(); } //if (unitSOS == null || unitSOS.Count<1) return; if (units == null || units.Count < 1) { return; } int dif = unitSOS.Count - units[0].Count; if (dif > 0) { SGUtility.RemoveExtraShapeObjects(ref unitSOS, dif); } for (int i = 0; i < units[0].Count; i++) { if (i >= unitSOS.Count) { unitSOS.Add(ShapeObject.CreateBasic()); } Meshable m = (Meshable)units[0][i].Clone(); SGUtility.ScaleForm(m, new Vector3(0.9f, 0.7f, 1f), Alignment.Center3D); unitSOS[i].SetMeshable(m); unitSOS[i].Show(true); } }
// Use this for initialization void Start() { Vector3[] pts = new Vector3[] { new Vector3(), new Vector3(30, 0, -5), new Vector3(50, 0, 0), new Vector3(50, 0, 20), new Vector3(0, 0, 20), }; Polygon pg = new Polygon(pts); ShapeObject.CreateMeshable(pg); Extrusion ext = pg.Extrude(new Vector3(0, 20, 0)); ShapeObject refo = ShapeObject.CreateMeshable(ext); refo.transform.Translate(new Vector3(0, 20, 0)); ext.bbox = BoundingBox.CreateFromPoints(ext.vertices, new Vector3(1, 0, 0)); //ShapeObject.CreateMeshable(ext); //Meshable[] mbs = SGUtility.DivideFormByCount(ext, 3, 0); Meshable[] mbs = SGUtility.DivideFormToLength(ext, 10, 0); int counter = 0; foreach (Meshable mb in mbs) { if (mb.bbox == null) { throw new System.Exception("null bbox"); } SGUtility.ScaleForm(mb, new Vector3(0.9f, 0.3f, 0.9f), Alignment.Center3D); ShapeObject so = ShapeObject.CreateMeshable(mb); //so.transform.Translate(new Vector3(counter*1, 10, 0)); counter += 1; } }