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


C# MeshBuilder.AddSurfaceOfRevolution方法代码示例

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


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

示例1: AppearanceChanged

        private void AppearanceChanged()
        {
            var builder = new MeshBuilder(false, false);
            var p0 = new Point(0, 0);
            var p1 = new Point(this.Diameter / 2, 0);
            var p2 = new Point(this.Diameter / 2, this.Height);
            var p3 = new Point(this.DomeDiameter / 2, this.Height);

            var section = new List<Point> { p0, p1, p1, p2, p2, p3 };
            var sectionIndices = new List<int> { 0, 1, 2, 3, 4, 5 };
            int n = 40;
            for (int i = n; i >= 0; i--)
            {
                double x = (double)i / n;
                double y = x * x;
                if (i < n)
                {
                    sectionIndices.Add(section.Count - 1);
                    sectionIndices.Add(section.Count);
                }

                section.Add(new Point(x * this.DomeDiameter / 2, this.Height + (this.DomeHeight * (1 - y))));
            }

            builder.AddSurfaceOfRevolution(new Point3D(0, 0, 0), new Vector3D(0, 0, 1), section, sectionIndices, 80);
            this.walls.Geometry = builder.ToMesh(true);

            var treadDepth = 0.3;
            var riseHeight = 0.15;
            var thickness = 0.05;
            var width = 1;
            var steps = (int)(this.Height / riseHeight);
            var r = (this.Diameter * 0.5) + (width * 0.5);
            var rp = (this.Diameter * 0.5) + (width * 0.95);
            var stairBuilder = new MeshBuilder(false, false);
            var railBases = new List<Point3D>();
            for (int i = 0; i < steps; i++)
            {
                var theta = treadDepth * i / r;
                var p = new Point3D(Math.Cos(theta) * r, Math.Sin(theta) * r, (riseHeight * i) + (thickness / 2));
                var x = new Vector3D(Math.Cos(theta), Math.Sin(theta), 0);
                var z = new Vector3D(0, 0, 1);
                var y = Vector3D.CrossProduct(z, x);
                stairBuilder.AddBox(p, x, y, width, treadDepth, thickness);
                railBases.Add(new Point3D(Math.Cos(theta) * rp, Math.Sin(theta) * rp, (riseHeight * i) + thickness));
            }

            var lastTheta = treadDepth * steps / r;

            // Railing along stairs
            var railingHeight = 0.8;
            var railingDiameter = 0.05;
            var railings = 3;
            var railingBuilder = new MeshBuilder(false, false);

            // Top railing
            var railingPostDistance = 0.5;
            int topRailingPosts = (int)(this.Diameter * Math.PI / railingPostDistance);
            var tr = (this.Diameter / 2) - railingDiameter;
            for (int i = 0; i < topRailingPosts; i++)
            {
                var theta = lastTheta + (2 * Math.PI * i / topRailingPosts);
                railBases.Add(new Point3D(Math.Cos(theta) * tr, Math.Sin(theta) * tr, this.Height));
            }

            BuildRailing(railingBuilder, railBases, railingHeight, railingDiameter, railings);

            this.stairs.Geometry = stairBuilder.ToMesh();
            this.railing.Geometry = railingBuilder.ToMesh();
        }
开发者ID:JeremyAnsel,项目名称:helix-toolkit,代码行数:70,代码来源:SiloVisual3D.cs


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