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


C# Point3DCollection.Clear方法代码示例

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


在下文中一共展示了Point3DCollection.Clear方法的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);
 }
开发者ID:samlcharreyron,项目名称:PedestrianTracker,代码行数:33,代码来源:WireLine.cs

示例2: 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

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

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

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

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

示例7: Triangulate

        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="indices"></param>
        /// <param name="textures"></param>
        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();

            // Fill the vertices, normals, and textures collections.
            for (int stack = 0; stack <= Stacks; stack++)
            {
                double y = Length - stack * Length / Stacks;

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices;
                    double x = -Radius * Math.Sin(theta);
                    double z = -Radius * Math.Cos(theta);

                    normals.Add(new Vector3D(x, 0, z));
                    vertices.Add(new Point3D(x, y, z));
                    textures.Add(new Point((double)slice / Slices,
                                           (double)stack / Stacks));
                }
            }

            // Fill the indices collection.
            for (int stack = 0; stack < Stacks; stack++)
            {
                for (int slice = 0; slice < Slices; slice++)
                {
                    indices.Add((stack + 0) * (Slices + 1) + slice);
                    indices.Add((stack + 1) * (Slices + 1) + slice);
                    indices.Add((stack + 0) * (Slices + 1) + slice + 1);

                    indices.Add((stack + 0) * (Slices + 1) + slice + 1);
                    indices.Add((stack + 1) * (Slices + 1) + slice);
                    indices.Add((stack + 1) * (Slices + 1) + slice + 1);
                }
            }
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:54,代码来源:HollowCylinderMesh.cs

示例8: Triangulate

        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="indices"></param>
        /// <param name="textures"></param>
        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();

            double x, y, z;
            int indexBase = 0;

            // Front side.
            // -----------
            z = Depth / 2;

            // Fill the vertices, normals, textures collections.
            for (int stack = 0; stack <= Stacks; stack++)
            {
                y = Height / 2 - stack * Height / Stacks;

                for (int slice = 0; slice <= Slices; slice++)
                {
                    x = -Width / 2 + slice * Width / Slices;
                    Point3D point = new Point3D(x, y, z);
                    vertices.Add(point);

                    normals.Add(point - new Point3D(x, y, 0));
                    textures.Add(new Point((double)slice / Slices,
                                           (double)stack / Stacks));
                }
            }

            // Fill the indices collection.
            for (int stack = 0; stack < Stacks; stack++)
            {
                for (int slice = 0; slice < Slices; slice++)
                {
                    indices.Add((stack + 0) * (Slices + 1) + slice);
                    indices.Add((stack + 1) * (Slices + 1) + slice);
                    indices.Add((stack + 0) * (Slices + 1) + slice + 1);
 
                    indices.Add((stack + 0) * (Slices + 1) + slice + 1);
                    indices.Add((stack + 1) * (Slices + 1) + slice);
                    indices.Add((stack + 1) * (Slices + 1) + slice + 1);
                }
            }

            // Rear side.
            // -----------
            indexBase = vertices.Count;
            z = -Depth / 2;

            // Fill the vertices, normals, textures collections.
            for (int stack = 0; stack <= Stacks; stack++)
            {
                y = Height / 2 - stack * Height / Stacks;

                for (int slice = 0; slice <= Slices; slice++)
                {
                    x = Width / 2 - slice * Width / Slices;
                    Point3D point = new Point3D(x, y, z);
                    vertices.Add(point);

                    normals.Add(point - new Point3D(x, y, 0));
                    textures.Add(new Point((double)slice / Slices,
                                           (double)stack / Stacks));
                }
            }

            // Fill the indices collection.
            for (int stack = 0; stack < Stacks; stack++)
            {
                for (int slice = 0; slice < Slices; slice++)
                {
                    indices.Add(indexBase + (stack + 0) * (Slices + 1) + slice);
                    indices.Add(indexBase + (stack + 1) * (Slices + 1) + slice);
                    indices.Add(indexBase + (stack + 0) * (Slices + 1) + slice + 1);

                    indices.Add(indexBase + (stack + 0) * (Slices + 1) + slice + 1);
                    indices.Add(indexBase + (stack + 1) * (Slices + 1) + slice);
                    indices.Add(indexBase + (stack + 1) * (Slices + 1) + slice + 1);
                }
            }

            // Left side.
            // -----------
            indexBase = vertices.Count;
            x = -Width / 2;
//.........这里部分代码省略.........
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:101,代码来源:BoxMesh.cs

示例9: Triangulate

        protected override void Triangulate(DependencyPropertyChangedEventArgs args, 
                                            Point3DCollection vertices, 
                                            Vector3DCollection normals, 
                                            Int32Collection indices, 
                                            PointCollection textures)
        {
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            Point3D[,] faces = Faces;
            PointCollection texturesBase = TextureCoordinates;
            int indexTextures = 0;

            for (int face = 0; face < faces.GetLength(0); face++)
            {
                Vector3D normal = Vector3D.CrossProduct(faces[face, 1] - faces[face, 0],
                                                        faces[face, 2] - faces[face, 0]);

                // For faces that are triangles.
                if (faces.GetLength(1) == 3)
                {
                    int indexBase = vertices.Count;

                    for (int i = 0; i < 3; i++)
                    {
                        vertices.Add(faces[face, i]);
                        normals.Add(normal);
                        indices.Add(indexBase + i);

                        if (texturesBase != null && texturesBase.Count > 0)
                        {
                            textures.Add(texturesBase[indexTextures]);
                            indexTextures = (indexTextures + 1) % texturesBase.Count;
                        }
                    }

                    if (Slices > 1)
                        TriangleSubdivide(vertices, normals, indices, textures);
                }

                // For faces that are not triangles.
                else
                {
                    for (int i = 0; i < faces.GetLength(1) - 1; i++)
                    {
                        int indexBase = vertices.Count;
                        int num = faces.GetLength(1) - 1;

                        vertices.Add(faces[face, 0]);
                        vertices.Add(faces[face, i + 1]);
                        vertices.Add(faces[face, (i + 1) % num + 1]);

                        if (texturesBase != null && texturesBase.Count >= faces.GetLength(1))
                        {
                            textures.Add(texturesBase[indexTextures + 0]);
                            textures.Add(texturesBase[indexTextures + i + 1]);
                            textures.Add(texturesBase[indexTextures + (i + 1) % num + 1]);
                        }

                        normals.Add(normal);
                        normals.Add(normal);
                        normals.Add(normal);

                        indices.Add(indexBase + 0);
                        indices.Add(indexBase + 1);
                        indices.Add(indexBase + 2);

                        if (Slices > 1)
                            TriangleSubdivide(vertices, normals, indices, textures);
                    }
                    if (texturesBase != null && texturesBase.Count > 0)
                        indexTextures = (indexTextures + faces.GetLength(1)) % texturesBase.Count;
                }
            }
        }
开发者ID:samlcharreyron,项目名称:PedestrianTracker,代码行数:77,代码来源:PolyhedronMeshBase.cs

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

示例11: Triangulate

        /// <summary>
        /// 
        /// </summary>
        /// <param name="args">
        ///     The DependencyPropertyChangedEventArgs object originally 
        ///     passed to the PropertyChanged handler that initiated this
        ///     recalculation.
        /// </param>
        /// <param name="vertices">
        ///     The Point3DCollection corresponding to the Positions property
        ///     of the MeshGeometry3D.
        /// </param>
        /// <param name="normals">
        ///     The Vector3DCollection corresponding to the Normals property
        ///     of the MeshGeometry3D.
        /// </param>
        /// <param name="indices">
        ///     The Int32Collection corresponding to the TriangleIndices
        ///     property of the MeshGeometry3D.
        /// </param>
        /// <param name="textures">
        ///     The PointCollection corresponding to the TextureCoordinates
        ///     property of the MeshGeometry3D.
        /// </param>
        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();

            // Loop for outside (side = 1) and inside (side = -1).
            for (int side = 1; side >= -1; side -= 2)
            {
                int offset = vertices.Count;

                // Begin at the top end. Fill the collections.
                for (int stack = 0; stack <= EndStacks; stack++)
                {
                    double y = Length;
                    double radius = Radius + side * stack * Thickness / 2 / EndStacks;
                    int top = offset + (stack + 0) * (Slices + 1);
                    int bot = offset + (stack + 1) * (Slices + 1);

                    for (int slice = 0; slice <= Slices; slice++)
                    {
                        double theta = slice * 2 * Math.PI / Slices;
                        double x = -radius * Math.Sin(theta);
                        double z = -radius * Math.Cos(theta);

                        vertices.Add(new Point3D(x, y, z));
                        normals.Add(new Vector3D(0, side, 0));
                        textures.Add(new Point((double)slice / Slices,
                                               Fold * stack / EndStacks));

                        if (stack < EndStacks && slice < Slices)
                        {
                            indices.Add(top + slice);
                            indices.Add(bot + slice);
                            indices.Add(top + slice + 1);

                            indices.Add(top + slice + 1);
                            indices.Add(bot + slice);
                            indices.Add(bot + slice + 1);
                        }
                    }
                }

                offset = vertices.Count;

                // Length of the tube: Fill in the collections.
                for (int stack = 0; stack <= Stacks; stack++)
                {
                    double y = Length - stack * Length / Stacks;
                    int top = offset + (stack + 0) * (Slices + 1);
                    int bot = offset + (stack + 1) * (Slices + 1);

                    for (int slice = 0; slice <= Slices; slice++)
                    {
                        double theta = slice * 2 * Math.PI / Slices;
                        double x = -(Radius + side * Thickness / 2) * Math.Sin(theta);
                        double z = -(Radius + side * Thickness / 2) * Math.Cos(theta);

                        vertices.Add(new Point3D(x, y, z));
                        normals.Add(new Vector3D(side * x, 0, side * z));
                        textures.Add(new Point((double)slice / Slices,
                                               Fold + (1 - 2 * Fold) * stack / Stacks));

                        if (stack < Stacks && slice < Slices)
                        {
                            indices.Add(top + slice);
                            indices.Add(bot + slice);
                            indices.Add(top + slice + 1);

                            indices.Add(top + slice + 1);
//.........这里部分代码省略.........
开发者ID:samlcharreyron,项目名称:PedestrianTracker,代码行数:101,代码来源:TubeMesh.cs

示例12: Triangulate

        // Define a plane consisting of two triangles.
        protected override void Triangulate(DependencyPropertyChangedEventArgs args, 
                                            Point3DCollection vertices, 
                                            Vector3DCollection normals, 
                                            Int32Collection indices, 
                                            PointCollection textures)
        {
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            if (TextGeometry == null)
                return;

            Rect rect = TextGeometry.Bounds;
            double top = 2 * Origin.Y - rect.Top;
            double bot = 2 * Origin.Y - rect.Bottom;

            // Define triangle vertices.
            vertices.Add(new Point3D(rect.Left, top, Z));
            vertices.Add(new Point3D(rect.Right, top, Z));
            vertices.Add(new Point3D(rect.Left, bot, Z));
            vertices.Add(new Point3D(rect.Right, bot, Z));

            // Define texture coordinates.
            textures.Add(new Point(0, 0));
            textures.Add(new Point(1, 0));
            textures.Add(new Point(0, 1));
            textures.Add(new Point(1, 1));

            // Define triangle indices.
            indices.Add(0);
            indices.Add(2);
            indices.Add(1);

            indices.Add(1);
            indices.Add(2);
            indices.Add(3);
        }
开发者ID:tianweidut,项目名称:3DMap,代码行数:40,代码来源:PlanarText.cs

示例13: Triangulate

        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        /// <param name="vertices"></param>
        /// <param name="normals"></param>
        /// <param name="indices"></param>
        /// <param name="textures"></param>
        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();

            // Begin at the top end. Fill the collections.
            for (int stack = 0; stack <= EndStacks; stack++)
            {
                double y = Length;
                double radius = stack * Radius / EndStacks;
                int top = (stack + 0) * (Slices + 1);
                int bot = (stack + 1) * (Slices + 1);

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices;
                    double x = -radius * Math.Sin(theta);
                    double z = -radius * Math.Cos(theta);

                    vertices.Add(new Point3D(x, y, z));
                    normals.Add(new Vector3D(0, 1, 0));
                    textures.Add(new Point((double)slice / Slices,
                                           Fold * stack / EndStacks));

                    if (stack < EndStacks && slice < Slices)
                    {
                        if (stack != 0)
                        {
                            indices.Add(top + slice);
                            indices.Add(bot + slice);
                            indices.Add(top + slice + 1);
                        }

                        indices.Add(top + slice + 1);
                        indices.Add(bot + slice);
                        indices.Add(bot + slice + 1);
                    }
                }
            }

            int offset = vertices.Count;

            // Length of the cylinder: Fill in the collections.
            for (int stack = 0; stack <= Stacks; stack++)
            {
                double y = Length - stack * Length / Stacks;
                int top = offset + (stack + 0) * (Slices + 1);
                int bot = offset + (stack + 1) * (Slices + 1);

                for (int slice = 0; slice <= Slices; slice++)
                {
                    double theta = slice * 2 * Math.PI / Slices;
                    double x = -Radius * Math.Sin(theta);
                    double z = -Radius * Math.Cos(theta);

                    vertices.Add(new Point3D(x, y, z));
                    normals.Add(new Vector3D(x, 0, z));
                    textures.Add(new Point((double)slice / Slices,
                                           Fold + (1 - 2 * Fold) * stack / Stacks));

                    if (stack < Stacks && slice < Slices)
                    {
                        indices.Add(top + slice);
                        indices.Add(bot + slice);
                        indices.Add(top + slice + 1);

                        indices.Add(top + slice + 1);
                        indices.Add(bot + slice);
                        indices.Add(bot + slice + 1);
                    }
                }
            }

            offset = vertices.Count;

            // Finish with the bottom end. Fill the collections.
            for (int stack = 0; stack <= EndStacks; stack++)
            {
                double y = 0;
                double radius = (EndStacks - stack) * Radius / EndStacks;
                int top = offset + (stack + 0) * (Slices + 1);
                int bot = offset + (stack + 1) * (Slices + 1);

                for (int slice = 0; slice <= Slices; slice++)
                {
//.........这里部分代码省略.........
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:101,代码来源:CylinderMesh.cs

示例14: Generate

        protected override void Generate(DependencyPropertyChangedEventArgs args,
                                         Point3DCollection lines)
        {
            lines.Clear();

            txtgen.Font = Font;
            txtgen.FontSize = FontSize;
            txtgen.Rounding = Rounding;
            txtgen.Thickness = Thickness;
            txtgen.BaselineDirection = BaselineDirection;
            txtgen.Origin = Origin;
            txtgen.UpDirection = UpDirection;
            txtgen.VerticalAlignment = VerticalAlignment;
            txtgen.HorizontalAlignment = HorizontalAlignment;

            txtgen.Generate(lines, Text);
        }
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:17,代码来源:WireText.cs

示例15: Triangulate

        protected override void Triangulate(DependencyPropertyChangedEventArgs args,
                                            Point3DCollection vertices, 
                                            Vector3DCollection normals, 
                                            Int32Collection indices, 
                                            PointCollection textures)
        {
            vertices.Clear();
            normals.Clear();
            indices.Clear();
            textures.Clear();

            // Front.
            for (int iy = 0; iy <= Stacks; iy++)
            {
                double y = Origin.Y + Height - iy * Height / Stacks;

                for (int ix = 0; ix <= Slices; ix++)
                {
                    double x = Origin.X + ix * Width / Slices;
                    vertices.Add(new Point3D(x, y, Origin.Z + Depth));
                }
            }

            // Back
            for (int iy = 0; iy <= Stacks; iy++)
            {
                double y = Origin.Y + Height - iy * Height / Stacks;

                for (int ix = 0; ix <= Slices; ix++)
                {
                    double x = Origin.X + Width - ix * Width / Slices;
                    vertices.Add(new Point3D(x, y, Origin.Z));
                }
            }

            // Left
            for (int iy = 0; iy <= Stacks; iy++)
            {
                double y = Origin.Y + Height - iy * Height / Stacks;

                for (int iz = 0; iz <= Slivers; iz++)
                {
                    double z = Origin.Z + iz * Depth / Slivers;
                    vertices.Add(new Point3D(Origin.X, y, z));
                }
            }

            // Right
            for (int iy = 0; iy <= Stacks; iy++)
            {
                double y = Origin.Y + Height - iy * Height / Stacks;

                for (int iz = 0; iz <= Slivers; iz++)
                {
                    double z = Origin.Z + Depth - iz * Depth / Slivers;
                    vertices.Add(new Point3D(Origin.X + Width, y, z));
                }
            }

            // Top
            for (int iz = 0; iz <= Slivers; iz++)
            {
                double z = Origin.Z + iz * Depth / Slivers;

                for (int ix = 0; ix <= Slices; ix++)
                {
                    double x = Origin.X + ix * Width / Slices;
                    vertices.Add(new Point3D(x, Origin.Y + Height, z));
                }
            }

            // Top
            for (int iz = 0; iz <= Slivers; iz++)
            {
                double z = Origin.Z + Depth - iz * Depth / Slivers;

                for (int ix = 0; ix <= Slices; ix++)
                {
                    double x = Origin.X + ix * Width / Slices;
                    vertices.Add(new Point3D(x, Origin.Y, z));
                }
            }

            for (int side = 0; side < 6; side++)
            {
                for (int iy = 0; iy <= Stacks; iy++)
                {
                    double y = (double)iy / Stacks;

                    for (int ix = 0; ix <= Slices; ix++)
                    {
                        double x = (double)ix / Slices;
                        textures.Add(new Point(x, y));
                    }
                }
            }

            // Front, back, left, right
            for (int side = 0; side < 6; side++)
            {
//.........这里部分代码省略.........
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:101,代码来源:Cuboid.cs


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