Ejemplo n.º 1
0
        public void BuildFromGrid2(ICartGridData pointStripList)
        {
            int minStripLen = GetMinStripLength(pointStripList);
            int id          = 0;

            IPlyVertex[,] vertexGrid = new PlyVertex[pointStripList.Count, minStripLen];
            for (int i = 0; i < pointStripList.Count; i++)
            {
                for (int j = 0; j < minStripLen; j++)
                {
                    vertexGrid[i, j] = new PlyVertex(pointStripList[i][j], id++);
                    Vertices.Add(vertexGrid[i, j]);
                }
            }
            for (int i = 0; i < pointStripList.Count - 1; i++)
            {
                for (int j = 0; j < minStripLen - 1; j++)
                {
                    var indices1 = new List <int>()
                    {
                        vertexGrid[i, j].ID, vertexGrid[i, j + 1].ID, vertexGrid[i + 1, j].ID
                    };
                    Faces.Add(new PlyFace(indices1));
                    var indices2 = new List <int>()
                    {
                        vertexGrid[i, j + 1].ID, vertexGrid[i + 1, j + 1].ID, vertexGrid[i + 1, j].ID
                    };
                    Faces.Add(new PlyFace(indices2));
                }
            }
        }
        public void Reload(Shape shape, Mesh mesh)
        {
            //Load indices into the group
            var indices = mesh.GetIndices().ToArray();

            Faces.Clear();
            for (int i = 0; i < indices.Length; i++)
            {
                Faces.Add(indices[i]);
            }

            if (!PrimitiveTypes.ContainsKey(mesh.PrimitiveType))
            {
                throw new Exception($"Unsupported primitive type! {mesh.PrimitiveType}");
            }

            //Set the primitive type
            PrimitiveType = PrimitiveTypes[mesh.PrimitiveType];;

            switch (Stride)
            {
            case 2: DrawElementsType = DrawElementsType.UnsignedShort; break;

            case 4: DrawElementsType = DrawElementsType.UnsignedInt; break;

            case 1: DrawElementsType = DrawElementsType.UnsignedByte; break;
            }
        }
 /// <summary>
 /// Add all the faces of the mesh
 /// </summary>
 public void AddFaces()
 {
     for (int i = 0; i < (NU * NV); i++)
     {
         Faces.Add(new UVMeshFace(i, this));
     }
 }
Ejemplo n.º 4
0
        static protected void TraverseBSPTree(Vector3D origin, BSPTreeNode node, Faces faces)
        {
            if (node != null)
            {
                int sign = (int)Math3D.GetSign(node.Plane.GetDistanceToPlane(origin));

                if (sign > 0)
                {
                    TraverseBSPTree(origin, node.NegativeChild, faces);
                    foreach (Face face in node.Faces)
                    {
                        if (face.Visible == true)
                        {
                            faces.Add(face);
                        }
                    }
                    TraverseBSPTree(origin, node.PositiveChild, faces);
                }
                else                 /*if( sign <= 0 )*/
                {
                    TraverseBSPTree(origin, node.PositiveChild, faces);
                    TraverseBSPTree(origin, node.NegativeChild, faces);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Split the given face on the given plane. Remove the original face
        /// and add as many new faces as required for the split.
        /// </summary>
        /// <param name="faceIndex">The index of the face to split.</param>
        /// <param name="plane">The plane to split the face on. The face will not be split
        /// if it is not intersected by this plane.</param>
        /// <param name="onPlaneDistance">If a given edge of the face has a vertex that is within
        /// this distance of the plane, the edge will not be split.</param>
        /// <returns>Returns if the edge was actually split.</returns>
        public bool SplitFace(int faceIndex, Plane plane, double onPlaneDistance = .001)
        {
            var newVertices = new List <Vector3Float>();
            var newFaces    = new List <Face>();

            if (Faces[faceIndex].Split(this.Vertices, plane, newFaces, newVertices, onPlaneDistance))
            {
                var vertexCount = Vertices.Count;
                // remove the face index
                Faces.RemoveAt(faceIndex);
                // add the new vertices
                Vertices.AddRange(newVertices);
                // add the new faces (have to make the vertex indices to the new vertices
                foreach (var newFace in newFaces)
                {
                    Face faceNewIndices = newFace;
                    faceNewIndices.v0 += vertexCount;
                    faceNewIndices.v1 += vertexCount;
                    faceNewIndices.v2 += vertexCount;
                    Faces.Add(faceNewIndices);
                }

                CleanAndMerge();

                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
        // Methods

        public void AddFace(int faceIndex)
        {
            if (!IsFaceAlreadyAdded(faceIndex))
            {
                Faces.Add(faceIndex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor to build a custom mesh from Rhino's mesh type
        /// </summary>
        /// <param name="source">the Rhino mesh</param>
        public Mesh(Rhino.Geometry.Mesh source)
            : this()
        {
            // Check that the mesh is oriented and manifold
            bool isOriented, hasBoundary;
            var  isManifold = source.IsManifold(true, out isOriented, out hasBoundary);

            if (!isManifold || !isOriented)
            {
                return;
            }

            // Remove unused vertices
            source.Vertices.CullUnused();

            //var faces = Enumerable.Range(0, source.Faces.Count).Select(i => source.TopologyVertices.IndicesFromFace(i));
            //InitIndexed(source.TopologyVertices, faces);

            // Add vertices
            Vertices.Capacity = source.TopologyVertices.Count;
            foreach (Point3f p in source.TopologyVertices)
            {
                Vertices.Add(new Vertex(p));
            }

            // Add faces (and construct halfedges and store in hash table)
            for (int i = 0; i < source.Faces.Count; i++)
            {
                var vertices = source.TopologyVertices.IndicesFromFace(i).Select(v => Vertices[v]);
                Faces.Add(vertices);
            }

            // Find and link halfedge pairs
            Halfedges.MatchPairs();
        }
Ejemplo n.º 8
0
        private void make_rotation_figure(int cnt_breaks, Edge rot_line, List<Point3d> pts)
        {
             double angle = 360.0 / cnt_breaks;
             angle = angle / 180.0 * Math.PI;

            double Ax = rot_line.P1.X, Ay = rot_line.P1.Y, Az = rot_line.P1.Z;

            foreach (var p in pts)
                p.Apply(Transformation.Translate(-Ax, -Ay, -Az));

            List<Point3d> new_pts = new List<Point3d>();
            foreach (var p in pts)
                new_pts.Add(new Point3d(p.X, p.Y, p.Z));


            for (int i = 0; i < cnt_breaks; ++i)
            {
                foreach (var np in new_pts)
                    np.Apply(Transformation.RotateY(angle));
                for (int j = 1; j < pts.Count; ++j)
                {
                    Face f = new Face(new List<Point3d>(){ new Point3d(pts[j - 1]), new Point3d(new_pts[j - 1]),
                        new Point3d(new_pts[j]), new Point3d(pts[j])});
                    Faces.Add(f);
                }
                foreach (var p in pts)
                    p.Apply(Transformation.RotateY(angle));
            }

            find_center();
        }
Ejemplo n.º 9
0
        public int AddFace(int a, int b, int c, int mtl, int gen)
        {//不排重了
            if (a == b || b == c || a == c)
            {
                return(-1);
            }
            var f = new Face();

            f.A          = a;
            f.B          = b;
            f.C          = c;
            f.Mtl        = mtl;
            f.Gen        = gen;
            f.FaceNormal = Vector3.CalcFaceNormal(ref Vertices[a].Position,
                                                  ref Vertices[b].Position,
                                                  ref Vertices[c].Position);
            f.Area = Vector3.CalcArea3(ref Vertices[a].Position,
                                       ref Vertices[b].Position,
                                       ref Vertices[c].Position);
            f.Area = Math.Abs(f.Area) * 0.5f;
            Faces.Add(f);

            var index = Faces.Count - 1;

            Atoms[mtl].AddFace(index);
            return(index);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Добавление индексов треугольников.
        /// </summary>
        /// <param name="index0">
        /// Смещение индекса.
        /// </param>
        /// <param name="rows">
        /// The number of rows.
        /// </param>
        /// <param name="columns">
        /// Количество строк.
        /// </param>
        /// <param name="isSpherical">
        /// если флаг в значение true, то создатуся треугольники сверху и снизу (сферическая сетка).
        /// </param>
        public void AddIndices(int index0, int rows, int columns, bool isSpherical = false)
        {
            var face = new Face();

            for (int i = 0; i < rows - 1; i++)
            {
                for (int j = 0; j < columns - 1; j++)
                {
                    int ij = (i * columns) + j;
                    if (!isSpherical || i > 0)
                    {
                        Indices.Add(index0 + ij);
                        Indices.Add(index0 + ij + 1 + columns);
                        Indices.Add(index0 + ij + 1);

                        face.Indices.Add(index0 + ij);
                        face.Indices.Add(index0 + ij + 1);
                        face.Indices.Add(index0 + ij + 1 + columns);
                    }

                    if (!isSpherical || i < rows - 2)
                    {
                        Indices.Add(index0 + ij + 1 + columns);
                        Indices.Add(index0 + ij);
                        Indices.Add(index0 + ij + columns);

                        face.Indices.Add(index0 + ij + columns);
                        face.Indices.Add(index0 + ij + 1 + columns);
                        face.Indices.Add(index0 + ij);
                    }
                }
            }
            Faces.Add(face);
        }
Ejemplo n.º 11
0
        protected virtual void UpdatePoints()
        {
            double x = Width / 2;
            double z = Length / 2;

            List <Point3D> points = new List <Point3D>();

            points.Add(new Point3D(-x, 0, -z)); // bottom
            points.Add(new Point3D(-x, 0, z));
            points.Add(new Point3D(x, 0, 0));
            points.Add(new Point3D(x, 0, 0));

            points.Add(new Point3D(-x, Height, -z)); // top
            points.Add(new Point3D(-x, Height, z));
            points.Add(new Point3D(x, Height, 0));
            points.Add(new Point3D(x, Height, 0));

            Faces.Clear();
            Faces.Add(new Face(new Point3D[] { points[7], points[4], points[0] }));
            Faces.Add(new Face(new Point3D[] { points[0], points[3], points[7] }));
            Faces.Add(new Face(new Point3D[] { points[6], points[7], points[3] }));
            Faces.Add(new Face(new Point3D[] { points[2], points[6], points[3] }));
            Faces.Add(new Face(new Point3D[] { points[5], points[6], points[2] }));
            Faces.Add(new Face(new Point3D[] { points[1], points[5], points[2] }));
            Faces.Add(new Face(new Point3D[] { points[4], points[5], points[1] }));
            Faces.Add(new Face(new Point3D[] { points[0], points[4], points[1] }));
            Faces.Add(new Face(new Point3D[] { points[2], points[3], points[0] }));
            Faces.Add(new Face(new Point3D[] { points[1], points[2], points[0] }));
            Faces.Add(new Face(new Point3D[] { points[6], points[4], points[7] }));
            Faces.Add(new Face(new Point3D[] { points[6], points[5], points[4] }));

            // итого 12 = 6х2 faces на box
        }
Ejemplo n.º 12
0
        private void UpdatePoints()
        {
            double x = Width / 2;
            double z = Length / 2;

            List <Point3D> points = new List <Point3D>();

            points.Add(new Point3D(-x, 0, -z));
            points.Add(new Point3D(-x, 0, z));
            points.Add(new Point3D(x, 0, z));
            points.Add(new Point3D(x, 0, -z));
            points.Add(new Point3D(-x, Height, -z));
            points.Add(new Point3D(-x, Height, z));
            points.Add(new Point3D(x, Height, z));
            points.Add(new Point3D(x, Height, -z));

            Faces.Clear();
            Faces.Add(new Face(new Point3D[] { points[7], points[4], points[0] }));
            Faces.Add(new Face(new Point3D[] { points[0], points[3], points[7] }));
            Faces.Add(new Face(new Point3D[] { points[6], points[7], points[3] }));
            Faces.Add(new Face(new Point3D[] { points[2], points[6], points[3] }));
            Faces.Add(new Face(new Point3D[] { points[5], points[6], points[2] }));
            Faces.Add(new Face(new Point3D[] { points[1], points[5], points[2] }));
            Faces.Add(new Face(new Point3D[] { points[4], points[5], points[1] }));
            Faces.Add(new Face(new Point3D[] { points[0], points[4], points[1] }));
            Faces.Add(new Face(new Point3D[] { points[2], points[3], points[0] }));
            Faces.Add(new Face(new Point3D[] { points[1], points[2], points[0] }));
            Faces.Add(new Face(new Point3D[] { points[6], points[4], points[7] }));
            Faces.Add(new Face(new Point3D[] { points[6], points[5], points[4] }));
        }
Ejemplo n.º 13
0
    void ParseLine(string line)
    {
        Func <string [], Vec3f> parseV3f = strItems => new Vec3f {
            x = float.Parse(strItems [1], CultureInfo.InvariantCulture.NumberFormat),
            y = float.Parse(strItems [2], CultureInfo.InvariantCulture.NumberFormat),
            z = float.Parse(strItems [3], CultureInfo.InvariantCulture.NumberFormat)
        };

        var items = line.Split(new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

        if (line.StartsWith("v ", StringComparison.InvariantCulture))
        {
            Vertices.Add(parseV3f(items));
        }
        else if (line.StartsWith("vt ", StringComparison.InvariantCulture))
        {
            Textures.Add(parseV3f(items));
        }
        else if (line.StartsWith("vn ", StringComparison.InvariantCulture))
        {
            Normals.Add(parseV3f(items));
        }
        else if (line.StartsWith("f ", StringComparison.InvariantCulture))
        {
            var indexes = items.Skip(1)
                          .SelectMany(s => s.Split(new char [] { '/', ' ' }, StringSplitOptions.RemoveEmptyEntries))
                          .Select(s => int.Parse(s) - 1)                                    // in wavefront obj all indices start at 1, not zero
                          .ToArray();
            Faces.Add(new Face {
                Vertices = indexes.Where((v, index) => index % 3 == 0).ToArray(),
                Textures = indexes.Where((v, index) => index % 3 == 1).ToArray(),
                Normals  = indexes.Where((v, index) => index % 3 == 2).ToArray()
            });
        }
    }
Ejemplo n.º 14
0
 /// <summary>
 /// Add one or more Faces from a list to this set of entities.
 /// </summary>
 /// <param name="faces"></param>
 public void Add(IList<Face> faces)
 {
     foreach (Face face in faces)
     {
         Faces.Add(face);
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Add one or more Faces (or an array) to this set of entities.
 /// </summary>
 /// <param name="faces"></param>
 public void Add(params Face[] faces)
 {
     foreach (Face face in faces)
     {
         Faces.Add(face);
     }
 }
Ejemplo n.º 16
0
        private void UpdatePoints()
        {
            int    quater = Math.Max(SegmentsCount / 4 - 1, 1);
            double angle  = 360.0 / SegmentsCount;
            double sin    = Math.Sin(MathHelp.DegreesToRadians(-angle));
            double cos    = Math.Cos(MathHelp.DegreesToRadians(-angle));

            Point3D[,] points = new Point3D[quater, SegmentsCount + 1];
            points[0, 0]      = new Point3D(-Radius, 0, 0);
            for (int i = 1; i < quater; ++i)
            {
                double x = points[i - 1, 0].X * cos - points[i - 1, 0].Y * sin;
                double y = points[i - 1, 0].X * sin + points[i - 1, 0].Y * cos;
                points[i, 0] = new Point3D(x, y, 0);
            }
            Faces.Clear();

            for (int i = 1; i <= SegmentsCount; ++i)
            {
                for (int j = 0; j < quater; ++j)
                {
                    double x = points[j, i - 1].X * cos - points[j, i - 1].Z * sin;
                    double z = points[j, i - 1].X * sin + points[j, i - 1].Z * cos;
                    points[j, i] = new Point3D(x, points[j, i - 1].Y, z);
                    if (i > 0)
                    {
                        if (j > 0)
                        {
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j - 1, i - 1].X, points[j - 1, i - 1].Y, points[j - 1, i - 1].Z),
                                new Point3D(points[j - 1, i].X, points[j - 1, i].Y, points[j - 1, i].Z),
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z)
                            }));
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z),
                                new Point3D(points[j, i].X, points[j, i].Y, points[j, i].Z),
                                new Point3D(points[j - 1, i].X, points[j - 1, i].Y, points[j - 1, i].Z)
                            }));
                        }
                        else if (closeBottom)
                        {
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z),
                                new Point3D(points[j, i].X, points[j, i].Y, points[j, i].Z),
                                new Point3D(0, 0, 0)
                            }));
                        }
                        if (j == quater - 1)
                        {
                            Faces.Add(new Face(new Point3D[] {
                                new Point3D(points[j, i - 1].X, points[j, i - 1].Y, points[j, i - 1].Z),
                                new Point3D(points[j, i].X, points[j, i].Y, points[j, i].Z),
                                new Point3D(0, Radius, 0)
                            }));
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
 public void AddFace(Face face)
 {
     if (Faces.Contains(face))
     {
         throw new InvalidOperationException("Edge allready contains face!");
     }
     Faces.Add(face);
 }
        /// <summary>
        /// Produces a triangular pyramid with 4 faces.
        /// </summary>
        /// <param name="sideLength">The length the edges of the triangles should be in pixels.</param>
        /// <param name="height">The height of the triangle in pixels.</param>
        public ShapeTriangularPyramid(float sideLength, float height)
        {
            SideLength = sideLength;
            Height     = height;

            // Front is towards you
            // Back is away from you
            Vector3 front = new Vector3(
                0,
                sideLength / 2,
                height / 2 * -1
                );
            Vector3 backLeft = new Vector3(
                sideLength / 2,
                sideLength / 2 * -1,
                height / 2 * -1
                );
            Vector3 backRight = new Vector3(
                sideLength / 2 * -1,
                sideLength / 2 * -1,
                height / 2 * -1
                );

            Vector3 top = new Vector3(
                0,
                0,
                height / 2
                );

            FaceFrontLeft = new FaceTriangle(
                top,
                backLeft,
                front
                );

            FaceFrontRight = new FaceTriangle(
                top,
                front,
                backRight
                );

            FaceBack = new FaceTriangle(
                top,
                backLeft,
                backRight
                );

            FaceBottom = new FaceTriangle(
                front,
                backLeft,
                backRight
                );

            Faces.Add(FaceFrontLeft);
            Faces.Add(FaceFrontRight);
            Faces.Add(FaceBack);
            Faces.Add(FaceBottom);
        }
Ejemplo n.º 19
0
 public Face AddFace(Face face)
 {
     if (Faces.Any(f => f.IsMatchFor(face)))
     {
         throw new InvalidOperationException("There is allready such a face in the shape!");
     }
     Faces.Add(face);
     return(face);
 }
Ejemplo n.º 20
0
 public void AddCard(int value, string face)
 {
     Values.Add(value);
     Faces.Add(face);
     if (Values.Count >= 5)
     {
         Analyze();
     }
 }
Ejemplo n.º 21
0
        public Cross(double scale) : base()
        {
            for (int i = 0; i < _vertices.Count; i++)
            {
                _vertices[i] = _vertices[i] * scale;
            }

            Faces.Add(new Polygon(new Point[] { _vertices[1], _vertices[2], _vertices[3], _vertices[4], _vertices[5], _vertices[6], _vertices[7], _vertices[8], _vertices[9], _vertices[10], _vertices[11], _vertices[12] }));
        }
Ejemplo n.º 22
0
    public void InitFaces(Vector3 finalFaceNormal)
    {
        Faces.Add(m_FinalFaceCreator.Create(finalFaceNormal));

        foreach (var f in Faces)
        {
            f.AddMeshAndCachePoints(m_MeshPool, transform);
        }
    }
Ejemplo n.º 23
0
        /// <summary>
        /// Добавление грани куба.
        /// </summary>
        /// <param name="center">
        /// Центр Куба.
        /// </param>
        /// <param name="normal">
        /// Вектор нормали для грани.
        /// </param>
        /// <param name="up">
        /// Вектор вверх для грани.
        /// </param>
        /// <param name="dist">
        /// Расстояние от центра куба до грани.
        /// </param>
        /// <param name="width">
        /// Ширина грани.
        /// </param>
        /// <param name="height">
        /// Высота грани.
        /// </param>
        void AddCubeFace(Vector3 center, Vector3 normal, Vector3 up, float dist, float width, float height)
        {
            var right = Vector3.Cross(normal, up);
            var n     = normal * dist / 2;

            up    *= height / 2;
            right *= width / 2;
            var p1 = center + n - up - right;
            var p2 = center + n - up + right;
            var p3 = center + n + up + right;
            var p4 = center + n + up - right;

            int i0 = Positions.Count;

            Positions.Add(p1);
            Positions.Add(p2);
            Positions.Add(p3);
            Positions.Add(p4);
            if (Normals != null)
            {
                Normals.Add(normal);
                Normals.Add(normal);
                Normals.Add(normal);
                Normals.Add(normal);
            }

            Indices.Add(i0 + 2);
            Indices.Add(i0 + 1);
            Indices.Add(i0 + 0);
            Indices.Add(i0 + 0);
            Indices.Add(i0 + 3);
            Indices.Add(i0 + 2);

            // добавление граней
            var face = new Face();

            face.Indices.Add(i0 + 2);
            face.Indices.Add(i0 + 1);
            face.Indices.Add(i0 + 0);
            face.Indices.Add(i0 + 0);
            face.Indices.Add(i0 + 3);
            face.Indices.Add(i0 + 2);

            Faces.Add(face);

            // добавление ребер к граням
            var edge = new Edge();

            AddLine(edge, i0 + 0, i0 + 1);
            AddLine(edge, i0 + 1, i0 + 2);
            AddLine(edge, i0 + 2, i0 + 3);
            AddLine(edge, i0 + 3, i0 + 0);
            //AddLine(edge, i0 + 2, i0 + 1);
            face.Edges.Add(edge);
        }
Ejemplo n.º 24
0
        // Simulates the drawing of the edges into the designated face
        // and splits the face into two
        public void AddBridgeAndSeperateFace(List <Edge> edgesToAdd, Face face, Node[] pointsOfContract)
        {
            Face face1 = new Face();
            Face face2 = new Face();

            foreach (Edge edge in edgesToAdd)
            {
                AddNode(edge.Node1);
                AddNode(edge.Node2);
                AddEdge(edge);
                face1.AddNode(edge.Node1);
                face1.AddNode(edge.Node2);
                face1.AddEdge(edge);
                face2.AddNode(edge.Node1);
                face2.AddNode(edge.Node2);
                face2.AddEdge(edge);
            }
            Face oldFace  = face;
            Edge faceEdge = oldFace.Edges.First(e => e.Node1 == pointsOfContract[0] || e.Node2 == pointsOfContract[0]);
            Node prevNode = pointsOfContract[0];
            Node otherNode;

            while (faceEdge.Node1 != pointsOfContract[1] && faceEdge.Node2 != pointsOfContract[1])
            {
                face1.AddNode(faceEdge.Node1);
                face1.AddNode(faceEdge.Node2);
                face1.AddEdge(faceEdge);
                otherNode = faceEdge.OtherNode(prevNode);
                faceEdge  = oldFace.GetNextEdge(faceEdge, prevNode);
                prevNode  = otherNode;
            }
            face1.AddNode(faceEdge.Node1);
            face1.AddNode(faceEdge.Node2);
            face1.AddEdge(faceEdge);
            otherNode = faceEdge.OtherNode(prevNode);
            faceEdge  = oldFace.GetNextEdge(faceEdge, prevNode);
            prevNode  = otherNode;
            while (faceEdge.Node1 != pointsOfContract[0] && faceEdge.Node2 != pointsOfContract[0])
            {
                face2.AddNode(faceEdge.Node1);
                face2.AddNode(faceEdge.Node2);
                face2.AddEdge(faceEdge);
                otherNode = faceEdge.OtherNode(prevNode);
                faceEdge  = oldFace.GetNextEdge(faceEdge, prevNode);
                prevNode  = otherNode;
            }
            face2.AddNode(faceEdge.Node1);
            face2.AddNode(faceEdge.Node2);
            face2.AddEdge(faceEdge);

            Faces.Remove(oldFace);
            Faces.Add(face1);
            Faces.Add(face2);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Add a new face to this mesh.
        /// The vertex indices provided should reference valid vertices
        /// already added to this mesh.
        /// </summary>
        /// <param name="vertexIndices">The vertex indices which the
        /// face should join</param>
        /// <returns>The index of the new face</returns>
        public int AddFace(IEnumerable <int> vertexIndices)
        {
            var face = new MeshFace();

            foreach (int i in vertexIndices)
            {
                face.Add(Vertices[i]);
            }
            Faces.Add(face);
            return(Faces.Count - 1);
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Initialise a mesh with the specified vertices and faces.
 /// The vertices used should not already form part of any other geometry definition.
 /// </summary>
 /// <param name="verts"></param>
 /// <param name="faces"></param>
 public Mesh(VertexCollection verts, MeshFaceCollection faces) : this()
 {
     foreach (Vertex v in verts)
     {
         Vertices.Add(v);
     }
     foreach (MeshFace f in faces)
     {
         Faces.Add(f);
     }
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Initialise a mesh with the specified set of nodes.
 /// </summary>
 /// <param name="nodes">The collection of nodes.  Vertices will
 /// be created at the node locations and bound to the nodes.</param>
 /// <param name="addFace">If true, a face will be added to the mesh joining all of the
 /// vertices.</param>
 public Mesh(IList <Node> nodes, bool addFace = false) : this()
 {
     foreach (Node n in nodes)
     {
         Vertices.Add(new Vertex(n));
     }
     if (addFace)
     {
         Faces.Add(new MeshFace(Vertices));
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Creates a model of the tetrahedron. Transparency is applied to the color.
        /// </summary>
        /// <param name="color"></param>
        /// <param name="radius"></param>
        /// <returns>A model representing the tetrahedron</returns>
        public override void CreateFaces(Mesh mesh)
        {
            var points = new Point3DCollection(Enumerable.Range(0, 4).Select(i => GetPosition(i, mesh)));

            Faces.Clear();

            Faces.Add(new Triangle(points[0].ToLocationTimeValue(), points[1].ToLocationTimeValue(), points[2].ToLocationTimeValue()));
            Faces.Add(new Triangle(points[0].ToLocationTimeValue(), points[1].ToLocationTimeValue(), points[3].ToLocationTimeValue()));
            Faces.Add(new Triangle(points[0].ToLocationTimeValue(), points[2].ToLocationTimeValue(), points[3].ToLocationTimeValue()));
            Faces.Add(new Triangle(points[1].ToLocationTimeValue(), points[2].ToLocationTimeValue(), points[3].ToLocationTimeValue()));
        }
Ejemplo n.º 29
0
 public LetterDie(string[] faces) : base(faces.Length)
 {
     foreach (var f in faces)
     {
         Faces.Add(new LetterFace
         {
             Name    = f,
             Display = f,
             Value   = f
         });
     }
 }
Ejemplo n.º 30
0
        public void AddMap(string name, TextureMap map)
        {
            var type = GetFaceName(name);

            Faces.Add(type, map);
            Values.Clear();

            foreach (var(t, value) in Faces)
            {
                Values.Add(value);
            }
        }