本文整理汇总了C#中System.Windows.Media.Media3D.Point3DCollection类的典型用法代码示例。如果您正苦于以下问题:C# Point3DCollection类的具体用法?C# Point3DCollection怎么用?C# Point3DCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point3DCollection类属于System.Windows.Media.Media3D命名空间,在下文中一共展示了Point3DCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
/// <summary>
/// Sets the coordinates of all the individual lines in the visual.
/// </summary>
/// <param name="args">
/// The <c>DependencyPropertyChangedEventArgs</c> object associated
/// with the property-changed event that resulted in this method
/// being called.
/// </param>
/// <param name="lines">
/// The <c>Point3DCollection</c> to be filled.
/// </param>
/// <remarks>
/// <para>
/// Classes that derive from <c>WireBase</c> override this
/// method to fill the <c>lines</c> collection.
/// It is custmary for implementations of this method to clear
/// the <c>lines</c> collection first before filling it.
/// Each pair of successive members of the <c>lines</c>
/// collection indicate one straight line.
/// </para>
/// <para>
/// The <c>WireLine</c> class implements this method by
/// clearing the <c>lines</c> collection and then adding
/// <c>Point1</c> and <c>Point2</c> to the collection.
/// </para>
/// </remarks>
protected override void Generate(DependencyPropertyChangedEventArgs args,
Point3DCollection lines)
{
lines.Clear();
lines.Add(Point1);
lines.Add(Point2);
}
示例2: FillMesh
public Point3DCollection FillMesh(int xVertices, int yVertices, double aspect)
{
LineEvaluator hLine = new LineEvaluator();
hLine.Point1 = new Point3D(-aspect/2, 0, 0);
hLine.Point2 = new Point3D(aspect/2, 0, 0);
LineEvaluator vLine = new LineEvaluator();
vLine.Point1 = new Point3D(0, 0.5, 0);
vLine.Point2 = new Point3D(0, -0.5, 0);
Point3DCollection positions = new Point3DCollection();
for (int y = 0; y < yVertices; y++)
{
double vT = (double) y/(yVertices - 1);
Point3D vPoint = vLine.Evaluate(vT);
for (int x = 0; x < xVertices; x++)
{
double hT = (double) x/(xVertices - 1);
Point3D hPoint = hLine.Evaluate(hT);
positions.Add(new Point3D(hPoint.X, vPoint.Y, 0));
}
}
return positions;
}
示例3: CreateRectangle
public static MeshGeometry3D CreateRectangle(double height, double width)
{
var vertices = new Point3DCollection();
var normals = new Vector3DCollection();
var facets = new Int32Collection();
var textureCoords = new PointCollection();
vertices.Add(new Point3D(-width / 2, 0, -height / 2));
vertices.Add(new Point3D(-width / 2, 0, height / 2));
vertices.Add(new Point3D(width / 2, 0, -height / 2));
vertices.Add(new Point3D(width / 2, 0, height / 2));
normals.Add(new Vector3D(0, -1, 0));
normals.Add(new Vector3D(0, -1, 0));
normals.Add(new Vector3D(0, -1, 0));
normals.Add(new Vector3D(0, -1, 0));
textureCoords.Add(new Point(1,1));
textureCoords.Add(new Point(1, 0));
textureCoords.Add(new Point(0,1));
textureCoords.Add(new Point(0,0));
facets.Add(0); facets.Add(1); facets.Add(2); facets.Add(3); facets.Add(2); facets.Add(1);
var rectangle = new MeshGeometry3D();
rectangle.Positions = vertices;
rectangle.Normals = normals;
rectangle.TriangleIndices = facets;
rectangle.TextureCoordinates = textureCoords;
return rectangle;
}
示例4: Triangulate
protected override void Triangulate(DependencyPropertyChangedEventArgs args,
Point3DCollection vertices,
Vector3DCollection normals,
Int32Collection indices,
PointCollection textures)
{
vertices.Clear();
normals.Clear();
indices.Clear();
textures.Clear();
MeshGeometry3D mesh = MeshGenerator.Geometry;
foreach (Point3D vertex in mesh.Positions)
vertices.Add(vertex);
foreach (Vector3D normal in mesh.Normals)
normals.Add(normal);
foreach (int index in mesh.TriangleIndices)
indices.Add(index);
foreach (Point texture in mesh.TextureCoordinates)
textures.Add(texture);
}
示例5: ProcessFigure
protected override void ProcessFigure(CircularList<Point> list,
Point3DCollection vertices,
Vector3DCollection normals,
Int32Collection indices,
PointCollection textures)
{
int offset = vertices.Count;
for (int i = 0; i <= list.Count; i++)
{
Point pt = list[i];
// Set vertices.
vertices.Add(new Point3D(pt.X, pt.Y, 0));
vertices.Add(new Point3D(pt.X, pt.Y, -Depth));
// Set texture coordinates.
textures.Add(new Point((double)i / list.Count, 0));
textures.Add(new Point((double)i / list.Count, 1));
// Set triangle indices.
if (i < list.Count)
{
indices.Add(offset + i * 2 + 0);
indices.Add(offset + i * 2 + 2);
indices.Add(offset + i * 2 + 1);
indices.Add(offset + i * 2 + 1);
indices.Add(offset + i * 2 + 2);
indices.Add(offset + i * 2 + 3);
}
}
}
示例6: receiveCurveFromMaya
public void receiveCurveFromMaya(string node_name, out Point3DCollection controlVertices, out List<double> weights, out List<double> knots, out int degree, out bool closed, out bool rational)
{
MPlug plLocal = getPlug(node_name, "local");
MObject oLocal = new MObject();
plLocal.getValue(oLocal);
MFnNurbsCurve nc = new MFnNurbsCurve(oLocal);
MPointArray p_aCVs = new MPointArray();
nc.getCVs(p_aCVs, MSpace.Space.kWorld);
controlVertices = new Point3DCollection();
weights = new List<double>();
foreach (MPoint p in p_aCVs)
{
controlVertices.Add(new Point3D(p.x, p.y, p.z));
weights.Add(1.0);
}
double min = 0, max = 0;
nc.getKnotDomain(ref min, ref max);
MDoubleArray d_aKnots = new MDoubleArray();
nc.getKnots(d_aKnots);
knots = new List<double>();
knots.Add(min);
foreach (double d in d_aKnots)
{
knots.Add(d);
}
knots.Add(max);
degree = nc.degree;
closed = nc.form == MFnNurbsCurve.Form.kClosed ? true : false;
rational = true;
}
示例7: Generate
/// <summary>
///
/// </summary>
/// <param name="args"></param>
/// <param name="lines"></param>
protected override void Generate(DependencyPropertyChangedEventArgs args,
Point3DCollection lines)
{
Point3DCollection vertices = Positions;
Int32Collection indices = TriangleIndices;
lines.Clear();
if (vertices != null && vertices.Count > 0 &&
indices != null && indices.Count > 0)
{
// Check that this doesn't overflow !!!!!!
// -----------------------------------------
// Special logic if there are no indices !!!!
// -------------------------------------------
for (int i = 0; i < indices.Count; i += 3)
{
lines.Add(vertices[indices[i + 0]]);
lines.Add(vertices[indices[i + 1]]);
lines.Add(vertices[indices[i + 1]]);
lines.Add(vertices[indices[i + 2]]);
lines.Add(vertices[indices[i + 2]]);
lines.Add(vertices[indices[i + 0]]);
}
}
}
示例8: AddCircleInZCross
private static void AddCircleInZCross(MeshBuilder mb, Point3D centre, double radius, int div)
{
var points = MeshBuilder.GetCircle(div);
var vectors = new Point3DCollection();
var normals = new Vector3DCollection();
var textures = new PointCollection();
vectors.Add(new Point3D(centre.X, centre.Y, 0));
normals.Add(new Vector3D(0, 0, 1));
textures.Add(new Point(0.5, 0.5));
for (int i = 0; i < points.Count - 1; i++)
{
vectors.Add(new Point3D(points[i].X * radius + centre.X, points[i].Y * radius + centre.Y, centre.Z));
normals.Add(new Vector3D(0, 0, -1));
textures.Add(new Point(points[i].X * 0.5 + 0.5, points[i].Y * 0.5 + 0.5));
vectors.Add(new Point3D(points[i + 1].X * radius + centre.X, points[i + 1].Y * radius + centre.Y, centre.Z));
normals.Add(new Vector3D(0, 0, 01));
textures.Add(new Point(points[i + 1].X * 0.5 + 0.5, points[i + 1].Y * 0.5 + 0.5));
}
mb.AddTriangleFan(vectors, normals, textures);
}
示例9: Point3DCollection
/* internal void drawLine(Point3D start, Point3D pt, bool hit)
{
TubeVisual3D line;
lines.TryGetValue(start, out line);
if (line != null)
{
this.Children.Remove(line);
lines.Remove(start);
}
Point3DCollection contours = new Point3DCollection();
contours.Add(ToWorld(start));
contours.Add(ToWorld(pt));
line = new TubeVisual3D { Diameter = 0.5, Path = contours, Fill = Brushes.SandyBrown };
lines.Add(start,line);
this.Children.Add(line);
addBox(start);
if(hit) addBox(pt);
}
*/
internal void drawLine(Point3D start, Point3D end)
{
TubeVisual3D line;
lines.TryGetValue(start, out line);
if (line != null)
{
this.Children.Remove(line);
lines.Remove(start);
}
Point3DCollection contours = new Point3DCollection();
contours.Add(ToWorld(start));
contours.Add(ToWorld(end));
line = new TubeVisual3D { Diameter = 0.3, Path = contours, Fill = Brushes.DarkOliveGreen};
lines.Add(start, line);
this.Children.Add(line);
string x = string.Format("{0:0.00}",end.X);
string y = string.Format("{0:0.00}", end.Y);
string z = string.Format("{0:0.00}", end.Z);
string text = x + "," + y + "," + z;
addBox(start);
addBox(end);
add3DText(end, text);
}
示例10: OnNumberOfSidesChanged
private static void OnNumberOfSidesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
WheelMesh wheel = (WheelMesh)d;
Point3DCollection points = new Point3DCollection(3 + wheel.NumberOfSides - 2);
Int32Collection triangles = new Int32Collection(wheel.NumberOfSides);
// Center
points.Add(new Point3D(wheel.Radius, wheel.Radius, wheel.Height));
// Top
points.Add(new Point3D(wheel.Radius, 0, 0));
for (int i = 1; i < wheel.NumberOfSides; i++)
{
double beta = 2 * Math.PI / wheel.NumberOfSides * i;
double alpha = (Math.PI - beta) / 2;
double length = 2 * wheel.Radius * Math.Sin(beta / 2);
double x = length * Math.Cos(Math.PI / 2 - alpha);
double y = length * Math.Sin(Math.PI / 2 - alpha);
points.Add(new Point3D(wheel.Radius + x, y, 0));
triangles.Add(0);
triangles.Add(i);
triangles.Add(i+1);
}
triangles.Add(0);
triangles.Add(wheel.NumberOfSides);
triangles.Add(1);
wheel.SetValue(PointsProperty, points);
wheel.SetValue(TriangleIndicesProperty, triangles);
}
示例11: Triangulate
protected override void Triangulate(
DependencyPropertyChangedEventArgs args,
Point3DCollection vertices,
Vector3DCollection normals,
Int32Collection indices,
PointCollection textures)
{
// Clear all four collections.
vertices.Clear();
normals.Clear();
indices.Clear();
textures.Clear();
// Convert TextGeometry to series of closed polylines.
PathGeometry path =
TextGeometry.GetFlattenedPathGeometry(0.001,
ToleranceType.Relative);
foreach (PathFigure fig in path.Figures)
{
list.Clear();
list.Add(fig.StartPoint);
foreach (PathSegment seg in fig.Segments)
{
if (seg is LineSegment)
{
LineSegment lineseg = seg as LineSegment;
list.Add(lineseg.Point);
}
else if (seg is PolyLineSegment)
{
PolyLineSegment polyline = seg as PolyLineSegment;
for (int i = 0; i < polyline.Points.Count; i++)
list.Add(polyline.Points[i]);
}
}
// Figure is complete. Post-processing follows.
if (list.Count > 0)
{
// Remove last point if it's the same as the first.
if (list[0] == list[list.Count - 1])
list.RemoveAt(list.Count - 1);
// Convert points to Y increasing up.
for (int i = 0; i < list.Count; i++)
{
Point pt = list[i];
pt.Y = 2 * Origin.Y - pt.Y;
list[i] = pt;
}
// For each figure, process the points.
ProcessFigure(list, vertices, normals, indices, textures);
}
}
}
示例12: Generate
/// <summary>
/// Sets the coordinates of all the individual lines in the visual.
/// </summary>
/// <param name="args">
/// The <c>DependencyPropertyChangedEventArgs</c> object associated
/// with the property-changed event that resulted in this method
/// being called.
/// </param>
/// <param name="lines">
/// The <c>Point3DCollection</c> to be filled.
/// </param>
/// <remarks>
/// <para>
/// Classes that derive from <c>WireBase</c> override this
/// method to fill the <c>lines</c> collection.
/// It is custmary for implementations of this method to clear
/// the <c>lines</c> collection first before filling it.
/// Each pair of successive members of the <c>lines</c>
/// collection indicate one straight line.
/// </para>
/// </remarks>
protected override void Generate(DependencyPropertyChangedEventArgs args,
Point3DCollection lines)
{
lines.Clear();
if (Data == null)
return;
Transform3D xform = Data.Transform;
foreach (PathFigure3D fig in Data.Figures)
{
PathFigure3D figFlattened = fig.GetFlattenedPathFigure();
Point3D pointStart = xform.Transform(figFlattened.StartPoint);
foreach (PathSegment3D seg in figFlattened.Segments)
{
PolyLineSegment3D segPoly = seg as PolyLineSegment3D;
for (int i = 0; i < segPoly.Points.Count; i++)
{
lines.Add(pointStart);
Point3D point = xform.Transform(segPoly.Points[i]);
lines.Add(point);
pointStart = point;
}
}
}
}
示例13: PlaneModel
public PlaneModel(GeometryModel3D plane, Color planeColor, Point3DCollection points)
{
this.plane = plane;
this.planeColor = planeColor;
this.points = points;
this.crosses = 0;
}
示例14: Generate
/// <summary>
/// Sets the coordinates of all the individual lines in the visual.
/// </summary>
/// <param name="args">
/// The <c>DependencyPropertyChangedEventArgs</c> object associated
/// with the property-changed event that resulted in this method
/// being called.
/// </param>
/// <param name="lines">
/// The <c>Point3DCollection</c> to be filled.
/// </param>
/// <remarks>
/// <para>
/// Classes that derive from <c>WireBase</c> override this
/// method to fill the <c>lines</c> collection.
/// It is custmary for implementations of this method to clear
/// the <c>lines</c> collection first before filling it.
/// Each pair of successive members of the <c>lines</c>
/// collection indicate one straight line.
/// </para>
/// <para>
/// The <c>WireLines</c> class implements this method by
/// clearing the <c>lines</c> collection and then copying
/// its own <c>Lines</c> collection to it.
/// </para>
/// </remarks>
protected override void Generate(DependencyPropertyChangedEventArgs args,
Point3DCollection lines)
{
lines.Clear();
foreach (Point3D point in Lines)
lines.Add(point);
}
示例15: CreateModel
private void CreateModel()
{
var points = new Point3DCollection();
var edges = new Int32Collection();
var triangles = new Int32Collection();
switch (CurrentModelType)
{
case ModelTypes.StellatedOctahedron:
case ModelTypes.Tetrahedron:
points.Add(+1, +1, +1);
points.Add(-1, -1, 1);
points.Add(-1, +1, -1);
points.Add(+1, -1, -1);
edges.Add(0, 1, 1, 2, 2, 0, 0, 3, 1, 3, 2, 3);
triangles.Add(0, 1, 2, 0, 3, 1, 1, 3, 2, 2, 3, 0);
break;
}
switch (CurrentModelType)
{
case ModelTypes.StellatedOctahedron:
// http://en.wikipedia.org/wiki/Compound_of_two_tetrahedra
points.Add(-1, +1, +1);
points.Add(1, -1, 1);
points.Add(1, +1, -1);
points.Add(-1, -1, -1);
edges.Add(4, 5, 5, 6, 6, 4, 4, 7, 5, 7, 6, 7);
triangles.Add(4, 5, 6, 4, 7, 5, 5, 7, 6, 6, 7, 4);
break;
}
var m = new Model3DGroup();
// Add the nodes
var gm = new MeshBuilder();
foreach (var p in points)
{
gm.AddSphere(p, 0.1);
}
m.Children.Add(new GeometryModel3D(gm.ToMesh(), Materials.Gold));
// Add the triangles
var tm = new MeshBuilder();
for (int i = 0; i < triangles.Count; i += 3)
{
tm.AddTriangle(points[triangles[i]], points[triangles[i + 1]], points[triangles[i + 2]]);
}
m.Children.Add(new GeometryModel3D(tm.ToMesh(), Materials.Red) { BackMaterial = Materials.Blue });
// Add the edges
var em = new MeshBuilder();
for (int i = 0; i < edges.Count; i += 2)
{
em.AddCylinder(points[edges[i]], points[edges[i + 1]], 0.08, 10);
}
m.Children.Add(new GeometryModel3D(em.ToMesh(), Materials.Gray));
Model = m;
}