本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.ToMesh方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.ToMesh方法的具体用法?C# MeshBuilder.ToMesh怎么用?C# MeshBuilder.ToMesh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HelixToolkit.Wpf.MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.ToMesh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainViewModel
public MainViewModel()
{
var gm = new MeshBuilder();
gm.AddBox(new Point3D(0, 0, 0.5), 1, 1, 1);
gm.AddCylinder(new Point3D(5, 0, 0), new Point3D(5, 0, 5), 1, 36);
this.Model = new GeometryModel3D(gm.ToMesh(true), Materials.Blue);
this.Model.Freeze();
}
示例2: buildTri
private static object buildTri()
{
var mb = new MeshBuilder(true, false);
var p0 = new Point3D(0, 0, 0);
var p1 = new Point3D(1, 0, 0);
var p2 = new Point3D(1, 1, 0);
mb.AddTriangle(p0, p1, p2);
mb.Normals.ToList().ForEach(x => System.Diagnostics.Trace.WriteLine(x.ToString()));
return mb.ToMesh();
}
示例3: MainViewModel
/// <summary>
/// Initializes a new instance of the <see cref="MainViewModel"/> class.
/// </summary>
public MainViewModel()
{
// Create a model group
var modelGroup = new Model3DGroup();
// Create a mesh builder and add a box to it
var meshBuilder = new MeshBuilder(false, false);
meshBuilder.AddBox(new Point3D(0, 0, 1), 1, 2, 0.5);
meshBuilder.AddBox(new Rect3D(0, 0, 1.2, 0.5, 1, 0.4));
// Create a mesh from the builder (and freeze it)
var mesh = meshBuilder.ToMesh(true);
// Create some materials
var greenMaterial = MaterialHelper.CreateMaterial(Colors.Green);
var redMaterial = MaterialHelper.CreateMaterial(Colors.Red);
var blueMaterial = MaterialHelper.CreateMaterial(Colors.Blue);
var insideMaterial = MaterialHelper.CreateMaterial(Colors.Yellow);
// Add 3 models to the group (using the same mesh, that's why we had to freeze it)
modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Material = greenMaterial, BackMaterial = insideMaterial });
modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Transform = new TranslateTransform3D(-2, 0, 0), Material = redMaterial, BackMaterial = insideMaterial });
modelGroup.Children.Add(new GeometryModel3D { Geometry = mesh, Transform = new TranslateTransform3D(2, 0, 0), Material = blueMaterial, BackMaterial = insideMaterial });
//// Set the property, which will be bound to the Content property of the ModelVisual3D (see MainWindow.xaml)
//AxisAngleRotation3D rotateAxis = new AxisAngleRotation3D(new Vector3D(0, 1, 0), 180/*or 360*/);
//Rotation3DAnimation rotateAnimation = new Rotation3DAnimation(rotateAxis, TimeSpan.FromSeconds(2));
//var rotateTransform = new RotateTransform3D();
//rotateTransform.BeginAnimation(RotateTransform3D.RotationProperty, rotateAnimation);
//modelGroup.Transform = rotateTransform;
this.Model = modelGroup;
}
示例4: ModelVisual3D
// Add all cubes to a ModelVisual3D, reuse geometry but create new visual for each cube - this is slow
/* GeometryModel3D AddGeometrySeparate(IEnumerable<Point3D> centers, double L)
{
var mv = new ModelVisual3D();
var cubit = new CubeVisual3D { SideLength = L * 0.95, Fill = Brushes.Gold };
var cuboidGeometry = cubit.Model.Geometry as MeshGeometry3D;
var r = new Random();
foreach (var center in centers)
{
var tg = new Transform3DGroup();
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), (r.NextDouble() - 0.5) * 10)));
tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), (r.NextDouble() - 0.5) * 10)));
tg.Children.Add(new TranslateTransform3D(center.ToVector3D()));
var c = new ModelVisual3D
{
Content =
new GeometryModel3D
{
Geometry = cuboidGeometry,
Material = cubit.Material,
Transform = tg
}
};
mv.Children.Add(c);
}
return mv;
}*/
// All cubes in one GeometryModel - much faster
GeometryModel3D AddGeometry(IEnumerable<Point3D> centers, double L)
{
var w = new Stopwatch();
w.Start();
/* var geometry = new MeshGeometry3D();
foreach (var center in centers)
{
MeshGeometryHelper.AddBox(geometry,center, L, L, L);
}
*/
var builder = new MeshBuilder();
foreach (var center in centers)
{
builder.AddBox(center, L, L, L);
}
var geometry = builder.ToMesh();
geometry.Freeze();
Trace.WriteLine(Level + ": " + w.ElapsedMilliseconds + " ms");
var mv = new GeometryModel3D
{
Geometry = geometry,
Material = MaterialHelper.CreateMaterial(Brushes.Gold)
};
TriangleCount = geometry.TriangleIndices.Count / 3;
return mv;
}
示例5: Initializer
private void Initializer(Point3D location)
{
var geometryModel = new GeometryModel3D();
var meshBuilder = new MeshBuilder();
meshBuilder.AddBox(new Point3D(location.X, location.Y, location.Z + 3.5), 1.5, 1.5, 0.25);
meshBuilder.AddBox(new Point3D(location.X, location.Y + 1, location.Z + 3.5), 0.25, 1.25, 0.25);
meshBuilder.AddBox(new Point3D(location.X, location.Y - 1, location.Z + 3.5), 0.25, 1.25, 0.25);
meshBuilder.AddBox(new Point3D(location.X + 1, location.Y , location.Z + 3.5), 1.25, 0.25, 0.25);
meshBuilder.AddBox(new Point3D(location.X - 1, location.Y, location.Z + 3.5), 1.25, 0.25, 0.25);
meshBuilder.AddBox(new Point3D(location.X, location.Y + 1.5, location.Z + 3), 0.25, 0.25, 0.75);
meshBuilder.AddBox(new Point3D(location.X, location.Y - 1.5, location.Z + 3), 0.25, 0.25, 0.75);
meshBuilder.AddBox(new Point3D(location.X + 1.5, location.Y, location.Z + 3), 0.25, 0.25, 0.75);
meshBuilder.AddBox(new Point3D(location.X - 1.5, location.Y, location.Z + 3), 0.25, 0.25, 0.75);
meshBuilder.AddBox(new Point3D(location.X, location.Y, location.Z + 4), 0.5, 0.5, 1);
geometryModel.Geometry = meshBuilder.ToMesh();
geometryModel.Material = Materials.Gold;
Visual3DModel = geometryModel;
}
示例6: CreateModel
private void CreateModel()
{
const double dt = 0.1;
const int nSteps = 100;
var mb = new MeshBuilder(true, true);
for (double y0 = -5; y0 <= 5; y0 += 0.25)
{
var p0 = new Point(-3, y0);
Point[] pts = Solve(Velocity, p0, dt, nSteps);
var vel = new double[pts.Length];
var diam = new double[pts.Length];
int i = 0;
var pts3d = new Point3D[pts.Length];
double vmax = 0;
foreach (Point pt in pts)
{
pts3d[i] = new Point3D(pt.X, pt.Y, 0);
double v = Velocity(pt.X, pt.Y).Length;
if (v > vmax) vmax = v;
vel[i++] = v;
}
for (int j = 0; j < vel.Length; j++)
vel[j] /= vmax;
for (int j = 0; j < vel.Length; j++)
diam[j] = 0.075;
mb.AddTube(pts3d, vel, diam, 12, false);
}
this.StreamLinesModel = new GeometryModel3D();
this.StreamLinesModel.Geometry = mb.ToMesh();
this.StreamLinesModel.Material = Materials.Hue;
this.StreamLinesModel.BackMaterial = Materials.Hue;
}
示例7: CreateModel
private Model3D CreateModel()
{
var plotModel = new Model3DGroup();
var mb = new MeshBuilder();
Point3D centre = new Point3D(1, 0.5, 0);
double radius = 0.4;
AddCircleInZCross(mb,centre, radius, 121);
var a = mb.ToMesh();
plotModel.Children.Add(new GeometryModel3D(mb.ToMesh(), MaterialHelper.CreateMaterial(TopBrush.Clone())));
return plotModel;
}
示例8: LineSegment
public LineSegment(Point3D startPoint, Point3D endPoint)
{
StartPoint = startPoint;
EndPoint = endPoint;
var meshBuilder = new MeshBuilder(false, false);
meshBuilder.AddCylinder(startPoint, endPoint, 0.2, 10);
Model = meshBuilder.ToMesh();
}
示例9: 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;
}
示例10: AddTube
void AddTube(List<Point3D> path, Color color)
{
var mb = new MeshBuilder();
mb.AddTube(path, 0.1, 3, false);
var geom = new GeometryModel3D { Geometry = mb.ToMesh(true), Material = MaterialHelper.CreateMaterial(color) }; // create a model
var model = new ModelVisual3D();
model.Content = geom;
_Helix.Children.Add(model);
}
示例11: 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 });
}
示例12: MainWindow
public MainWindow()
{
InitializeComponent();
var material = MaterialHelper.CreateMaterial(Colors.Aqua);
var builder = new MeshBuilder();
builder.AddTriangle(new Point3D(0, 0, 0), new Point3D(0, 10, 100), new Point3D(100, 0, 0));
var mesh = builder.ToMesh();
var geo = new GeometryModel3D { Geometry = mesh, Material = material , Transform = null};
var model = new ModelVisual3D { Content = geo, Transform = null };
_visual.Children.Add(model);
}
示例13: Cube
public Cube(Point3D center, double radius, Action action) {
Center = center;
Radius = radius;
Action = action;
Notified = false;
SolidColorBrush = new SolidColorBrush();
SolidColorBrush.Opacity = _Constants.BaseOpacity;
SolidColorBrush.Color = _Constants.DefaultCubeColour;
Material = new DiffuseMaterial(SolidColorBrush);
MeshBuilder meshBuilder = new MeshBuilder();
meshBuilder.AddBox(center, radius, radius, radius);
ModelVisual3D = Engine._3DUtil.WrapMeshAndMaterialIntoModelVisual3D(meshBuilder.ToMesh(), Material);
}
示例14: CreateDice
private ModelVisual3D CreateDice()
{
var diceMesh = new MeshBuilder();
diceMesh.AddBox(new Point3D(0, 0, 0), 1, 1, 1);
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
for (int k = 0; k < 2; k++)
{
var points = new List<Point3D>();
diceMesh.ChamferCorner(new Point3D(i - 0.5, j - 0.5, k - 0.5), 0.1, 1e-6, points);
//foreach (var p in points)
// b.ChamferCorner(p, 0.03);
}
return new ModelVisual3D { Content = new GeometryModel3D { Geometry = diceMesh.ToMesh(), Material = Materials.White } };
}
示例15: 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);
}