Uv's to Flat Mesh


#1

Hi forum,

I don’t know if I’m imagining it but I remember I saw something very recently released on the forum that would convert Uv’s to a flat mesh object. There is a similar function in SouP but wondering and looking for something easier.

Is there an easy way to get a flat mesh object based on UVs?

Thanks.


#2

Select all your uv seams and detach component, then transfer attributes (vertex position) to a flat plane with sampling space set to UV.

I can post some screenshots if needed.


#3

Thank you.
I’ll give this a go on my own and see if I can get it working first, seems pretty straight forward.

Thanks again.


#4

or use mudbox…
or this script…

{
string $selection[] = ls -sl;

int $numVert[];
int $numUVs[];
string $vert[];
float $uv[];
float $v;
float $u;
string $temp[];
string $flat;
string $orig;
string $blendShape;
string $BSN;
if (size($selection) > 0)
{
    for ($s in $selection)
    {
         $s = `match "[^|]*$" $s`;
        $temp = `ls $s`;
        if (size($temp) == 1)
        {
            int $isCut = 0;
            $numVert = `polyEvaluate -vertex $s`;
            $numUVs = `polyEvaluate -uv $s`;
            $temp = `duplicate -n ($s+"_orig") $s`;
            $orig = $temp[0];
            print $numVert;
            print "

“;
print $numUVs;
if ($numVert[0] < $numUVs[0])
{
polySplitEdge -ch 0 ($orig+”.e[li]");
[/li] $isCut = 1;
$numVert = polyEvaluate -vertex $orig;
$numUVs = polyEvaluate -uv $orig;
}

            $temp = `duplicate -n ($s+"_flat" )$orig`;
            $flat = $temp[0];
            $temp = `duplicate -n ($s+"_bs" )$orig`;
            $blendShape = $temp[0];
            print $s;
            for($i = 0; $i &lt; $numUVs[0]; $i++)
            {
                $vert = `polyListComponentConversion -fuv -tv ($flat+".map["+$i+"]")`;
                $uv = `polyEditUV -q ($flat+".map["+$i+"]")`;
                $u = $uv[0];
                $v = $uv[1] * -1;
                for ($vtx in $vert) move -absolute -worldSpace $u 0 $v $vtx;
            }
            
            // scale according to 3d data;
            string $vert1[] = `polyListComponentConversion -fe -tv ($orig+".e[0]")`;
            $vert1 = `ls -fl $vert1`;
            string $vert2[] = `polyListComponentConversion -fe -tv ($flat+".e[0]")`;
            $vert2 = `ls -fl $vert2`;
            vector $v10 = `xform -q -ws -t $vert1[0]`;
            vector $v11 = `xform -q -ws -t $vert1[1]`;
            float $length1 = `mag ($v10 - $v11)`;
            vector $v20 = `xform -q -ws -t $vert2[0]`;
            vector $v21 = `xform -q -ws -t $vert2[1]`;
            float $length2 = `mag ($v20 - $v21)`;
            float $factor = $length1 / $length2;
            scale -pivot 0 0 0 $factor $factor $factor ($flat+".vtx[li]");

[/li]

            addAttr -k 1 -dv 1 -min 0 -max 1 -ln "flatten" $blendShape;
            $temp = `blendShape -n ("BSN_"+$s+"_flat") $flat $blendShape`;
            $BSN = $temp[0];
            connectAttr ($blendShape+".flatten") ($BSN+".weight[0]");
            delete $orig;
            delete $flat;
            
            // make Cut mesh nice
            if ($isCut)
            {
                $blendShape = `rename $blendShape "soonGone"`;
                $temp = `duplicate -n ($s+"_flat") $blendShape`;
                $flat = $temp[0];
                $temp = `listRelatives -shapes $flat`;
                for ($sh in $temp)
                {
                    if (`getAttr ($sh+".intermediateObject")`) delete $sh;
                }
                polyMergeVertex  -d 0.0001 -ch 0 $flat;  
                select -r $flat $blendShape;
                string $wrap = `CreateWrap`;
                               
                setAttr ($blendShape+".flatten") 0;
                $temp = `duplicate -n ($s+"_orig") $flat`;
                $orig = $temp[0];
                delete $blendShape;
                $temp = `duplicate -n ($s+"_flattened") $orig`;
                $blendShape = $temp[0];
                
                $temp = `blendShape -n ("BSN_"+$s+"_flat") $flat $blendShape`;
                $BSN = $temp[0];
                connectAttr ($blendShape+".flatten") ($BSN+".weight[0]");
                delete $orig;
                delete $flat;
            }
        }
        else confirmDialog -title "Warning" -message ("Multiple objects called \""+$s+"\" found.

Please give objects unique names!") -button “Ok”;
}
}
else error (“nothing selected”);
}