本文整理汇总了C#中MeshBuilder.AddSubdivisionSphere方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddSubdivisionSphere方法的具体用法?C# MeshBuilder.AddSubdivisionSphere怎么用?C# MeshBuilder.AddSubdivisionSphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.AddSubdivisionSphere方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateVisuals
/// <summary>
/// Updates the visuals.
/// </summary>
protected void UpdateVisuals()
{
if (this.Mesh == null)
{
this.Content = null;
return;
}
var m = new Model3DGroup();
this.TriangleIndexToFaceIndex = new List<int>();
var faceGeometry = this.Mesh.ToMeshGeometry3D(
this.SharedVertices, this.ShrinkFactor, this.TriangleIndexToFaceIndex);
m.Children.Add(
new GeometryModel3D(faceGeometry, this.FaceMaterial) { BackMaterial = this.FaceBackMaterial });
// Add the nodes
if (this.VertexRadius > 0)
{
var gm = new MeshBuilder(false, false);
foreach (var p in this.Mesh.Vertices)
{
gm.AddSubdivisionSphere(p, this.VertexRadius, this.VertexResolution);
// gm.AddBox(p, VertexRadius, VertexRadius, VertexRadius);
}
m.Children.Add(new GeometryModel3D(gm.ToMesh(), this.VertexMaterial));
}
// Add the edges
if (this.EdgeDiameter > 0)
{
var em = new MeshBuilder(false, false);
//// int fi = 0;
foreach (var p in this.Mesh.Faces)
{
//// var n = this.Mesh.GetFaceNormal(fi++);
for (int i = 0; i < p.Length; i += 1)
{
var p0 = this.Mesh.Vertices[p[i]];
var p1 = this.Mesh.Vertices[p[(i + 1) % p.Length]];
em.AddCylinder(p0, p1, this.EdgeDiameter, 4);
}
}
m.Children.Add(new GeometryModel3D(em.ToMesh(), this.EdgeMaterial));
}
this.Content = m;
}
示例2: UpdateVisuals
/// <summary>
/// Updates the visuals.
/// </summary>
protected void UpdateVisuals()
{
this.vertexVisuals = new Dictionary<HalfEdgeMesh.Vertex, ModelUIElement3D>();
this.halfEdgeVisuals = new Dictionary<HalfEdgeMesh.HalfEdge, ModelUIElement3D>();
this.faceVisuals = new Dictionary<HalfEdgeMesh.Face, ModelUIElement3D>();
this.Children.Clear();
if (this.Mesh == null)
{
return;
}
if (this.VertexRadius > 0)
{
// Add the vertices
foreach (var vertex in this.Mesh.Vertices)
{
var gm = new MeshBuilder(false, false);
gm.AddSubdivisionSphere(vertex.Position, this.VertexRadius, 4);
var vertexElement = new ModelUIElement3D
{
Model = new GeometryModel3D(gm.ToMesh(), this.VertexMaterial)
};
var currentVertex = vertex;
vertexElement.MouseLeftButtonDown += (s, e) => this.HighlightVertex(currentVertex);
this.vertexVisuals.Add(vertex, vertexElement);
this.Add(vertexElement);
}
}
var faceCenter = new Dictionary<HalfEdgeMesh.Face, Point3D>();
foreach (var face in this.Mesh.Faces)
{
var faceVertices = face.Vertices.Select(v => v.Position).ToList();
// Find the face centroid
var center = this.FindCentroid(faceVertices);
faceCenter.Add(face, center);
if (this.ShrinkFactor < 1)
{
// Add the faces
for (int i = 0; i < faceVertices.Count; i++)
{
faceVertices[i] += (center - faceVertices[i]) * this.ShrinkFactor;
}
var gm = new MeshBuilder(false, false);
gm.AddTriangleFan(faceVertices);
var faceElement = new ModelUIElement3D
{
Model =
new GeometryModel3D(gm.ToMesh(), this.FaceMaterial)
{
BackMaterial = this.FaceBackMaterial
}
};
var currentFace = face;
faceElement.MouseLeftButtonDown += (s, e) => this.HighlightFace(currentFace);
this.faceVisuals.Add(face, faceElement);
this.Add(faceElement);
}
}
if (this.EdgeDiameter > 0)
{
// Add the edges
foreach (var edge in this.Mesh.Edges)
{
var start = edge.StartVertex.Position;
var end = edge.EndVertex.Position;
var center = faceCenter[edge.Face];
start = start + (center - start) * this.ShrinkFactor;
end = end + (center - end) * this.ShrinkFactor;
var gm = new MeshBuilder(false, false);
gm.AddArrow(start, end, this.EdgeDiameter);
var edgeElement = new ModelUIElement3D
{
Model = new GeometryModel3D(gm.ToMesh(), this.EdgeMaterial)
};
var currentEdge = edge;
edgeElement.MouseLeftButtonDown += (s, e) => { this.HighlightEdge(currentEdge); };
this.halfEdgeVisuals.Add(edge, edgeElement);
this.Add(edgeElement);
}
}
}