Beispiel #1
0
        public void ReplaceVertex(Vert vo, Vert vnew, Vector2 newUV, Vector3 newVN, History his)
        {
            Vector3 vec             = vo.position;
            Vert    changedVertex   = v2;
            int     changedVertexId = 2;
            Vector3 changedNormal   = vn2;
            Vector2 changedUV       = uv2;

            if (vec == v0.position)
            {
                changedVertex   = v0;
                changedVertexId = 0;
                changedNormal   = vn0;
                changedUV       = uv0;
                v0  = vnew;
                vn0 = newVN;
                uv0 = newUV;
            }
            else if (vec == v1.position)
            {
                changedVertex   = v1;
                changedVertexId = 1;
                changedNormal   = vn1;
                changedUV       = uv1;
                v1  = vnew;
                vn1 = newVN;
                uv1 = newUV;
            }
            else
            {
                v2  = vnew;
                vn2 = newVN;
                uv2 = newUV;
            }

            vo.RemoveFace(this);
            vnew.AddFace(this);

            vo.RemoveIfNonNeighbor(v0);
            v0.RemoveIfNonNeighbor(vo);
            vo.RemoveIfNonNeighbor(v1);
            v1.RemoveIfNonNeighbor(vo);
            vo.RemoveIfNonNeighbor(v2);
            v2.RemoveIfNonNeighbor(vo);

            v0.AddNeighbor(v1);
            v0.AddNeighbor(v2);
            v1.AddNeighbor(v0);
            v1.AddNeighbor(v2);
            v2.AddNeighbor(v0);
            v2.AddNeighbor(v1);

            RecalculateNormal();

            his.ReplaceVertex(id, changedVertexId, changedVertex.id, changedNormal, changedUV, vnew.id, newVN, newUV);
        }
Beispiel #2
0
        public Tri(int id, Vert v0, Vert v1, Vert v2, Vector2 uv0, Vector2 uv1, Vector2 uv2)
        {
            this.id  = id;
            this.v0  = v0;
            this.v1  = v1;
            this.v2  = v2;
            this.uv0 = uv0;
            this.uv1 = uv1;
            this.uv2 = uv2;

            RecalculateNormal();

            v0.AddFace(this);
            v1.AddFace(this);
            v2.AddFace(this);

            v0.AddNeighbor(v1);
            v0.AddNeighbor(v2);
            v1.AddNeighbor(v0);
            v1.AddNeighbor(v2);
            v2.AddNeighbor(v0);
            v2.AddNeighbor(v1);
        }