AddCone() public method

Adds a cone.
public AddCone ( System.Windows.Media.Media3D.Point3D origin, System.Windows.Media.Media3D.Point3D apex, double baseRadius, bool baseCap, int thetaDiv ) : void
origin System.Windows.Media.Media3D.Point3D The origin point.
apex System.Windows.Media.Media3D.Point3D The apex point.
baseRadius double The base radius.
baseCap bool /// Include a base cap if set to true . ///
thetaDiv int The theta div.
return void
示例#1
0
        public static MeshGeometry3D GetPointedMesh(Tool tool, Point3D position, Vector3D direction)
        {
            var t       = tool as PointedTool;
            var builder = new HelixToolkit.Wpf.MeshBuilder();
            var p1      = position + direction * t.StraightLength;
            var p2      = position + direction * (t.StraightLength + t.ConeHeight);

            builder.AddCylinder(position, p1, t.Diameter / 2.0);
            builder.AddCone(p1, p2, t.Diameter / 2.0, false, 20);

            return(builder.ToMesh());
        }
示例#2
0
        public static MeshGeometry3D GetCountersinkMesh(Tool tool, Point3D position, Vector3D direction)
        {
            const double hSvasatore = 10.0;
            var          t          = tool as CountersinkTool;
            var          builder    = new HelixToolkit.Wpf.MeshBuilder();
            var          p1         = position + direction * (t.Length1 - hSvasatore);
            var          p12        = position + direction * t.Length1;
            var          p2         = position + direction * (t.Length1 + t.Length2);
            var          p3         = position + direction * (t.Length1 + t.Length2 + t.Length3);

            builder.AddCylinder(position, p1, t.Diameter1 / 2.0);
            builder.AddCylinder(p1, p12, t.Diameter2 / 2.0);
            builder.AddCone(p12, direction, t.Diameter2 / 2.0, t.Diameter1 / 2.0, t.Length2, false, false, 20);
            builder.AddCylinder(p2, p3, t.Diameter1 / 2.0);

            return(builder.ToMesh());
        }
 /// <summary>
 /// Do the tessellation and return the <see cref="MeshGeometry3D"/>.
 /// </summary>
 /// <returns>A triangular mesh geometry.</returns>
 protected override MeshGeometry3D Tessellate()
 {
     var builder = new MeshBuilder(false, true);
     builder.AddCone(
         this.Origin,
         this.Normal,
         this.BaseRadius,
         this.TopRadius,
         this.Height,
         this.BaseCap,
         this.TopCap,
         this.ThetaDiv);
     return builder.ToMesh();
 }
示例#4
0
        protected override MeshGeometry3D Tessellate()
        {
            double width = Columns*grid - margin*2;
            double length = Rows*grid - margin*2;
            double height = Height*plateThickness;
            var builder = new MeshBuilder(true, true);

            for (int i = 0; i < Columns; i++)
                for (int j = 0; j < Rows; j++)
                {
                    var o = new Point3D((i + 0.5)*grid, (j + 0.5)*grid, height);
                    builder.AddCone(o, new Vector3D(0, 0, 1), knobDiameter/2, knobDiameter/2, knobHeight, false, true,
                                    Divisions);
                    builder.AddPipe(new Point3D(o.X, o.Y, o.Z - wallThickness), new Point3D(o.X, o.Y, wallThickness),
                                    knobDiameter, outerDiameter, Divisions);
                }

            builder.AddBox(new Point3D(Columns * 0.5 * grid, Rows * 0.5 * grid, height - wallThickness / 2), width, length,
                          wallThickness,
                          MeshBuilder.BoxFaces.All);
            builder.AddBox(new Point3D(margin + wallThickness / 2, Rows * 0.5 * grid, height / 2 - wallThickness / 2),
                           wallThickness, length, height - wallThickness,
                           MeshBuilder.BoxFaces.All ^ MeshBuilder.BoxFaces.Top);
            builder.AddBox(
                new Point3D(Columns * grid - margin - wallThickness / 2, Rows * 0.5 * grid, height / 2 - wallThickness / 2),
                wallThickness, length, height - wallThickness,
                MeshBuilder.BoxFaces.All ^ MeshBuilder.BoxFaces.Top);
            builder.AddBox(new Point3D(Columns * 0.5 * grid, margin + wallThickness / 2, height / 2 - wallThickness / 2),
                           width, wallThickness, height - wallThickness,
                           MeshBuilder.BoxFaces.All ^ MeshBuilder.BoxFaces.Top);
            builder.AddBox(
                new Point3D(Columns * 0.5 * grid, Rows * grid - margin - wallThickness / 2, height / 2 - wallThickness / 2),
                width, wallThickness, height - wallThickness,
                MeshBuilder.BoxFaces.All ^ MeshBuilder.BoxFaces.Top);

            return builder.ToMesh();
        }
示例#5
0
        private void AddBranch(MeshBuilder mesh, Point3D p0, Vector3D direction, int p)
        {
            double angle = GetAngleBetween(direction, UpVector);
            bool isStem = angle < 10;

            double h = isStem ? 2.5 : 2;
            double r = (Level+1-p)*0.1;

            mesh.AddCone(p0, direction, r, r * 0.8, h, false, false, 12);
            var p1 = p0 + direction*h;

            if (p == Level)
                return;

            if (isStem)
            {
                var rightVector=direction.FindAnyPerpendicular();
                var t0 = new RotateTransform3D(new AxisAngleRotation3D(rightVector, GetRandom(3)));
                AddBranch(mesh, p1, t0.Transform(direction), p + 1);

                var t1 = new RotateTransform3D(new AxisAngleRotation3D(rightVector, 95 + GetRandom(5)));
                var d1 = t1.Transform(direction);
                int nBranches = 5+GetRandom(2);
                for (int i = 0; i < nBranches; i++)
                {
                    double a = 360.0 * i / nBranches + GetRandom(25);
                    var t2 = new RotateTransform3D(new AxisAngleRotation3D(UpVector, a));
                    AddBranch(mesh, p1, t2.Transform(d1), p + 1);
                }
            } else
            {
                var rightVector=Vector3D.CrossProduct(direction, UpVector);
                var t1 = new RotateTransform3D(new AxisAngleRotation3D(rightVector, -5 + GetRandom(5)));
                var t2 = new RotateTransform3D(new AxisAngleRotation3D(UpVector, 45+GetRandom(10)));
                var t3 = new RotateTransform3D(new AxisAngleRotation3D(UpVector, -45 + GetRandom(10)));
                var d1 = t1.Transform(direction);
                AddBranch(mesh, p1, d1, p + 1);
                AddBranch(mesh, p1, t2.Transform(d1), p + 1);
                AddBranch(mesh, p1, t3.Transform(d1), p + 1);
            }
        }
示例#6
0
文件: 3DView.cs 项目: litdev1/LitDev
        /// <summary>
        /// Add a cone geometry object pointing up with base centred at (0,0,0).
        /// Note a cylinder is a cone with baseRadius = topRadius.
        /// </summary>
        /// <param name="shapeName">The 3DView object.</param>
        /// <param name="baseRadius">The radius of the base.</param>
        /// <param name="topRadius">The radius of the top  if truncated (default 0).</param>
        /// <param name="height">The height of the cone.</param>
        /// <param name="divisions">The number of divisions for the cone (default 18).</param>
        /// <param name="colour">A colour or gradient brush for the object.</param>
        /// <param name="materialType">A material for the object.
        /// The available options are:
        /// "E" Emmissive - constant brightness.
        /// "D" Diffusive - affected by lights.
        /// "S" Specular  - specular highlights.
        /// </param>
        /// <returns>The 3DView Geometry name.</returns>
        public static Primitive AddCone(Primitive shapeName, Primitive baseRadius, Primitive topRadius, Primitive height, Primitive divisions, Primitive colour, Primitive materialType)
        {
            UIElement obj;

            try
            {
                if (_objectsMap.TryGetValue((string)shapeName, out obj))
                {
                    InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
                    {
                        try
                        {
                            if (obj.GetType() == typeof(Viewport3D))
                            {
                                MeshBuilder builder = new MeshBuilder(true, true);
                                builder.AddCone(new Point3D(0, 0, 0), new Vector3D(0, 1, 0), baseRadius, topRadius, height, true, true, divisions);
                                MeshGeometry3D mesh = builder.ToMesh();

                                Viewport3D viewport3D = (Viewport3D)obj;
                                return AddGeometry(viewport3D, mesh.Positions, mesh.TriangleIndices, mesh.Normals, mesh.TextureCoordinates, colour, materialType);
                            }
                        }
                        catch (Exception ex)
                        {
                            Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                        }
                        return "";
                    });
                    return FastThread.InvokeWithReturn(ret).ToString();
                }
                else
                {
                    Utilities.OnShapeError(Utilities.GetCurrentMethod(), shapeName);
                }
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
            return "";
        }