Permalink #1 
littlemonkey's Avatar
Join Date: Feb 2012
Posts: 1
Junior Member
    Thanks: 0
    Thanked 0 Times in 0 Posts

    Default Get vertices and uvs from a single face


    Hi everyone I just started mel scripting and ran into some problems.

    The title says it all, I need to get the 3 vertices and 3 uv coords from a single face.

    I looked around and could barely find things that would explain this, so I put my hope on this forum.
    (or maybe I was just looking at the wrong places?)

    I tried it with the following method:
    (I know it is probably rubbish, but it is as close as I could get)

    for vertices:

    Code:
    int $skipableNumFromTokenization = 2;
    				
    				
    					string $Num=".f["+$i+"]";
    					string $LinkString=$obj+$Num;
    					
    					//string $sArray[] = `polyListComponentConversion -fromFace -toVertex $LinkString`;		
    			
    					select -r $LinkString;
    					string $TriangleVertices[] = `polyInfo -fv`;
    					//print($TriangleVertices);
    					
    					for($j=0;$j<3;++$j)
    					{
    						string $buffer[];
    						tokenizeList ($TriangleVertices[$j], $buffer);
    						//print($buffer);
    					
    						string $Num=".vtx["+$buffer[$j+$skipableNumFromTokenization]+"]";
    						string $LinkString=$obj+$Num;
    						float $vtxPos[3] = `xform -q -ws -t $LinkString`;
    						
    						if($Exportinfo==1)print("Vertex:"+$vtxPos[0]+","+$vtxPos[1]+","+$vtxPos[2]+"\n");	
    						
    						if($CompressionLevel==0)fprint $fileId("Vertex:");
    						fprint $fileId($vtxPos[0]+","+$vtxPos[1]+","+$vtxPos[2]+"\n");
    						
    					}
    and for the uvs:
    Code:
    string $Num=".f["+$i+"]";
    					string $LinkString=$obj+$Num;
    					string $sArray[] = `polyListComponentConversion -fromFace -toUV $LinkString`;			
    					//print($sArray[0]+$sArray[1]);
    					
    	
    					
    					$fArray = `polyEditUV -q $sArray`;
    					if($Exportinfo==1)print($LinkString+": "+$fArray[0]+","+$fArray[1]+","+$fArray[2]+","+$fArray[3]+","+$fArray[4]+","+$fArray[5]+"\n");
    					if($CompressionLevel==0)fprint $fileId("FaceUV:");
    					fprint $fileId($fArray[0]+","+$fArray[1]+"\n");
    					if($CompressionLevel==0)fprint $fileId("FaceUV:");
    					fprint $fileId($fArray[2]+","+$fArray[3]+"\n");
    					if($CompressionLevel==0)fprint $fileId("FaceUV:");
    					fprint $fileId($fArray[4]+","+$fArray[5]+"\n");
    					select -r $select;
    They both seem to give me what I want (3 vertices and 3 uv coords), BUT they are in the wrong order!

    Can someone help me with this code or help met find a better piece of code alltogether?

    Cheers, Rik.


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     

    Posting Rules
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Similar Threads
    Thread Thread Starter Forum Replies Last Post
    Female face nitrox721 3D WIP 1 02-15-2012 07:59 AM
    at the dig face phreatic Sketchbooks 1 11-07-2011 12:02 AM
    First try at painting a face Huck 2D WIP 0 06-16-2011 02:57 PM
    Self 3D Face Portrait MarkWen 3D Finished Work 0 02-07-2011 02:37 AM
    How to save render elements to single multichannel exr walthergropius 3ds Max 0 03-24-2009 11:36 AM