本文整理匯總了C#中System.Windows.Media.Media3D.Point3DCollection.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# Point3DCollection.Add方法的具體用法?C# Point3DCollection.Add怎麽用?C# Point3DCollection.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Media.Media3D.Point3DCollection
的用法示例。
在下文中一共展示了Point3DCollection.Add方法的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: 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);
}
示例3: 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);
}
示例4: 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);
}
}
}
示例5: 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);
}
示例6: 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;
}
示例7: 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>WirePolyline</c> class implements this method by
/// clearing the <c>lines</c> collection and then breaking
/// down its <c>Points</c> collection into individual lines
/// and then adding the start and end points to the collection.
/// </para>
/// </remarks>
protected override void Generate(DependencyPropertyChangedEventArgs args,
Point3DCollection lines)
{
Point3DCollection points = Points;
lines.Clear();
for (int i = 0; i < points.Count - 1; i++)
{
lines.Add(points[i]);
lines.Add(points[i + 1]);
}
}
示例8: CombinePointCollection
public static Point3DCollection CombinePointCollection(Point3DCollection initialPOints, List<XbimPoint3D> points)
{
var ret = new Point3DCollection(initialPOints.Count + points.Count);
foreach (var enumPoint in initialPOints)
{
ret.Add(enumPoint);
}
foreach (var enumPoint in points)
{
ret.Add(new Point3D(enumPoint.X, enumPoint.Y, enumPoint.Z));
}
return ret;
}
示例9: CreateMeshPositions
private Point3DCollection CreateMeshPositions()
{
double aspect = ElementWidth/ElementHeight;
double reflectionFactor = HasReflection ? 1.0 : 0.5;
Point3DCollection positions = new Point3DCollection();
positions.Add(new Point3D(-aspect/2, 1*reflectionFactor, 0));
positions.Add(new Point3D(aspect/2, 1*reflectionFactor, 0));
positions.Add(new Point3D(aspect/2, -1*reflectionFactor, 0));
positions.Add(new Point3D(-aspect/2, -1*reflectionFactor, 0));
return positions;
}
示例10: VideoSurface
public VideoSurface(string mediaSource)
{
this.ModelVisual3D = new ModelVisual3D();
var geometryModel = new GeometryModel3D();
this.ModelVisual3D.Content = geometryModel;
this.geometry = new MeshGeometry3D();
geometryModel.Geometry = geometry;
var positions = new Point3DCollection();
positions.Add(new Point3D(0, 0, 0));
positions.Add(new Point3D(640, 0, 0));
positions.Add(new Point3D(640, 480, 0));
positions.Add(new Point3D(0, 480, 0));
this.geometry.Positions = positions;
var textureCoordinates = new PointCollection();
textureCoordinates.Add(new System.Windows.Point(0, 1));
textureCoordinates.Add(new System.Windows.Point(1, 1));
textureCoordinates.Add(new System.Windows.Point(1, 0));
textureCoordinates.Add(new System.Windows.Point(0, 0));
this.geometry.TextureCoordinates = textureCoordinates;
var triangleIndices = new Int32Collection();
triangleIndices.Add(0);
triangleIndices.Add(1);
triangleIndices.Add(2);
triangleIndices.Add(2);
triangleIndices.Add(3);
triangleIndices.Add(0);
this.geometry.TriangleIndices = triangleIndices;
var material = new EmissiveMaterial();
var brush = new VisualBrush();
this.border = new Border();
this.border.BorderBrush = Brushes.White;
this.border.BorderThickness = new Thickness(10);
this.border.Opacity = 0;
this.mediaElement = new MediaElement();
mediaElement.LoadedBehavior = MediaState.Manual;
mediaElement.Source = new Uri(mediaSource);
this.border.Child = mediaElement;
brush.Visual = border;
material.Brush = brush;
geometryModel.Material = material;
this.mediaElement.MediaEnded += new RoutedEventHandler(mediaElement_MediaEnded);
}
示例11: CalculateGeometry
protected override void CalculateGeometry()
{
int e;
double segmentRad = Math.PI / 2 / (n + 1);
points = new Point3DCollection();
triangleIndices = new Int32Collection();
for (e = -n; e <= n; e++)
{
double r_e = r * Math.Cos(segmentRad * e);
double y_e = r * Math.Sin(segmentRad * e);
for (int s = 0; s <= (4 * n + 4 - 1); s++)
{
double z_s = r_e * Math.Sin(segmentRad * s) * (-1);
double x_s = r_e * Math.Cos(segmentRad * s);
points.Add(new Point3D(x_s, y_e, z_s));
}
}
points.Add(new Point3D(0, r, 0));
points.Add(new Point3D(0, -1 * r, 0));
for (e = 0; e < 2 * n; e++)
{
for (int i = 0; i < (4 * n + 4); i++)
{
triangleIndices.Add(e * (4 * n + 4) + i);
triangleIndices.Add(e * (4 * n + 4) + i + (4 * n + 4));
triangleIndices.Add(e * (4 * n + 4) + (i + 1) % (4 * n + 4) + (4 * n + 4));
triangleIndices.Add(e * (4 * n + 4) + (i + 1) % (4 * n + 4) + (4 * n + 4));
triangleIndices.Add(e * (4 * n + 4) + (i + 1) % (4 * n + 4));
triangleIndices.Add(e * (4 * n + 4) + i);
}
}
for (int i = 0; i < (4 * n + 4); i++)
{
triangleIndices.Add(e * (4 * n + 4) + i);
triangleIndices.Add(e * (4 * n + 4) + (i + 1) % (4 * n + 4));
triangleIndices.Add((4 * n + 4) * (2 * n + 1));
}
for (int i = 0; i < (4 * n + 4); i++)
{
triangleIndices.Add(i);
triangleIndices.Add((i + 1) % (4 * n + 4));
triangleIndices.Add((4 * n + 4) * (2 * n + 1) + 1);
}
}
示例12: GeneratePoints
private Point3DCollection GeneratePoints()
{
int n = _geomPoints.Count;
var result = new Point3DCollection(_geomPoints.Count);
for (int i = 0; i < n; i++)
{
var pt = _geomPoints[i].Point;
result.Add(pt);
if (i > 0 && i < n - 1)
result.Add(pt);
}
return result;
}
示例13: 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;
}
示例14: sampleSelected
private void sampleSelected(object sender, RoutedEventArgs args)
{
Point3DCollection points = new Point3DCollection();
double ratio = myScrollViewer.ActualWidth / myScrollViewer.ActualHeight;
points.Add(new Point3D(5, -5 * ratio, 0));
points.Add(new Point3D(5, 5 * ratio, 0));
points.Add(new Point3D(-5, 5 * ratio, 0));
points.Add(new Point3D(-5, 5 * ratio, 0));
points.Add(new Point3D(-5, -5 * ratio, 0));
points.Add(new Point3D(5, -5 * ratio, 0));
points.Add(new Point3D(-5, 5 * ratio, 0));
points.Add(new Point3D(-5, -5 * ratio, 0));
points.Add(new Point3D(5, -5 * ratio, 0));
points.Add(new Point3D(5, -5 * ratio, 0));
points.Add(new Point3D(5, 5 * ratio, 0));
points.Add(new Point3D(-5, 5 * ratio, 0));
myGeometry.Positions = points;
myViewport3D.Width = 100;
myViewport3D.Height = 100 * ratio;
scrollViewerBorder.Visibility = Visibility.Hidden;
RadioButton button = sender as RadioButton;
if (button != null)
{
if (button.Content.ToString() == "Geometry Usage")
sampleIndex = 0;
else if (button.Content.ToString() == "Shape Geometries")
sampleIndex = 1;
else if (button.Content.ToString() == "PathGeometry")
sampleIndex = 2;
else if (button.Content.ToString() == "Combining Geometries Example")
sampleIndex = 3;
else if (button.Content.ToString() == "Geometry Attribute Syntax Example")
sampleIndex = 4;
}
}
示例15: 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;
}