/// <summary> /// Update polygons from the given points. (happens once) /// </summary> public void UpdatePolygons() { // Init list if required if (polygons == null) { polygons = new List <Polygon3D>(); } // reset list polygons.Clear(); // Add center and scale to all points foreach (Point3D p in points.Values) { p.x *= Scale; p.y *= Scale; p.z *= Scale; p.x += Pivot.x; p.y += Pivot.y; p.z += Pivot.z; } // Create triangular polygons for each face of the box Point3D[] top1 = { points["tlb"], points["tlf"], points["trf"] }; Point3D[] top2 = { points["tlb"], points["trf"], points["trb"] }; Point3D[] bot1 = { points["brb"], points["brf"], points["blf"] }; Point3D[] bot2 = { points["brb"], points["blf"], points["blb"] }; Point3D[] right1 = { points["trf"], points["brf"], points["brb"] }; Point3D[] right2 = { points["trf"], points["brb"], points["trb"] }; Point3D[] left1 = { points["tlb"], points["blb"], points["blf"] }; Point3D[] left2 = { points["tlb"], points["blf"], points["tlf"] }; Point3D[] front1 = { points["tlf"], points["blf"], points["brf"] }; Point3D[] front2 = { points["tlf"], points["brf"], points["trf"] }; Point3D[] back1 = { points["trb"], points["brb"], points["blb"] }; Point3D[] back2 = { points["trb"], points["blb"], points["tlb"] }; // Apply box rotation Transformations.Transformation x = new Transformations.Rotate(); x.Transform(this, new Point3D(rotation.x, rotation.y, rotation.z)); // Create polygons and add to list polygons.Add(new Polygon3D(top1, System.Drawing.Color.Black, System.Drawing.Color.Red)); polygons.Add(new Polygon3D(top2, System.Drawing.Color.Black, System.Drawing.Color.Red)); polygons.Add(new Polygon3D(bot1, System.Drawing.Color.Black, System.Drawing.Color.Blue)); polygons.Add(new Polygon3D(bot2, System.Drawing.Color.Black, System.Drawing.Color.Blue)); polygons.Add(new Polygon3D(right1, System.Drawing.Color.Black, System.Drawing.Color.DarkViolet)); polygons.Add(new Polygon3D(right2, System.Drawing.Color.Black, System.Drawing.Color.DarkViolet)); polygons.Add(new Polygon3D(left1, System.Drawing.Color.Black, System.Drawing.Color.Purple)); polygons.Add(new Polygon3D(left2, System.Drawing.Color.Black, System.Drawing.Color.Purple)); polygons.Add(new Polygon3D(front1, System.Drawing.Color.Black, System.Drawing.Color.Magenta)); polygons.Add(new Polygon3D(front2, System.Drawing.Color.Black, System.Drawing.Color.Magenta)); polygons.Add(new Polygon3D(back1, System.Drawing.Color.Black, System.Drawing.Color.Salmon)); polygons.Add(new Polygon3D(back2, System.Drawing.Color.Black, System.Drawing.Color.Salmon)); }
/// <summary> /// Creates polygons for the pyramid /// </summary> public void UpdatePolygons() { // init polygon list if required if (polygons == null) { polygons = new List <Polygon3D>(); } // clear list polygons.Clear(); // Apply scale and center to points foreach (Point3D p in points.Values) { p.x *= Scale; p.y *= Scale; p.z *= Scale; p.x += Pivot.x; p.y += Pivot.y; p.z += Pivot.z; } // Create point arrays for triangular polygons Point3D[] top1 = { points["top"], points["bbl"], points["bfc"] }; Point3D[] top2 = { points["top"], points["bbr"], points["bbl"] }; Point3D[] top3 = { points["top"], points["bfc"], points["bbr"] }; Point3D[] base1 = { points["bfc"], points["bbl"], points["bbr"] }; // apply shape rotation Transformations.Transformation x = new Transformations.Rotate(); x.Transform(this, new Point3D(rotation.x, rotation.y, rotation.z)); // create and save polygons in list polygons.Add(new Polygon3D(top1, System.Drawing.Color.Black, System.Drawing.Color.Red)); polygons.Add(new Polygon3D(top2, System.Drawing.Color.Black, System.Drawing.Color.DarkSlateGray)); polygons.Add(new Polygon3D(top3, System.Drawing.Color.Black, System.Drawing.Color.DarkViolet)); polygons.Add(new Polygon3D(base1, System.Drawing.Color.Black, System.Drawing.Color.DarkGreen)); }