本文整理汇总了C#中System.Windows.Media.Int32Collection类的典型用法代码示例。如果您正苦于以下问题:C# Int32Collection类的具体用法?C# Int32Collection怎么用?C# Int32Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Int32Collection类属于System.Windows.Media命名空间,在下文中一共展示了Int32Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
}
}
示例3: 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);
}
}
}
示例4: 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;
}
示例5: Terrain3D
static Terrain3D()
{
{
SX = new double[17];
SZ = new double[17];
int i = 0;
for (double d = 0; d < 2; d += 0.125)
{
i++;
SX[i] = Math.Cos(Math.PI * d);
SZ[i] = Math.Sin(Math.PI * d);
}
}
{
TEXTURE_COORDINATES = new PointCollection(17);
TEXTURE_COORDINATES.Add(new Point(0, 0));
Point p = new Point(1, 0);
int i = -1;
while (++i < 16) TEXTURE_COORDINATES.Add(p);
TEXTURE_COORDINATES.Freeze();
}
{
TRIANGLE_INDICES = new Int32Collection(48);
for (int i = 1; i < 16; i++)
{
TRIANGLE_INDICES.Add(0);
TRIANGLE_INDICES.Add(i + 1);
TRIANGLE_INDICES.Add(i);
}
TRIANGLE_INDICES.Add(0);
TRIANGLE_INDICES.Add(1);
TRIANGLE_INDICES.Add(16);
TRIANGLE_INDICES.Freeze();
}
}
示例6: 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);
}
示例7: GetArrowIndices
public Int32Collection GetArrowIndices()
{
Int32Collection cArrowIndices = new Int32Collection();
for (int i = 0; i < number_of_segments; i++)
{
if (i < number_of_segments - 1)
{
cArrowIndices.Add(0);
cArrowIndices.Add(i + 2);
cArrowIndices.Add(i + 1);
}
else // last
{
cArrowIndices.Add(0);
cArrowIndices.Add(1);
cArrowIndices.Add(i + 1);
}
}
// annulus
for (int i = 0; i < number_of_segments; i++)
{
if (i < number_of_segments - 1)
{
CreateRectangle_CCW(cArrowIndices, i + 1, i + 2, i + 2 + number_of_segments, i + 1 + number_of_segments);
}
else // last
{
CreateRectangle_CCW(cArrowIndices, i + 1, 1, 1 + number_of_segments, i + 1 + number_of_segments);
}
}
return cArrowIndices;
}
示例8: Pokemon3D
static Pokemon3D()
{
TEXTURE_COORDINATES = new PointCollection(new Point[]
{ new Point(0, 1), new Point(0, 0), new Point(1, 1), new Point(1, 0) });
TRIANGLE_INDICES = new Int32Collection(new int[] { 0, 2, 1, 3, 1, 2 });
TEXTURE_COORDINATES.Freeze();
TRIANGLE_INDICES.Freeze();
}
示例9: 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;
}
示例10: AdaptableDateTimeAxis
public AdaptableDateTimeAxis()
{
SecondIncrements = new Int32Collection(new int[] { 1, 2, 5, 15, 30 });
MinuteIncrements = new Int32Collection(new int[] { 1, 2, 5, 15, 30 });
HourIncrements = new Int32Collection(new int[] { 1, 2, 4, 6, 12 });
DayIncrements = new Int32Collection(new int[] { 1, 2, 5, 10 });
MonthIncrements = new Int32Collection(new int[] { 1, 2, 4, 6 });
YearIncrements = new Int32Collection(new int[] { 1, 2, 5 });
}
示例11: CreateRectangle_CW
public void CreateRectangle_CW(Int32Collection ArrowIndices, int i0, int i1, int i2, int i3)
{
ArrowIndices.Add(i0);
ArrowIndices.Add(i2);
ArrowIndices.Add(i1);
ArrowIndices.Add(i0);
ArrowIndices.Add(i3);
ArrowIndices.Add(i2);
}
示例12: MeshBuilder
/// <summary>
/// Initializes a new instance of the <see cref="MeshBuilder"/> class.
/// </summary>
/// <param name="generateNormals">generate normals</param>
/// <param name="generateTextureCoordinates">generate texture coordinates</param>
public MeshBuilder(bool generateNormals, bool generateTextureCoordinates)
{
positions = new Point3DCollection();
triangleIndices = new Int32Collection();
if (generateNormals)
normals = new Vector3DCollection();
if (generateTextureCoordinates)
textureCoordinates = new PointCollection();
}
示例13: ProcessFigure
// ProcessFigure override.
protected override void ProcessFigure(CircularList<Point> list,
Point3DCollection vertices,
Vector3DCollection normals,
Int32Collection indices,
PointCollection textures)
{
int k = Slices * list.Count;
int offset = vertices.Count;
for (int i = 0; i < list.Count; i++)
{
Point ptBefore = list[i - 1];
Point pt = list[i];
Point ptAfter = list[i + 1];
Vector v1 = pt - ptBefore;
v1.Normalize();
Vector v1Rotated = new Vector(-v1.Y, v1.X);
Vector v2 = ptAfter - pt;
v2.Normalize();
Vector v2Rotated = new Vector(-v2.Y, v2.X);
Line2D line1 = new Line2D(pt, ptBefore);
Line2D line2 = new Line2D(pt, ptAfter);
for (int slice = 0; slice < Slices; slice++)
{
// Angle ranges from 0 to 360 degrees.
double angle = slice * 2 * Math.PI / Slices;
double scale = EllipseWidth / 2 * Math.Sin(angle);
double depth = -Depth / 2 * (1 - Math.Cos(angle));
Line2D line1Shifted = line1 + scale * v1Rotated;
Line2D line2Shifted = line2 + scale * v2Rotated;
Point ptIntersect = line1Shifted * line2Shifted;
// Set vertex.
vertices.Add(new Point3D(ptIntersect.X, ptIntersect.Y, depth));
// Set texture coordinate.
textures.Add(new Point((double)i / list.Count,
Math.Sin(angle / 2)));
// Set triangle indices.
indices.Add(offset + (Slices * i + slice + 0) % k);
indices.Add(offset + (Slices * i + slice + 1) % k);
indices.Add(offset + (Slices * i + slice + 0 + Slices) % k);
indices.Add(offset + (Slices * i + slice + 0 + Slices) % k);
indices.Add(offset + (Slices * i + slice + 1) % k);
indices.Add(offset + (Slices * i + slice + 1 + Slices) % k);
}
}
}
示例14: SegmentCollectionVisual3D
public SegmentCollectionVisual3D()
{
Positions = new Point3DCollection();
SegmentIndices = new Int32Collection();
Fill = Brushes.Blue;
Diameter = 0.1;
ThetaDiv = 37;
_element = new ModelVisual3D();
Children.Add(_element);
}
示例15: get3DWalls
/// <summary>
/// This method returns a 3D representation of this building walls
/// </summary>
/// <param name="nodesDict">List of all the nodes on the map</param>
/// <param name="map">bounds of the map</param>
/// <param name="brush">Color of these walls</param>
/// <returns>ModelUIElement3D of these walls</returns>
public ModelUIElement3D get3DWalls(Dictionary<long, OsmSharp.Osm.Node> nodesDict, Map map, ImageBrush brush)
{
// Surrounding tags of the mesh
ModelUIElement3D model = new ModelUIElement3D();
GeometryModel3D geometryModel = new GeometryModel3D();
// Mesh and his his properties
MeshGeometry3D mesh = new MeshGeometry3D();
DiffuseMaterial material = new DiffuseMaterial((System.Windows.Media.Brush)brush);
Point3DCollection positions = new Point3DCollection();
PointCollection texturePoints = new PointCollection();
Int32Collection indices = new Int32Collection();
// Add Points of surface and with add points of surface with height 0
positions = getScaledPositionsWall(nodesDict, map);
// Add indices to the collection
for (int i = 0; i < positions.Count - 2; i += 2) {
indices.Add(i);
indices.Add(i + 2);
indices.Add(i + 1);
indices.Add(i + 3);
indices.Add(i + 1);
indices.Add(i + 2);
// Get the width and height of a wall
float widthWall = (float)Math.Sqrt(Math.Pow(positions[i].X - positions[i + 2].X, 2) + Math.Pow(positions[i].Y - positions[i + 2].Y, 2));
int imageWidth = (int)(brush.ImageSource.Width * widthWall);
int imageHeight = (int)(brush.ImageSource.Height * height);
// Add texture coordinates
texturePoints.Add(new System.Windows.Point(0, imageHeight));
texturePoints.Add(new System.Windows.Point(0, 0));
texturePoints.Add(new System.Windows.Point(imageWidth, imageHeight));
texturePoints.Add(new System.Windows.Point(imageWidth, 0));
}
// Add these collections to the mesh
mesh.Positions = positions;
mesh.TriangleIndices = indices;
mesh.TextureCoordinates = texturePoints;
// Set the color of front and back of the triangle
geometryModel.Material = material;
geometryModel.BackMaterial = material;
// Add the mesh to the model
geometryModel.Geometry = mesh;
model.Model = geometryModel;
return model;
}