bool isInSegment(Points p, Points p2, Points p3, Util.eView view) { float delta = 10f; Points p0 = (Points)p2.Clone(); Points p1 = (Points)p3.Clone(); p0.X += centerPoint.X; p1.X += centerPoint.X; p0.Y += centerPoint.Y; p1.Y += centerPoint.Y; p0.Z += centerPoint.Z; p1.Z += centerPoint.Z; if (view == Util.eView.x) { return(_isInSegment(delta, p.Y, p.Z, p0.Y, p0.Z, p1.Y, p1.Z)); } if (view == Util.eView.y) { return(_isInSegment(delta, p.X, p.Z, p0.X, p0.Z, p1.X, p1.Z)); } if (view == Util.eView.z) { return(_isInSegment(delta, p.X, p.Y, p0.X, p0.Y, p1.X, p1.Y)); } return(false); }
private void draw_points(Image b, Viewport vp, bool selected, Util.eView view) { var points_f = new Point[points.Count]; var g = System.Drawing.Graphics.FromImage(b); for (var i = 0; i < points_f.Length; i++) { Points t = (Points)points[i].Clone(); t.X += centerPoint.X; t.Y += centerPoint.Y; t.Z += centerPoint.Z; Util.convertToGe(t, vp, b, view); if (view == Util.eView.x) { points_f[i] = new Point(t.Y, t.Z); } if (view == Util.eView.y) { points_f[i] = new Point(t.X, t.Z); } if (view == Util.eView.z) { points_f[i] = new Point(t.X, t.Y); } } using (var pen = new Pen((selected ? System.Drawing.Color.White : Color.toColor()))) { for (var id = 0; id < points_f.Length; id++) { g.DrawLine(pen, points_f[id], points_f[(id + 1 >= points_f.Length ? 0 : id + 1)]); } } }
bool isInWireframe(Points p, Util.eView view) { if (isInSegment(p, points[0], points[1], view) || isInSegment(p, points[1], points[2], view) || isInSegment(p, points[2], points[3], view) || isInSegment(p, points[3], points[0], view)) { return(true); } return(false); }
private void draw_points(Image b, Viewport vp, bool selected, Util.eView view) { var points_f1 = new Point[points_top.Count]; var points_f2 = new Point[points_bottom.Count]; var g = System.Drawing.Graphics.FromImage(b); for (var i = 0; i < points_f1.Length; i++) { Points t1 = (Points)points_top[i].Clone(); Points t2 = (Points)points_bottom[i].Clone(); t1.X += centerPoint.X; t1.Y += centerPoint.Y; t1.Z += centerPoint.Z; t2.X += centerPoint.X; t2.Y += centerPoint.Y; t2.Z += centerPoint.Z; Util.convertToGe(t1, vp, b, view); Util.convertToGe(t2, vp, b, view); if (view == Util.eView.x) { points_f1[i] = new Point(t1.Y, t1.Z); } if (view == Util.eView.y) { points_f1[i] = new Point(t1.X, t1.Z); } if (view == Util.eView.z) { points_f1[i] = new Point(t1.X, t1.Y); } if (view == Util.eView.x) { points_f2[i] = new Point(t2.Y, t2.Z); } if (view == Util.eView.y) { points_f2[i] = new Point(t2.X, t2.Z); } if (view == Util.eView.z) { points_f2[i] = new Point(t2.X, t2.Y); } } using (var pen = new Pen((selected ? System.Drawing.Color.White : Color.toColor()))) { for (var id = 0; id < points_f1.Length; id++) { g.DrawLine(pen, points_f1[id], points_f2[id]); } g.DrawClosedCurve(pen, points_f1); g.DrawClosedCurve(pen, points_f2); } }
bool isInWireframe(Points p, Util.eView view) { if (isInSegment(p, points_top[0], points_bottom[0], view)) { return(true); } for (var i = 1; i < points_top.Count; i++) { if (isInSegment(p, points_top[i - 1], points_top[i], view) || isInSegment(p, points_bottom[i - 1], points_bottom[i], view) || isInSegment(p, points_bottom[i], points_top[i], view)) { return(true); } } return(false); }
private bool drawTmpObject(MouseEventArgs e, Points p3, Util.eView v) { draw_status.Text = "Coords { X : " + p3.X + ", Y : " + p3.Y + ", Z : " + p3.Z + " }"; if (e.Button == System.Windows.Forms.MouseButtons.Left && this.drawMode < eDrawMode.NONE) { var vx = new System.Drawing.Bitmap(view_x_cp, view_x_cp.Size); var vy = new System.Drawing.Bitmap(view_y_cp, view_y_cp.Size); var vz = new System.Drawing.Bitmap(view_z_cp, view_z_cp.Size); Type object_type = null; switch (this.drawMode) { case eDrawMode.SPHERE: object_type = typeof(Sphere); break; case eDrawMode.CYLINDER: object_type = typeof(Cylinder); break; case eDrawMode.LIGHT: object_type = typeof(Light); break; case eDrawMode.CONE: object_type = typeof(Cone); break; case eDrawMode.PLAN: object_type = typeof(Plan); break; } if (object_type == null) { return(false); } if (_tmpObject != null) { if (v == Util.eView.x) { _tmpObject.Radius = (int)Math.Sqrt(Math.Pow(p3.Y - _tmpObject.centerPoint.Y, 2) + Math.Pow(p3.Z - _tmpObject.centerPoint.Z, 2)); } if (v == Util.eView.y) { _tmpObject.Radius = (int)Math.Sqrt(Math.Pow(p3.X - _tmpObject.centerPoint.X, 2) + Math.Pow(p3.Z - _tmpObject.centerPoint.Z, 2)); } if (v == Util.eView.z) { _tmpObject.Radius = (int)Math.Sqrt(Math.Pow(p3.X - _tmpObject.centerPoint.X, 2) + Math.Pow(p3.Y - _tmpObject.centerPoint.Y, 2)); } } else { if (v == Util.eView.x) { _tmpObject = object_type.GetMethod("create_x").Invoke(null, new object[] { (Points)p1.Clone(), (Points)p3.Clone(), vp, true }) as AObjects; } if (v == Util.eView.y) { _tmpObject = object_type.GetMethod("create_y").Invoke(null, new object[] { (Points)p1.Clone(), (Points)p3.Clone(), vp, true }) as AObjects; } if (v == Util.eView.z) { _tmpObject = object_type.GetMethod("create_z").Invoke(null, new object[] { (Points)p1.Clone(), (Points)p3.Clone(), vp, true }) as AObjects; } } draw_status.Text += ", " + object_type.ToString() + " { Cx : " + _tmpObject.centerPoint.X + ", Cy : " + _tmpObject.centerPoint.Y + ", Cz : " + _tmpObject.centerPoint.Z + ", R : " + _tmpObject.Radius + " }"; _tmpObject.Refresh(); _tmpObject.draw_x(vx, vp, true); _tmpObject.draw_y(vy, vp, true); _tmpObject.draw_z(vz, vp, true); view_x.Image = vx; view_y.Image = vy; view_z.Image = vz; return(true); } return(false); }