Exemplo n.º 1
0
        public PainterMesh.MeshPoint InsertIntoTriangle(PainterMesh.Triangle a, Vector3 pos)
        {
            // Debug.Log("Inserting into triangle");
            var newVrt = new PainterMesh.MeshPoint(a.vertexes[0].meshPoint, pos);

            var w = a.DistanceToWeight(pos);

            var newV20 = a.vertexes[0].GetUv(0) * w.x + a.vertexes[1].GetUv(0) * w.y + a.vertexes[2].GetUv(0) * w.z;
            var newV21 = a.vertexes[0].GetUv(1) * w.x + a.vertexes[1].GetUv(1) * w.y + a.vertexes[2].GetUv(1) * w.z;

            var newUv = new PainterMesh.Vertex(newVrt, newV20, newV21);

            a.AssignWeightedData(newUv, w);

            meshPoints.Add(newVrt);

            var b = new PainterMesh.Triangle(a.vertexes).CopySettingsFrom(a);
            var c = new PainterMesh.Triangle(a.vertexes).CopySettingsFrom(a);

            a.Replace(0, newUv); //uvpnts[0] = newUV;
            b.Replace(1, newUv); // uvpnts[1] = newUV;
            c.Replace(2, newUv); // uvpnts[2] = newUV;

            triangles.Add(b);
            triangles.Add(c);


            if (Cfg.pixelPerfectMeshEditing)
            {
                newVrt.PixPerfect();
            }

            Dirty = true;
            return(newVrt);
        }
Exemplo n.º 2
0
        public PainterMesh.MeshPoint InsertIntoTriangleUniqueVertices(PainterMesh.Triangle a, Vector3 localPos)
        {
            var newVrt = new PainterMesh.MeshPoint(a.vertexes[0].meshPoint, localPos);

            meshPoints.Add(newVrt);

            var newUv = new PainterMesh.Vertex[3]; // (newVrt);

            var w = a.DistanceToWeight(localPos);

            //var newV20 = a.vertexes[0].GetUv(0) * w.x + a.vertexes[1].GetUv(0) * w.y + a.vertexes[2].GetUv(0) * w.z;
            //var newV21 = a.vertexes[0].GetUv(1) * w.x + a.vertexes[1].GetUv(1) * w.y + a.vertexes[2].GetUv(1) * w.z;
            //Color col = a.uvpnts[0]._color * w.x + a.uvpnts[1]._color * w.y + a.uvpnts[2]._color * w.z;
            for (var i = 0; i < 3; i++)
            {
                newUv[i] = new PainterMesh.Vertex(newVrt);//, newV20, newV21);
                a.AssignWeightedData(newUv[i], w);
            }

            var b = new PainterMesh.Triangle(a.vertexes).CopySettingsFrom(a);
            var c = new PainterMesh.Triangle(a.vertexes).CopySettingsFrom(a);

            a.vertexes[0] = newUv[0];
            b.vertexes[1] = newUv[1];
            c.vertexes[2] = newUv[2];

            triangles.Add(b);
            triangles.Add(c);

            a.MakeTriangleVertexUnique(a.vertexes[1]);
            b.MakeTriangleVertexUnique(b.vertexes[2]);
            c.MakeTriangleVertexUnique(c.vertexes[0]);


            if (Cfg.pixelPerfectMeshEditing)
            {
                newVrt.PixPerfect();
            }

            Dirty = true;
            return(newVrt);
        }