当前位置: 首页>>代码示例>>C#>>正文


C# Int32Collection.Add方法代码示例

本文整理汇总了C#中System.Windows.Media.Int32Collection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Int32Collection.Add方法的具体用法?C# Int32Collection.Add怎么用?C# Int32Collection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Int32Collection的用法示例。


在下文中一共展示了Int32Collection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:58,代码来源:MainViewModel.xaml.cs

示例2: CombineIndexCollection

        public static Int32Collection CombineIndexCollection(Int32Collection initialIndices, List<int> addingIndices, int offset)
        {

            var ret = new Int32Collection(initialIndices.Count + addingIndices.Count);
            foreach (var origIndex in initialIndices)
            {
                ret.Add(origIndex);
            }
            foreach (var origIndex in addingIndices)
            {
                ret.Add(origIndex + offset);
            }
            return ret;
        }
开发者ID:tnesser,项目名称:XbimWindowsUI,代码行数:14,代码来源:GeomUtils.cs

示例3: 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);
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:25,代码来源:ModelVisual.cs

示例4: updateMesh

 public void updateMesh( Point3DCollection verticies,
                         Vector3DCollection normals)
 {
     Int32Collection triangleIndices = new Int32Collection();
     for (int i = 0; i < verticies.Count/3; i++)
     {
         triangleIndices.Add(i*3);
         triangleIndices.Add(i*3+1);
         triangleIndices.Add(i*3+2);
     }
     
     this.mesh.TriangleIndices = triangleIndices; 
     this.mesh.Positions = verticies;
     this.mesh.Normals = normals;
     this.InvalidateVisual();
 }
开发者ID:yeuchi,项目名称:DecoderExercise,代码行数:16,代码来源:Wireframe.xaml.cs

示例5: CalculateGeometry

        protected override void CalculateGeometry()
        {
            int numberOfSeparators = 4 * n + 4;

            points = new Point3DCollection(numberOfSeparators + 1);
            triangleIndices = new Int32Collection((numberOfSeparators + 1) * 3);

            points.Add(new Point3D(0, 0, 0));
            for (int divider = 0; divider < numberOfSeparators; divider++)
            {
                double alpha = Math.PI / 2 / (n + 1) * divider;
                points.Add(new Point3D(r * Math.Cos(alpha), 0, -1 * r * Math.Sin(alpha)));

                triangleIndices.Add(0);
                triangleIndices.Add(divider + 1);
                triangleIndices.Add((divider == (numberOfSeparators - 1)) ? 1 : (divider + 2));
            }
        }
开发者ID:hcilab-um,项目名称:STim,代码行数:18,代码来源:DiscGeometry3D.cs

示例6: get3DSurface

        /// <summary>
        /// This method returns a 3D representation of this area
        /// </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 this area</param>
        /// <returns>ModelUIElement3D of this area</returns>
        public virtual ModelUIElement3D get3DSurface(Dictionary<long, OsmSharp.Osm.Node> nodesDict, Map map, System.Windows.Media.SolidColorBrush brush) {
            List<PointF> ptlist = getScaledPointsSurface(nodesDict, map);

            // Divide the polygons in triangles, this is code (and these two classes) are from: https://polygontriangulation.codeplex.com/
            PolygonData poly = new PolygonData(ptlist);
            List<PointF[]> triangles = Triangulation2D.Triangulate(poly);

            // 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();
            Int32Collection indices = new Int32Collection();

            // Add points and indices to their collection
            foreach (PointF[] points in triangles) {
                foreach (PointF point in points) {
                    positions.Add(new Point3D(point.X, point.Y, height));
                }

                int count = positions.Count;
                indices.Add(count - 3);
                indices.Add(count - 2);
                indices.Add(count - 1);
            }

            // Add these collections to the mesh
            mesh.Positions = positions;
            mesh.TriangleIndices = indices;

            // 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;
        }
开发者ID:whztt07,项目名称:Osm3DBuildingGenerator,代码行数:50,代码来源:Area.cs

示例7: AddGeometry

        public static void AddGeometry(this ModelVisual3D visual, GeometryModel3D geometry)
        {
            if (visual.Content == null)
                visual.Content = geometry;
            else
            {
                if (visual.Content is Model3DGroup)
                {
                    GeometryModel3D m3d = (GeometryModel3D)((Model3DGroup)visual.Content).Children.First();
                    MeshGeometry3D main = (MeshGeometry3D)(m3d.Geometry);
                    MeshGeometry3D toAdd = (MeshGeometry3D)(geometry.Geometry);
                    Point3DCollection pc = new Point3DCollection(main.Positions.Count + toAdd.Positions.Count);
                    foreach (var pt in main.Positions) pc.Add(pt);
                    foreach (var pt in toAdd.Positions)
                    {
                        pc.Add(geometry.Transform.Transform(pt));
                    }
                    main.Positions = pc;

                    Vector3DCollection vc = new Vector3DCollection(main.Normals.Count + toAdd.Normals.Count);
                    foreach (var v in main.Normals) vc.Add(v);
                    foreach (var norm in toAdd.Normals) vc.Add(norm);
                    main.Normals = vc;

                    int maxIndices = main.Positions.Count; //we need to increment all indices by this amount
                    foreach (var i in toAdd.TriangleIndices) main.TriangleIndices.Add(i + maxIndices);
                    Int32Collection tc = new Int32Collection(main.TriangleIndices.Count + toAdd.TriangleIndices.Count);
                    foreach (var i in main.TriangleIndices) tc.Add(i);
                    foreach (var i in toAdd.TriangleIndices) tc.Add(i + maxIndices);
                    main.TriangleIndices = tc;

                }
                //it is not a group but now needs to be
                else
                {
                    Model3DGroup m3dGroup = new Model3DGroup();
                    m3dGroup.Children.Add(visual.Content);
                    m3dGroup.Children.Add(geometry);
                    visual.Content = m3dGroup;
                }
            }
        }
开发者ID:bnaand,项目名称:xBim-Toolkit,代码行数:42,代码来源:ModelVisual3DExtensions.cs

示例8: Display

        private void Display()
        {
            viewport.Children.Remove(modViz);

            var CVPoints = new Point3DCollection();
            foreach (var chV in convexHullVertices)
            {
                CVPoints.Add(chV.Center);
            }
            
            var faceTris = new Int32Collection();
            foreach (var f in faces)
            {
                // The vertices are stored in clockwise order.
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[0]));
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[1]));
                faceTris.Add(convexHullVertices.IndexOf(f.Vertices[2]));
            }
            var mg3d = new MeshGeometry3D
            {
                Positions = CVPoints,
                TriangleIndices = faceTris
            };

            var material = new MaterialGroup
            {
                Children = new MaterialCollection
                {
                    new DiffuseMaterial(Brushes.Red),
                    new SpecularMaterial(Brushes.Beige, 2.0)
                }
            };

            var geoMod = new GeometryModel3D
            {
                Geometry = mg3d,
                Material = material
            };

            modViz = new ModelVisual3D { Content = geoMod };
            viewport.Children.Add(modViz);
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:42,代码来源:MainWindow.xaml.cs

示例9: 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);
                }
            }
        }
开发者ID:tianweidut,项目名称:3DMap,代码行数:33,代码来源:RibbonText.cs

示例10: 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();
       }
 }
开发者ID:sunoru,项目名称:PBO,代码行数:35,代码来源:Terrain.cs

示例11: 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;
        }
开发者ID:777ondro,项目名称:sw-en,代码行数:35,代码来源:Arrow3DTip.cs

示例12: 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);
		}
开发者ID:mkandroid15,项目名称:Samples,代码行数:32,代码来源:WheelMesh.cs

示例13: 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;
        }
开发者ID:MathiasBrannstrom,项目名称:SoundToColor,代码行数:29,代码来源:SimpleGeometry3D.cs

示例14: Triangle

        private GeometryModel3D Triangle(double x, double y, double s, SolidColorBrush color)
        {
            Point3DCollection corners = new Point3DCollection();
            corners.Add(new Point3D(x, y, 0));
            corners.Add(new Point3D(x, y + s, 0));
            corners.Add(new Point3D(x + s, y + s, 0));

            Int32Collection Triangles = new Int32Collection();
            Triangles.Add(0);
            Triangles.Add(1);
            Triangles.Add(2);

            MeshGeometry3D tmesh = new MeshGeometry3D();
            tmesh.Positions = corners;
            tmesh.TriangleIndices = Triangles;
            tmesh.Normals.Add(new Vector3D(0, 0, -1));

            GeometryModel3D msheet = new GeometryModel3D();
            msheet.Geometry = tmesh;
            msheet.Material = new DiffuseMaterial(color);
            return msheet;
        }
开发者ID:JulianKemmerer,项目名称:Drexel-SeniorDesign,代码行数:22,代码来源:MainWindow.xaml.cs

示例15: TriangleMeshAdapater

        public TriangleMeshAdapater(MFnMesh mesh)
        {
            MIntArray indices = new MIntArray();
            MIntArray triangleCounts = new MIntArray();
            MPointArray points = new MPointArray();

            mesh.getTriangles(triangleCounts, indices);
            mesh.getPoints(points);

            // Get the triangle indices
            Indices = new Int32Collection((int)indices.length);
            for (int i = 0; i < indices.length; ++i)
                Indices.Add(indices[i]);

            // Get the control points (vertices)
            Points = new Point3DCollection((int)points.length);
            for (int i = 0; i < (int)points.length; ++i)
            {
                MPoint pt = points[i];
                Points.Add(new Point3D(pt.x, pt.y, pt.z));
            }

            // Get the number of triangle faces and polygon faces 
            Debug.Assert(indices.length % 3 == 0);
            int triFaces = (int)indices.length / 3;
            int polyFaces = mesh.numPolygons;

            // We have normals per polygon, we want one per triangle. 
            Normals = new Vector3DCollection(triFaces);
            int nCurrentTriangle = 0;

            // Iterate over each polygon
            for (int i = 0; i < polyFaces; ++i)
            {
                // Get the polygon normal
                var maya_normal = new MVector();
                mesh.getPolygonNormal((int)i, maya_normal);
                System.Windows.Media.Media3D.Vector3D normal = new System.Windows.Media.Media3D.Vector3D(maya_normal.x, maya_normal.y, maya_normal.z);

                // Iterate over each tri in the current polygon
                int nTrisAtFace = triangleCounts[i];
                for (int j = 0; j < nTrisAtFace; ++j)
                {
                    Debug.Assert(nCurrentTriangle < triFaces);
                    Normals.Add(normal);
                    nCurrentTriangle++;
                }
            }
            Debug.Assert(nCurrentTriangle == triFaces);
        }
开发者ID:meshdgp,项目名称:MeshDGP,代码行数:50,代码来源:TriangleMeshAdapater.cs


注:本文中的System.Windows.Media.Int32Collection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。