Beispiel #1
0
        public void AddFace(Vector3[] positions)
        {
            int length = positions.Length;

            HE_Vertex[] vertices = new HE_Vertex[length];
            HE_Edge[]   edges    = new HE_Edge[length];
            HE_Face     face     = new HE_Face();

            for (int i = 0; i < length; ++i)
            {
                vertices[i] = new HE_Vertex();
                edges[i]    = new HE_Edge();
            }

            for (int i = 0; i < length; ++i)
            {
                vertices[i].pos_  = positions[i];
                vertices[i].edge_ = edges[i];

                edges[i].vert_ = vertices[i];
                edges[i].next_ = edges[(i + 1) % length];
                edges[i].prev_ = edges[(i + length - 1) % length];
                edges[i].face_ = face;
            }

            face.edge_ = edges[0];
            faces.Add(face);
        }
Beispiel #2
0
        void SolvePair(HE_Face face)
        {
            HE_Edge edge = face.edge_;

            do
            {
                foreach (HE_Face f in faces)
                {
                    if (f == face)
                    {
                        continue;
                    }

                    HE_Edge pair = f.FindEdge(edge.next_.vert_.pos_, edge.vert_.pos_);
                    if (pair != null)
                    {
                        edge.pair_ = pair;
                        pair.pair_ = edge;
                        break;
                    }
                }
                edge = edge.next_;
            } while (edge != face.edge_);
        }