本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddCubeFace方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddCubeFace方法的具体用法?C# MeshBuilder.AddCubeFace怎么用?C# MeshBuilder.AddCubeFace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HelixToolkit.Wpf.MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.AddCubeFace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tessellate
/// <summary>
/// Do the tessellation and return the <see cref="MeshGeometry3D"/>.
/// </summary>
/// <returns>The mesh geometry.</returns>
protected override MeshGeometry3D Tessellate()
{
var b = new MeshBuilder(false, true);
b.AddCubeFace(
this.Center,
new Vector3D(-1, 0, 0),
new Vector3D(0, 0, 1),
this.SideLength,
this.SideLength,
this.SideLength);
b.AddCubeFace(
this.Center,
new Vector3D(1, 0, 0),
new Vector3D(0, 0, -1),
this.SideLength,
this.SideLength,
this.SideLength);
b.AddCubeFace(
this.Center,
new Vector3D(0, -1, 0),
new Vector3D(0, 0, 1),
this.SideLength,
this.SideLength,
this.SideLength);
b.AddCubeFace(
this.Center,
new Vector3D(0, 1, 0),
new Vector3D(0, 0, -1),
this.SideLength,
this.SideLength,
this.SideLength);
b.AddCubeFace(
this.Center,
new Vector3D(0, 0, 1),
new Vector3D(0, -1, 0),
this.SideLength,
this.SideLength,
this.SideLength);
b.AddCubeFace(
this.Center,
new Vector3D(0, 0, -1),
new Vector3D(0, 1, 0),
this.SideLength,
this.SideLength,
this.SideLength);
return b.ToMesh();
}
示例2: AddCubeFace
/// <summary>
/// Adds a cube face.
/// </summary>
/// <param name="normal">
/// The normal.
/// </param>
/// <param name="up">
/// The up vector.
/// </param>
/// <param name="b">
/// The brush.
/// </param>
/// <param name="text">
/// The text.
/// </param>
private void AddCubeFace(Vector3D normal, Vector3D up, Brush b, string text)
{
var grid = new Grid { Width = 20, Height = 20, Background = b };
grid.Children.Add(
new TextBlock
{
Text = text,
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
FontSize = 15,
Foreground = Brushes.White
});
grid.Arrange(new Rect(new Point(0, 0), new Size(20, 20)));
var bmp = new RenderTargetBitmap((int)grid.Width, (int)grid.Height, 96, 96, PixelFormats.Default);
bmp.Render(grid);
var material = MaterialHelper.CreateMaterial(new ImageBrush(bmp));
double a = this.Size;
var builder = new MeshBuilder(false, true);
builder.AddCubeFace(this.Center, normal, up, a, a, a);
var geometry = builder.ToMesh();
geometry.Freeze();
var model = new GeometryModel3D { Geometry = geometry, Material = material };
var element = new ModelUIElement3D { Model = model };
element.MouseLeftButtonDown += this.FaceMouseLeftButtonDown;
this.faceNormals.Add(element, normal);
this.faceUpVectors.Add(element, up);
this.Children.Add(element);
}
示例3: Tessellate
/// <summary>
/// Do the tesselation and return the <see cref="MeshGeometry3D"/>.
/// </summary>
/// <returns>The mesh geometry.</returns>
protected override MeshGeometry3D Tessellate()
{
var b = new MeshBuilder(false,true);
b.AddCubeFace(
this.Center, new Vector3D(-1, 0, 0), new Vector3D(0, 0, 1), this.Length, this.Width, this.Height);
b.AddCubeFace(
this.Center, new Vector3D(1, 0, 0), new Vector3D(0, 0, -1), this.Length, this.Width, this.Height);
b.AddCubeFace(
this.Center, new Vector3D(0, -1, 0), new Vector3D(0, 0, 1), this.Width, this.Length, this.Height);
b.AddCubeFace(
this.Center, new Vector3D(0, 1, 0), new Vector3D(0, 0, -1), this.Width, this.Length, this.Height);
if (this.TopFace)
{
b.AddCubeFace(
this.Center, new Vector3D(0, 0, 1), new Vector3D(0, -1, 0), this.Height, this.Length, this.Width);
}
if (this.BottomFace)
{
b.AddCubeFace(
this.Center, new Vector3D(0, 0, -1), new Vector3D(0, 1, 0), this.Height, this.Length, this.Width);
}
return b.ToMesh();
}
示例4: CreateFace
private static GeometryModel3D CreateFace(int face, Point3D center, double width, double length, double height, Brush brush)
{
var m = new GeometryModel3D();
var b = new MeshBuilder(false,true);
switch (face)
{
case 0:
b.AddCubeFace(center, new Vector3D(-1, 0, 0), new Vector3D(0, 0, 1), length, width, height);
break;
case 1:
b.AddCubeFace(center, new Vector3D(1, 0, 0), new Vector3D(0, 0, -1), length, width, height);
break;
case 2:
b.AddCubeFace(center, new Vector3D(0, -1, 0), new Vector3D(0, 0, 1), width, length, height);
break;
case 3:
b.AddCubeFace(center, new Vector3D(0, 1, 0), new Vector3D(0, 0, -1), width, length, height);
break;
case 4:
b.AddCubeFace(center, new Vector3D(0, 0, -1), new Vector3D(0, 1, 0), height, length, width);
break;
case 5:
b.AddCubeFace(center, new Vector3D(0, 0, 1), new Vector3D(0, -1, 0), height, length, width);
break;
}
m.Geometry = b.ToMesh();
m.Material = MaterialHelper.CreateMaterial(brush);
return m;
}
示例5: AddRectangle
/// <summary>
/// Add a rectangle geometry object centred at (0,0,0).
/// </summary>
/// <param name="shapeName">The 3DView object.</param>
/// <param name="width">The width of the rectangle.</param>
/// <param name="height">The height of the rectangle.</param>
/// <param name="colour">A colour or gradient brush for the object.</param>
/// <param name="materialType">A material for the object.
/// The available options are:
/// "E" Emmissive - constant brightness.
/// "D" Diffusive - affected by lights.
/// "S" Specular - specular highlights.
/// </param>
/// <returns>The 3DView Geometry name.</returns>
public static Primitive AddRectangle(Primitive shapeName, Primitive width, Primitive height, Primitive colour, Primitive materialType)
{
UIElement obj;
try
{
if (_objectsMap.TryGetValue((string)shapeName, out obj))
{
InvokeHelperWithReturn ret = new InvokeHelperWithReturn(delegate
{
try
{
if (obj.GetType() == typeof(Viewport3D))
{
Viewport3D viewport3D = (Viewport3D)obj;
ProjectionCamera camera = (ProjectionCamera)viewport3D.Camera;
MeshBuilder builder = new MeshBuilder(true, true);
builder.AddCubeFace(new Point3D(0, 0, 0), new Vector3D(0, 0, 1), new Vector3D(0, 1, 0), 0, width, height);
MeshGeometry3D mesh = builder.ToMesh();
return AddGeometry(viewport3D, mesh.Positions, mesh.TriangleIndices, mesh.Normals, mesh.TextureCoordinates, colour, materialType);
}
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return "";
});
return FastThread.InvokeWithReturn(ret).ToString();
}
else
{
Utilities.OnShapeError(Utilities.GetCurrentMethod(), shapeName);
}
}
catch (Exception ex)
{
Utilities.OnError(Utilities.GetCurrentMethod(), ex);
}
return "";
}