本文整理汇总了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();
}