本文整理汇总了C#中HelixToolkit.Wpf.MeshBuilder.AddCylinder方法的典型用法代码示例。如果您正苦于以下问题:C# MeshBuilder.AddCylinder方法的具体用法?C# MeshBuilder.AddCylinder怎么用?C# MeshBuilder.AddCylinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HelixToolkit.Wpf.MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder.AddCylinder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例3: ToModel3D
public Model3D ToModel3D()
{
var m = new Model3DGroup();
TriangleIndexToPanelIndex = new List<int>();
// Add the triangles
var tm = new MeshBuilder(false, false);
int panelIndex = 0;
foreach (var p in Panels)
{
p.TriangleIndex = tm.Positions.Count;
tm.AddTriangleFan(p.Points);
for (int i = 0; i < p.Points.Length - 2; i++) TriangleIndexToPanelIndex.Add(panelIndex);
panelIndex++;
}
var panelsGeometry = tm.ToMesh();
m.Children.Add(new GeometryModel3D(panelsGeometry, Materials.Red) { BackMaterial = Materials.Blue });
// Add the nodes
var gm = new MeshBuilder();
foreach (var p in panelsGeometry.Positions)
{
gm.AddSphere(p, 0.05);
}
m.Children.Add(new GeometryModel3D(gm.ToMesh(), Materials.Gold));
// Add the edges
var em = new MeshBuilder();
foreach (var p in Panels)
{
for (int i = 0; i < p.Points.Length; i += 1)
{
em.AddCylinder(p.Points[i], p.Points[(i + 1) % p.Points.Length], 0.05, 10);
}
}
m.Children.Add(new GeometryModel3D(em.ToMesh(), Materials.Gray));
return m;
}
示例4: 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;
}
示例5: BuildRailing
private static void BuildRailing(
MeshBuilder railingBuilder,
List<Point3D> bases,
double height,
double diameter,
int railings)
{
foreach (var point in bases)
{
railingBuilder.AddCylinder(point, point + new Vector3D(0, 0, height), diameter, 10);
}
for (int i = 1; i <= railings; i++)
{
var h = height * i / railings;
var path = bases.Select(p => p + new Vector3D(0, 0, h)).ToArray();
railingBuilder.AddTube(path, diameter, 10, false);
}
}
示例6: BuildBone
/// <summary>
/// Build a bone for drawing
/// </summary>
/// <param name="myBone">Bone</param>
/// <returns>bone created</returns>
private GeometryModel3D BuildBone(Mckineap.Models.Engine3D.Bone myBone)
{
MeshBuilder bone = new MeshBuilder();
Point3D Point1 = joints.First(x => x.Name == myBone.FirstJointName).Point;
Point3D Point2 = joints.First(x => x.Name == myBone.SecondJointName).Point;
bone.AddCylinder(Point1, Point2, boneDiameter, thetaDiv);
GeometryModel3D pipe = new GeometryModel3D(bone.ToMesh(), new DiffuseMaterial(new SolidColorBrush(Colors.Beige)));
return (pipe);
}
示例7: SkeletonFrameReady_Draw3D
//TODO: refactor into more methods
private void SkeletonFrameReady_Draw3D(ModelVisual3D modelVisual3D, SkeletonFrameReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
// Get tracked skeleton data from stream, return if no data
if (skeletonFrame == null)
{
modelVisual3D.Content = null;
return;
}
Skeleton[] skeletons = new Skeleton[kinect.SkeletonStream.FrameSkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo(skeletons);
Skeleton skeleton = skeletons.FirstOrDefault(s => s.TrackingState == SkeletonTrackingState.Tracked);
if (skeleton == null)
{
modelVisual3D.Content = null;
return;
}
// Waist coordinates will be origin
SkeletonPoint centroid = skeleton.Joints[JointType.HipCenter].Position;
// Init 3D stuff
Model3DGroup modelGroup = new Model3DGroup();
MeshBuilder meshBuilder = new MeshBuilder(false, false);
// Init dict to tidy up code
Dictionary<JointType, Point3D> jd = new Dictionary<JointType, Point3D>();
// Add joints to mesh while populating the dict
foreach (Joint j in skeleton.Joints)
{
// Helix3D has a different coordinate system
int y = (int)((j.Position.X - centroid.X) * 100);
int z = (int)((j.Position.Y - centroid.Y) * 100);
int x = (int)((centroid.Z - j.Position.Z) * 100);
Point3D center = new Point3D { X = x, Y = y, Z = z };
jd[j.JointType] = center;
meshBuilder.AddSphere(center, 5);
}
// Add bones to mesh
meshBuilder.AddCylinder(jd[JointType.Head], jd[JointType.ShoulderCenter], 6, 10);
meshBuilder.AddCylinder(jd[JointType.ShoulderCenter], jd[JointType.Spine], 6, 10);
meshBuilder.AddCylinder(jd[JointType.Spine], jd[JointType.HipCenter], 6, 10);
meshBuilder.AddCylinder(jd[JointType.HipCenter], jd[JointType.HipLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.HipLeft], jd[JointType.KneeLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.KneeLeft], jd[JointType.AnkleLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.AnkleLeft], jd[JointType.FootLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.HipCenter], jd[JointType.HipRight], 6, 10);
meshBuilder.AddCylinder(jd[JointType.HipRight], jd[JointType.KneeRight], 6, 10);
meshBuilder.AddCylinder(jd[JointType.KneeRight], jd[JointType.AnkleRight], 6, 10);
meshBuilder.AddCylinder(jd[JointType.AnkleRight], jd[JointType.FootRight], 6, 10);
meshBuilder.AddCylinder(jd[JointType.ShoulderCenter], jd[JointType.ShoulderLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.ShoulderLeft], jd[JointType.ElbowLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.ElbowLeft], jd[JointType.WristLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.WristLeft], jd[JointType.HandLeft], 6, 10);
meshBuilder.AddCylinder(jd[JointType.ShoulderCenter], jd[JointType.ShoulderRight], 6, 10);
meshBuilder.AddCylinder(jd[JointType.ShoulderRight], jd[JointType.ElbowRight], 6, 10);
meshBuilder.AddCylinder(jd[JointType.ElbowRight], jd[JointType.WristRight], 6, 10);
meshBuilder.AddCylinder(jd[JointType.WristRight], jd[JointType.HandRight], 6, 10);
var mesh = meshBuilder.ToMesh(true); // Create and freeze mesh
Material blueMaterial = MaterialHelper.CreateMaterial(Colors.SteelBlue); // Create material
modelGroup.Children.Add(new GeometryModel3D(mesh, blueMaterial)); // Create model
// Draw
modelVisual3D.Content = modelGroup;
}
}
示例8: AppearanceChanged
private void AppearanceChanged()
{
var builder = new MeshBuilder(false, false);
foreach (var p1 in DistributePoles(this.Positions, this.PoleDistance))
{
var p2 = p1 + new Vector3D(0, 0, this.Height);
builder.AddCylinder(p1, p2, this.Diameter, 36);
}
this.postsModel.Geometry = builder.ToMesh();
var fenceBuilder = new MeshBuilder(false, true);
var w0 = 0d;
for (int i = 0; i + 1 < this.Positions.Count; i++)
{
var p0 = this.Positions[i];
var p1 = this.Positions[i + 1];
var p2 = this.Positions[i + 1] + new Vector3D(0, 0, this.Height);
var p3 = this.Positions[i] + new Vector3D(0, 0, this.Height);
var h = this.Height / this.MeshSize;
var dw = p0.DistanceTo(p1) / this.MeshSize;
fenceBuilder.AddQuad(
p0,
p1,
p2,
p3,
new Point(w0, h),
new Point(w0 + dw, h),
new Point(w0 + dw, 0),
new Point(w0, 0));
w0 += dw;
}
this.fenceModel.Geometry = fenceBuilder.ToMesh();
}
示例9: CreatePlatform
public void CreatePlatform(Point3D location, string textureUri)
{
Initializer();
var geometryModel = new GeometryModel3D();
var meshBuilder = new MeshBuilder();
meshBuilder.AddCylinder(location, new Point3D(location.X, location.Y, location.Z + 5), 2.5, 180);
meshBuilder.AddBox(new Point3D(location.X, location.Y, location.Z + 5), 5, 5, 0.5);
//meshBuilder.AddBox(location, xLen, yLen, zLen);
geometryModel.Geometry = meshBuilder.ToMesh();
geometryModel.Material = Materials.DarkGray;
Visual3DModel = geometryModel;
}