本文整理汇总了C#中MeshBuilder.AddSphere方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddSphere方法的具体用法?C# MeshBuilder.AddSphere怎么用?C# MeshBuilder.AddSphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.AddSphere方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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);
}
示例3: CreateModel
private Model3D CreateModel()
{
var plotModel = new Model3DGroup();
if (Points == null || Values == null) 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 = Values.Min();
double maxValue = Values.Max();
var valueRange = maxValue - minValue;
var scatterMeshBuilder = new MeshBuilder(true, true);
var oldTCCount = 0;
for (var i = 0; i < Points.Length; ++i)
{
scatterMeshBuilder.AddSphere(Points[i], SphereSize, 4, 4);
var u = (Values[i] - minValue) / valueRange;
var newTCCount = scatterMeshBuilder.TextureCoordinates.Count;
for (var j = oldTCCount; j < newTCCount; ++j)
{
scatterMeshBuilder.TextureCoordinates[j] = new Point(u, u);
}
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.Black, 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.Black, 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.Black, 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.Black, 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.Black, 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.Black, 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.Black);
plotModel.Children.Add(scatterModel);
plotModel.Children.Add(axesModel);
return plotModel;
}
示例4: Tessellate
/// <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(true, true);
builder.AddSphere(this.Center, this.Radius, this.ThetaDiv, this.PhiDiv);
return builder.ToMesh();
}