public override void Draw(Graphics3D graphics) { System.Drawing.Graphics g = graphics.Graphics; Vector3D viewDir = graphics.ViewDirection; // build pen path Brush brushPath = new SolidBrush(ColorPath); Pen penPath = new Pen(brushPath, 1.7f); // bottom, top Point[] ptsBottom = graphics.TransformPoint(GetBottomPoints()); Point[] ptsTop = graphics.TransformPoint(GetTopPoints()); // outer wall Face[] facesWalls = GetFaceWalls(); foreach (Face face in facesWalls) { try { var normal = face.Normal; // visible ? if (!face.IsVisible(viewDir)) { continue; } // draw polygon Point[] ptsFace = graphics.TransformPoint(face.Points); g.FillPolygon(new SolidBrush(face.ColorGraph(graphics)), ptsFace); } catch (Exception /*ex*/) { } } // top double cosTop = Math.Abs(Vector3D.DotProduct(HalfAxis.ToVector3D(Position.Direction), graphics.VLight)); Color colorTop = Color.FromArgb((int)(Color.R * cosTop), (int)(Color.G * cosTop), (int)(Color.B * cosTop)); Brush brushTop = new SolidBrush(colorTop); bool topVisible = Vector3D.DotProduct(HalfAxis.ToVector3D(Position.Direction), viewDir) < 0; if (topVisible) { g.FillPolygon(brushTop, ptsTop); } else { g.FillPolygon(brushTop, ptsBottom); } }
public override void Draw(Graphics3D graphics) { var g = graphics.Graphics; var viewDir = graphics.ViewDirection; Face[] faces = Faces; for (int i = 0; i < 4; ++i) { // visible ? if (!faces[i].IsVisible(viewDir)) { continue; } // color faces[i].ColorFill = ColorFill; // points Vector3D[] points3D = faces[i].Points; Point[] pt = graphics.TransformPoint(points3D); // draw solid face Brush brush = new SolidBrush(faces[i].ColorGraph(graphics)); g.FillPolygon(brush, pt); // draw path Brush brushPath = new SolidBrush(faces[i].ColorPath); Pen penPathThick = new Pen(brushPath, 1.5f); int ptCount = pt.Length; for (int j = 1; j < ptCount; ++j) { g.DrawLine(penPathThick, pt[j - 1], pt[j]); } g.DrawLine(penPathThick, pt[ptCount - 1], pt[0]); } }
public override void Draw(Graphics3D graphics) { System.Drawing.Graphics g = graphics.Graphics; Vector3D viewDir = graphics.ViewDirection; Vector3D offset = new Vector3D(0.5 * Length, 0.5 * Width, 0.5 * Height); var transf = BoxPosition.Transformation; // draw all triangles foreach (var tri in indices) { try { Vector3D[] pts = new Vector3D[3]; Vector3D normal = Vector3D.Zero; for (int i = 0; i < 3; ++i) { normal += normals[tri[i]]; pts[i] = transf.transform(offset + vertices[tri[i]]); } normal /= 3; normal = transf.transformRot(normal); // visible ? if (Vector3D.DotProduct(viewDir, normal) > 0) { continue; } // draw polygon Point[] ptsTri = graphics.TransformPoint(pts); g.FillPolygon(new SolidBrush(ColorGraph(graphics, normal)), ptsTri); } catch (Exception /*ex*/) { } } }
public override void Draw(Graphics3D graphics) { System.Drawing.Graphics g = graphics.Graphics; var viewDir = graphics.ViewDirection; // draw tray back faces if (null != _packProperties.Tray) { foreach (Face f in TrayFaces) { graphics.Draw( f , Graphics3D.FaceDir.BACK , _packProperties.Tray.Color , false); } } // draw inner boxes if (null == _packProperties.Wrap || _packProperties.Wrap.Type == PackWrapper.WType.WT_POLYETHILENE) { var innerDrawables = InnerDrawables; innerDrawables.Sort(new DrawableComparerSimplifiedPainterAlgo(graphics.GetWorldToEyeTransformation())); foreach (var b in innerDrawables) { b.Draw(graphics); } } if (null != _packProperties.Wrap) { // draw front faces foreach (Face f in Faces) { graphics.Draw( f , Graphics3D.FaceDir.FRONT , _packProperties.Wrap.Color , _packProperties.Wrap.Transparent); } } if (null != _packProperties.Tray) { // draw tray front faces foreach (Face f in TrayFaces) { graphics.Draw( f , Graphics3D.FaceDir.FRONT , _packProperties.Tray.Color , false); } } // draw top points line if (_packProperties.Content is RevSolidProperties) { Color colorTopPoints = (null != _packProperties.Wrap) ? _packProperties.Wrap.Color : Color.White; Pen penTopPoints = new Pen(new SolidBrush(colorTopPoints), 1.5f); var listConvexHull1 = new List <Vector3D>(); foreach (var pt in ConvexHullResult) { listConvexHull1.Add(GlobalTransformation.transform(pt)); } var tPoints = graphics.TransformPoint(listConvexHull1.ToArray()); int tPointCount = tPoints.Length; for (int i = 1; i < tPointCount; ++i) { g.DrawLine(penTopPoints, tPoints[i - 1], tPoints[i]); } g.DrawLine(penTopPoints, tPoints[tPointCount - 1], tPoints[0]); } // draw strappers Pen penBlack = new Pen(new SolidBrush(Color.Black), 1.5f); foreach (var sf in StrapperFaces) { if (sf.IsVisible(viewDir)) { // get color double cosA = Math.Abs(Vector3D.DotProduct(sf.Normal, graphics.VLight)); Color color = Color.FromArgb((int)(sf.ColorFill.R * cosA), (int)(sf.ColorFill.G * cosA), (int)(sf.ColorFill.B * cosA)); // instantiate brush Brush brushStrapper = new SolidBrush(color); // get face points Point[] pts = graphics.TransformPoint(sf.Points); // fill polygon g.FillPolygon(brushStrapper, pts); // draw path int ptCount = pts.Length; for (int j = 1; j < ptCount; ++j) { g.DrawLine(penBlack, pts[j - 1], pts[j]); } g.DrawLine(penBlack, pts[ptCount - 1], pts[0]); } } }
public override void Draw(Graphics3D graphics) { System.Drawing.Graphics g = graphics.Graphics; var viewDir = graphics.ViewDirection; Face[] faces = Faces; for (int i = 0; i < 6; ++i) { // Face Face face = faces[i]; // visible ? if (!faces[i].IsVisible(viewDir)) { continue; } // color faces[i].ColorFill = Colors[i]; // points Vector3D[] points3D = faces[i].Points; Point[] pt = graphics.TransformPoint(points3D); // draw solid face Brush brush = new SolidBrush(faces[i].ColorGraph(graphics)); g.FillPolygon(brush, pt); // draw textures if (null != face.Textures && graphics.ShowTextures) { foreach (Texture texture in face.Textures) { Point[] ptsImage = graphics.TransformPoint(PointsImage(i, texture)); Point[] pts = new Point[3]; pts[0] = ptsImage[3]; pts[1] = ptsImage[2]; pts[2] = ptsImage[0]; g.DrawImage(texture.Bitmap, pts); } } // draw path Brush brushPath = new SolidBrush(faces[i].ColorPath); Pen penPathThick = new Pen(brushPath, IsBundle ? 2.0f : 1.5f); int ptCount = pt.Length; for (int j = 1; j < ptCount; ++j) { g.DrawLine(penPathThick, pt[j - 1], pt[j]); } g.DrawLine(penPathThick, pt[ptCount - 1], pt[0]); // draw bundle lines if (IsBundle && i < 4) { Pen penPathThin = new Pen(brushPath, 1.5f); int noSlice = Math.Min(BundleFlats, 4); for (int iSlice = 0; iSlice < noSlice - 1; ++iSlice) { Vector3D[] ptSlice = new Vector3D[2]; ptSlice[0] = points3D[0] + (iSlice + 1) / (double)noSlice * (points3D[3] - points3D[0]); ptSlice[1] = points3D[1] + (iSlice + 1) / (double)noSlice * (points3D[2] - points3D[1]); Point[] pt2D = graphics.TransformPoint(ptSlice); g.DrawLine(penPathThin, pt2D[0], pt2D[1]); } } } Pen penBlack = new Pen(new SolidBrush(Color.Black), 1.5f); // draw box tape if (ShowTape && faces[5].IsVisible(viewDir)) { // instantiate brush Brush brushTape = new SolidBrush(faces[5].ColorGraph(graphics, TapeColor)); // get tape points Point[] pts = graphics.TransformPoint(TapePoints); // fill polygon g.FillPolygon(brushTape, pts); // draw path for (int j = 1; j < pts.Length; ++j) { g.DrawLine(penBlack, pts[j - 1], pts[j]); } g.DrawLine(penBlack, pts[pts.Length - 1], pts[0]); } // draw strappers foreach (var sf in StrapperFaces) { if (sf.IsVisible(viewDir)) { // get color double cosA = Math.Abs(Vector3D.DotProduct(sf.Normal, graphics.VLight)); Color color = Color.FromArgb((int)(sf.ColorFill.R * cosA), (int)(sf.ColorFill.G * cosA), (int)(sf.ColorFill.B * cosA)); // instantiate brush Brush brushStrapper = new SolidBrush(color); // get face points Point[] pts = graphics.TransformPoint(sf.Points); // fill polygon g.FillPolygon(brushStrapper, pts); // draw path int ptCount = pts.Length; for (int j = 1; j < ptCount; ++j) { g.DrawLine(penBlack, pts[j - 1], pts[j]); } g.DrawLine(penBlack, pts[ptCount - 1], pts[0]); } } if (graphics.ShowBoxIds) { // draw box id Point ptId = graphics.TransformPoint(TopFace.Center); g.DrawString( PickId.ToString() , new Font("Arial", graphics.GridFontSize) , Brushes.Black , new Rectangle(ptId.X - 15, ptId.Y - 10, 30, 20) , StringFormat.GenericDefault); } }