当前位置: 首页>>代码示例>>C#>>正文


C# MeshBuilder.AddSphere方法代码示例

本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddSphere方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddSphere方法的具体用法?C# MeshBuilder.AddSphere怎么用?C# MeshBuilder.AddSphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HelixToolkit.Wpf.MeshBuilder的用法示例。


在下文中一共展示了MeshBuilder.AddSphere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DemoElement3D

        public DemoElement3D()
        {
            var gm = new GeometryModel3D();
            var mb = new MeshBuilder();
            mb.AddSphere(new Point3D(0, 0, 0), 2, 100, 50);
            gm.Geometry = mb.ToMesh();
            gm.Material = Materials.Blue;

            Visual3DModel = gm;
        }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:10,代码来源:DemoElement3D.cs

示例2: AddGroup

 public void AddGroup(List<int> selectedVertex)
 {
     MeshBuilder mesh = new MeshBuilder(false, false);
     foreach (int index in selectedVertex)
         mesh.AddSphere(this.Points[index], pointRaduis);
     var mesh1 = mesh.ToMesh(true);
     var redMaterial = MaterialHelper.CreateMaterial(Colors.Red);
     var insideMaterial = MaterialHelper.CreateMaterial(Colors.Yellow);
     
     // Add 3 models to the group (using the same mesh, that's why we had to freeze it)
     mg.Children.Add(new GeometryModel3D { Geometry = mesh1, Material = redMaterial, BackMaterial = insideMaterial });
 }
开发者ID:chantsunman,项目名称:RobustGeometry.NET,代码行数:12,代码来源:MainViewModel.cs

示例3: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            var container = new ContainerUIElement3D();
            var element = new ModelUIElement3D();
            var geometry = new GeometryModel3D();
            var meshBuilder = new MeshBuilder();
            meshBuilder.AddSphere(new Point3D(0, 0, 0), 2, 100, 50);
            geometry.Geometry = meshBuilder.ToMesh();
            geometry.Material = Materials.Green;
            element.Model = geometry;
            element.Transform = new TranslateTransform3D(5, 0, 0);
            element.MouseDown += this.ContainerElementMouseDown;
            container.Children.Add(element);
            view1.Children.Add(container);
        }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:17,代码来源:MainWindow.xaml.cs

示例4: ToModel3D

        public Model3D ToModel3D()
        {
            var m = new Model3DGroup();

            TriangleIndexToPanelIndex = new List<int>();

            // Add the triangles
            var tm = new MeshBuilder(false, false);
            int panelIndex = 0;
            foreach (var p in Panels)
            {
                p.TriangleIndex = tm.Positions.Count;
                tm.AddTriangleFan(p.Points);
                for (int i = 0; i < p.Points.Length - 2; i++) TriangleIndexToPanelIndex.Add(panelIndex);
                panelIndex++;
            }
            var panelsGeometry = tm.ToMesh();
            m.Children.Add(new GeometryModel3D(panelsGeometry, Materials.Red) { BackMaterial = Materials.Blue });

            // Add the nodes
            var gm = new MeshBuilder();
            foreach (var p in panelsGeometry.Positions)
            {
                gm.AddSphere(p, 0.05);
            }
            m.Children.Add(new GeometryModel3D(gm.ToMesh(), Materials.Gold));

            // Add the edges
            var em = new MeshBuilder();
            foreach (var p in Panels)
            {
                for (int i = 0; i < p.Points.Length; i += 1)
                {
                    em.AddCylinder(p.Points[i], p.Points[(i + 1) % p.Points.Length], 0.05, 10);
                }
            }
            m.Children.Add(new GeometryModel3D(em.ToMesh(), Materials.Gray));

            return m;
        }
开发者ID:dermeister0,项目名称:helix-toolkit,代码行数:40,代码来源:PanelModelBuilder.cs

示例5: Sphere

        public Sphere(Point3D center, double radius, IEnumerable<CutingPlane> cutingPlanes)
        {
            Center = center;
            Radius = radius;
            CutingPlanes  = new List<CutingPlane>();

            if (cutingPlanes != null)
            {
                CutingPlanes.AddRange(cutingPlanes);
            }

            var meshBuilder = new MeshBuilder(false, false);
            meshBuilder.AddSphere(center, radius, 25, 15);
            var m = meshBuilder.ToMesh();

            foreach (var plane3D in CutingPlanes)
            {
                Point3D p = plane3D.Point;
                Vector3D n = -1*plane3D.Vector;

                m = MeshGeometryHelper.Cut(m, p, n);
            }
            Model = m;
        }
开发者ID:rsemenov,项目名称:cave,代码行数:24,代码来源:Sphere.cs

示例6: UpdateModel

        private void UpdateModel()
        {
            // http://en.wikipedia.org/wiki/Lorenz_attractor
            Func<double[], double[]> lorenzAttractor = x =>
                                                           {
                                                               var dx = new double[3];
                                                               dx[0] = sigma * (x[1] - x[0]);
                                                               dx[1] = x[0] * (rho - x[2]) - x[1];
                                                               dx[2] = x[0] * x[1] - beta * x[2];
                                                               return dx;
                                                           };
            // solve the ODE
            var x0 = new[] { 0, 1, 1.05 };
            IEnumerable<double[]> solution = EulerSolver(lorenzAttractor, x0, 25);
            // todo: should have a better ODE solver (R-K(4,5)? http://www.mathworks.com/help/techdoc/ref/ode45.html)
            List<Point3D> path = solution.Select(x => new Point3D(x[0], x[1], x[2])).ToList();

            // create the WPF3D model
            var m = new Model3DGroup();
            var gm = new MeshBuilder();
            gm.AddTube(path, 0.8, 10, false);
            if (directionArrows)
            {
                // sphere at the initial point
                gm.AddSphere(path[0], 1);
                // arrow heads every 100 point
                for (int i = 100; i + 1 < path.Count; i += 100)
                {
                    gm.AddArrow(path[i], path[i + 1], 0.8);
                }
                // arrow head at the end
                Point3D p0 = path[path.Count - 2];
                Point3D p1 = path[path.Count - 1];
                var d = new Vector3D(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
                d.Normalize();
                Point3D p2 = p1 + d * 2;
                gm.AddArrow(p1, p2, 0.8);
            }

            m.Children.Add(new GeometryModel3D(gm.ToMesh(), Materials.Gold));

            Model = m;
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:43,代码来源:MainViewModel.cs

示例7: Tessellate

 /// <summary>
 /// Do the tesselation and return the <see cref="MeshGeometry3D"/>.
 /// </summary>
 /// <returns>A triangular mesh geometry.</returns>
 protected override MeshGeometry3D Tessellate()
 {
     var builder = new MeshBuilder(true, true);
     builder.AddSphere(this.Center, this.Radius, this.ThetaDiv, this.PhiDiv);
     return builder.ToMesh();
 }
开发者ID:sivarajankumar,项目名称:dentalsmile,代码行数:10,代码来源:SphereVisual3D.cs

示例8: SetToVisual

        /// <summary>
        /// Creates a rather ugly visual representatino of the polyline.
        /// Fixed in size with respect to the model.
        /// </summary>
        /// <param name="highlighted">The destination visual component to replace the content of.</param>
        internal void SetToVisual(MeshVisual3D highlighted)
        {
            if (_geomPoints == null)
                return;

            var lines = new LinesVisual3D { Color = Colors.Yellow };
            var axesMeshBuilder = new MeshBuilder();

            List<Point3D> path = new List<Point3D>();
            foreach (var item in _geomPoints)
            {
                axesMeshBuilder.AddSphere(item.Point, 0.1);
                path.Add(item.Point);
            }
            if (_geomPoints.Count > 1)
            {
                double lineThickness = 0.05;
                axesMeshBuilder.AddTube(path, lineThickness, 9, false);
            }
            highlighted.Content = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.Yellow);
        }
开发者ID:tnesser,项目名称:XbimWindowsUI,代码行数:26,代码来源:PolylineGeomInfo.cs

示例9: BuildJoint

        /// <summary>
        /// Build a joint for drawing
        /// </summary>
        /// <param name="joint">Joint</param>
        /// <returns>Joint created</returns>
        private GeometryModel3D BuildJoint(Joint joint)
        {
            MeshBuilder jointBuilder = new MeshBuilder();
            jointBuilder.AddSphere(new Point3D(0, 0, 0), jointDiameter, thetaDiv, 10);

            GeometryModel3D jointModel = new GeometryModel3D(jointBuilder.ToMesh(), Materials.Red);
            jointModel.SetName(joint.Name);

            MatrixTransform3D transform = new MatrixTransform3D(joint.Matrix.ElementAtOrDefault(Session.CurrentSession.CurrentProject.CurrentModel3D.Animation.Tick));
            jointModel.Transform = transform;

            return jointModel;
        }
开发者ID:loic-lavergne,项目名称:mckineap,代码行数:18,代码来源:SkeletonConverter.cs

示例10: SkeletonFrameReady_Draw3D

        //TODO: refactor into more methods
        private void SkeletonFrameReady_Draw3D(ModelVisual3D modelVisual3D, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
              {
            // Get tracked skeleton data from stream, return if no data
            if (skeletonFrame == null)
            {
              modelVisual3D.Content = null;
              return;
            }

            Skeleton[] skeletons = new Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength];
            skeletonFrame.CopySkeletonDataTo(skeletons);

            Skeleton skeleton = skeletons.FirstOrDefault(s => s.TrackingState == SkeletonTrackingState.Tracked);
            if (skeleton == null)
            {
              modelVisual3D.Content = null;
              return;
            }

            // Waist coordinates will be origin
            SkeletonPoint centroid = skeleton.Joints[JointType.HipCenter].Position;

            // Init 3D stuff
            Model3DGroup modelGroup = new Model3DGroup();
            MeshBuilder meshBuilder = new MeshBuilder(false, false);

            // Init dict to tidy up code
            Dictionary<JointType, Point3D> jd = new Dictionary<JointType, Point3D>();

            // Add joints to mesh while populating the dict
            foreach (Joint j in skeleton.Joints)
            {
              // Helix3D has a different coordinate system
              int y = (int)((j.Position.X - centroid.X) * 100);
              int z = (int)((j.Position.Y - centroid.Y) * 100);
              int x = (int)((centroid.Z - j.Position.Z) * 100);
              Point3D center = new Point3D { X = x, Y = y, Z = z };
              jd[j.JointType] = center;
              meshBuilder.AddSphere(center, 5);
            }

            // Add bones to mesh
            meshBuilder.AddCylinder(jd[JointType.Head], jd[JointType.ShoulderCenter], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.ShoulderCenter], jd[JointType.Spine], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.Spine], jd[JointType.HipCenter], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.HipCenter], jd[JointType.HipLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.HipLeft], jd[JointType.KneeLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.KneeLeft], jd[JointType.AnkleLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.AnkleLeft], jd[JointType.FootLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.HipCenter], jd[JointType.HipRight], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.HipRight], jd[JointType.KneeRight], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.KneeRight], jd[JointType.AnkleRight], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.AnkleRight], jd[JointType.FootRight], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.ShoulderCenter], jd[JointType.ShoulderLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.ShoulderLeft], jd[JointType.ElbowLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.ElbowLeft], jd[JointType.WristLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.WristLeft], jd[JointType.HandLeft], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.ShoulderCenter], jd[JointType.ShoulderRight], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.ShoulderRight], jd[JointType.ElbowRight], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.ElbowRight], jd[JointType.WristRight], 6, 10);
            meshBuilder.AddCylinder(jd[JointType.WristRight], jd[JointType.HandRight], 6, 10);

            var mesh = meshBuilder.ToMesh(true); // Create and freeze mesh
            Material blueMaterial = MaterialHelper.CreateMaterial(Colors.SteelBlue); // Create material
            modelGroup.Children.Add(new GeometryModel3D(mesh, blueMaterial)); // Create model

            // Draw
            modelVisual3D.Content = modelGroup;
              }
        }
开发者ID:birbilis,项目名称:Hotspotizer,代码行数:73,代码来源:MainWindow.KinectUtils.cs

示例11: CreateModel

        /// <summary>
        /// This function creates the model
        /// </summary>
        /// <returns>A created plot model</returns>
        private Model3D CreateModel()
        {
            var plotModel = new Model3DGroup();
            if (Points == null || Points.Count == 0) return plotModel;

            double minX = Points.Min(p => p.X);
            double maxX = Points.Max(p => p.X);
            double minY = Points.Min(p => p.Y);
            double maxY = Points.Max(p => p.Y);
            double minZ = Points.Min(p => p.Z);
            double maxZ = Points.Max(p => p.Z);
            double minValue = 0;
            double maxValue = 10000;

            var valueRange = maxValue - minValue;

            var scatterMeshBuilder = new MeshBuilder(true, true);

            var oldTCCount = 0;
            for (var i = 0; i < Points.Count; ++i)
            {
                scatterMeshBuilder.AddSphere(Points[i], SphereSize, 4, 4);

                var newTCCount = scatterMeshBuilder.TextureCoordinates.Count;
                oldTCCount = newTCCount;
            }

            var scatterModel = new GeometryModel3D(scatterMeshBuilder.ToMesh(),
                                                   MaterialHelper.CreateMaterial(SurfaceBrush, null, null, 1, 0));
            scatterModel.BackMaterial = scatterModel.Material;

            // create bounding box with axes indications
            var axesMeshBuilder = new MeshBuilder();
            for (double x = minX; x <= maxX; x += IntervalX)
            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D(x.ToString(), Brushes.White, true, FontSize,
                                                                           new Point3D(x, minY - FontSize * 2.5, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }

            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D("X-axis", Brushes.White, true, FontSize,
                                                                           new Point3D((minX + maxX) * 0.5,
                                                                                       minY - FontSize * 6, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }

            for (double y = minY; y <= maxY; y += IntervalY)
            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D(y.ToString(), Brushes.White, true, FontSize,
                                                                           new Point3D(minX - FontSize * 3, y, minZ),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 1, 0));
                plotModel.Children.Add(label);
            }
            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Y-axis", Brushes.White, true, FontSize,
                                                                           new Point3D(minX - FontSize * 10,
                                                                                       (minY + maxY) * 0.5, minZ),
                                                                           new Vector3D(0, 1, 0), new Vector3D(-1, 0, 0));
                plotModel.Children.Add(label);
            }
            double z0 = (int)(minZ / IntervalZ) * IntervalZ;
            for (double z = z0; z <= maxZ + double.Epsilon; z += IntervalZ)
            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D(z.ToString(), Brushes.White, true, FontSize,
                                                                           new Point3D(minX - FontSize * 3, maxY, z),
                                                                           new Vector3D(1, 0, 0), new Vector3D(0, 0, 1));
                plotModel.Children.Add(label);
            }
            {
                GeometryModel3D label = TextCreator.CreateTextLabelModel3D("Z-axis", Brushes.White, true, FontSize,
                                                                           new Point3D(minX - FontSize * 10, maxY,
                                                                                       (minZ + maxZ) * 0.5),
                                                                           new Vector3D(0, 0, 1), new Vector3D(1, 0, 0));
                plotModel.Children.Add(label);
            }

            var bb = new Rect3D(minX, minY, minZ, maxX - minX, maxY - minY, maxZ - minZ);
            axesMeshBuilder.AddBoundingBox(bb, LineThickness);

            var axesModel = new GeometryModel3D(axesMeshBuilder.ToMesh(), Materials.White);

            plotModel.Children.Add(scatterModel);
            plotModel.Children.Add(axesModel);

            return plotModel;
        }
开发者ID:JohnsonNicholas,项目名称:aetherum-navigator,代码行数:93,代码来源:ScatterPlot3D.cs

示例12: Tessellate

 /// <summary>
 /// The tessellate.
 /// </summary>
 /// <returns>The mesh.</returns>
 protected override MeshGeometry3D Tessellate()
 {
     var builder = new MeshBuilder(false, true);
     builder.AddSphere(new Point3D(0, 0, 0), 1.0, this.ThetaDiv, this.PhiDiv);
     builder.Scale(this.RadiusX, this.RadiusY, this.RadiusZ);
     return builder.ToMesh();
 }
开发者ID:BEEden,项目名称:Diplomarbeit,代码行数:11,代码来源:EllipsoidVisual3D.cs

示例13: CreateEnemyModel

        private Model3DGroup CreateEnemyModel(string EnemyType, Color color)
        {
            Model3DGroup EnemyModel = null;
            if (EnemyType.Contains("#"))
            {
                MeshBuilder b = new MeshBuilder();
                if (EnemyType.Contains("box"))
                {
                    b.AddBox(new Point3D(1, 1, 1), 40, 40, 40);
                }
                else
                if (EnemyType.Contains("sphere"))
                {
                    b.AddSphere(new Point3D(1, 1, 1), 40);
                }

                var Mesh = b.ToMesh();
                var GeometryModel = new GeometryModel3D { Geometry = Mesh };

                ModelVisual3D ModelVisual = new ModelVisual3D();
                ModelVisual.Content = GeometryModel;
                EnemyModel = new Model3DGroup();
                EnemyModel.Children.Add(ModelVisual.Content);
            }
            else
            {
                EnemyModel = importer.Load(EnemyType.ToString(), null, false);
            }

            foreach (var Child in EnemyModel.Children)
            {
                var Model = ((GeometryModel3D)Child);
                Model.Material = MaterialHelper.CreateMaterial(color);
            }

            return EnemyModel;
        }
开发者ID:BujakiAttila,项目名称:LanguageBoosterGame,代码行数:37,代码来源:LevelManager.cs

示例14: AddPoints

 private void AddPoints(IEnumerable<SurveyPoint> surveyPoints)
 {
     ViewPort.Children.Remove(_pointsVisual);
     var meshBuilder = new MeshBuilder();
     foreach (var current in surveyPoints) {
         var point = new Point3D {
             X = current.CalibrationPoint.X * ScaleFactor / _maxCoord,
             Y = current.CalibrationPoint.Y * ScaleFactor / _maxCoord,
             Z = current.CalibrationPoint.Z * ScaleFactor / _maxCoord
         };
         meshBuilder.AddSphere(point, PointRadius);
     }
     var modelVisual = new ModelVisual3D {
         Content = new GeometryModel3D {
             Geometry = meshBuilder.ToMesh(),
             Material = PointVisual3DMaterial.BlackMaterial
         }
     };
     ViewPort.Children.Add(modelVisual);
     _pointsVisual = modelVisual;
 }
开发者ID:saktanorovich,项目名称:survey-calibration,代码行数:21,代码来源:SurveySpaceReview.xaml.cs

示例15: AddSphere

        /// <summary>
        /// Add a sphere geometry object centred on (0,0,0).
        /// </summary>
        /// <param name="shapeName">The 3DView object.</param>
        /// <param name="radius">The sphere radius.</param>
        /// <param name="divisions">The sphere divisions, default 10 (affects number of triangles and smoothness).</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 AddSphere(Primitive shapeName, Primitive radius, 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);
                                Point3D center = new Point3D(0, 0, 0);
                                int phiDiv = divisions < 2 ? 10 : (int)divisions;
                                int thetaDiv = 2 * phiDiv;
                                builder.AddSphere(center, radius, thetaDiv, phiDiv);
                                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 "";
        }
开发者ID:litdev1,项目名称:LitDev,代码行数:58,代码来源:3DView.cs


注:本文中的HelixToolkit.Wpf.MeshBuilder.AddSphere方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。