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


C# MeshBuilder.AddSubdivisionSphere方法代码示例

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


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

示例1: UpdateVisuals

        /// <summary>
        /// Updates the visuals.
        /// </summary>
        protected void UpdateVisuals()
        {
            if (this.Mesh == null)
            {
                this.Content = null;
                return;
            }

            var m = new Model3DGroup();

            this.TriangleIndexToFaceIndex = new List<int>();
            var faceGeometry = this.Mesh.ToMeshGeometry3D(
                this.SharedVertices, this.ShrinkFactor, this.TriangleIndexToFaceIndex);
            m.Children.Add(
                new GeometryModel3D(faceGeometry, this.FaceMaterial) { BackMaterial = this.FaceBackMaterial });

            // Add the nodes
            if (this.VertexRadius > 0)
            {
                var gm = new MeshBuilder(false, false);
                foreach (var p in this.Mesh.Vertices)
                {
                    gm.AddSubdivisionSphere(p, this.VertexRadius, this.VertexResolution);

                    // gm.AddBox(p, VertexRadius, VertexRadius, VertexRadius);
                }

                m.Children.Add(new GeometryModel3D(gm.ToMesh(), this.VertexMaterial));
            }

            // Add the edges
            if (this.EdgeDiameter > 0)
            {
                var em = new MeshBuilder(false, false);
                //// int fi = 0;
                foreach (var p in this.Mesh.Faces)
                {
                    //// var n = this.Mesh.GetFaceNormal(fi++);
                    for (int i = 0; i < p.Length; i += 1)
                    {
                        var p0 = this.Mesh.Vertices[p[i]];
                        var p1 = this.Mesh.Vertices[p[(i + 1) % p.Length]];
                        em.AddCylinder(p0, p1, this.EdgeDiameter, 4);
                    }
                }

                m.Children.Add(new GeometryModel3D(em.ToMesh(), this.EdgeMaterial));
            }

            this.Content = m;
        }
开发者ID:ORRNY66,项目名称:helix-toolkit,代码行数:54,代码来源:MeshVisual3D.cs

示例2: UpdateVisuals

        /// <summary>
        /// Updates the visuals.
        /// </summary>
        protected void UpdateVisuals()
        {
            this.vertexVisuals = new Dictionary<HalfEdgeMesh.Vertex, ModelUIElement3D>();
            this.halfEdgeVisuals = new Dictionary<HalfEdgeMesh.HalfEdge, ModelUIElement3D>();
            this.faceVisuals = new Dictionary<HalfEdgeMesh.Face, ModelUIElement3D>();
            this.Children.Clear();
            if (this.Mesh == null)
            {
                return;
            }

            if (this.VertexRadius > 0)
            {
                // Add the vertices
                foreach (var vertex in this.Mesh.Vertices)
                {
                    var gm = new MeshBuilder(false, false);
                    gm.AddSubdivisionSphere(vertex.Position, this.VertexRadius, 4);
                    var vertexElement = new ModelUIElement3D
                        {
                           Model = new GeometryModel3D(gm.ToMesh(), this.VertexMaterial)
                        };
                    var currentVertex = vertex;
                    vertexElement.MouseLeftButtonDown += (s, e) => this.HighlightVertex(currentVertex);
                    this.vertexVisuals.Add(vertex, vertexElement);
                    this.Add(vertexElement);
                }
            }

            var faceCenter = new Dictionary<HalfEdgeMesh.Face, Point3D>();

            foreach (var face in this.Mesh.Faces)
            {
                var faceVertices = face.Vertices.Select(v => v.Position).ToList();

                // Find the face centroid
                var center = this.FindCentroid(faceVertices);
                faceCenter.Add(face, center);

                if (this.ShrinkFactor < 1)
                {
                    // Add the faces
                    for (int i = 0; i < faceVertices.Count; i++)
                    {
                        faceVertices[i] += (center - faceVertices[i]) * this.ShrinkFactor;
                    }

                    var gm = new MeshBuilder(false, false);
                    gm.AddTriangleFan(faceVertices);
                    var faceElement = new ModelUIElement3D
                        {
                            Model =
                                new GeometryModel3D(gm.ToMesh(), this.FaceMaterial)
                                    {
                                       BackMaterial = this.FaceBackMaterial
                                    }
                        };
                    var currentFace = face;
                    faceElement.MouseLeftButtonDown += (s, e) => this.HighlightFace(currentFace);
                    this.faceVisuals.Add(face, faceElement);
                    this.Add(faceElement);
                }
            }

            if (this.EdgeDiameter > 0)
            {
                // Add the edges
                foreach (var edge in this.Mesh.Edges)
                {
                    var start = edge.StartVertex.Position;
                    var end = edge.EndVertex.Position;
                    var center = faceCenter[edge.Face];
                    start = start + (center - start) * this.ShrinkFactor;
                    end = end + (center - end) * this.ShrinkFactor;
                    var gm = new MeshBuilder(false, false);
                    gm.AddArrow(start, end, this.EdgeDiameter);
                    var edgeElement = new ModelUIElement3D
                        {
                           Model = new GeometryModel3D(gm.ToMesh(), this.EdgeMaterial)
                        };
                    var currentEdge = edge;
                    edgeElement.MouseLeftButtonDown += (s, e) => { this.HighlightEdge(currentEdge); };
                    this.halfEdgeVisuals.Add(edge, edgeElement);
                    this.Add(edgeElement);
                }
            }
        }
开发者ID:BEEden,项目名称:Diplomarbeit,代码行数:90,代码来源:HalfEdgeMeshVisual3D.cs


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