PDA

View Full Version : Querying positions of verts surrounding a poly face?


superduper10000
01-25-2007, 05:26 PM
Is there a simple way to get the positions for vertices that define a face? Right now I have something like:


string $vertList[] = `polyInfo -fv`; // 1 face is selected in the scene
print $vertList;
string $vertBuffer[];

// This is the part that starts to get unplesant
tokenize($vertList[0], $vertBuffer);

for($vert in $vertBuffer)
{
print("Token: " + $vert + "\n");
}




... which outputs:

FACE 62: 68 69 79 78

Token: FACE
Token: 62:
Token: 68
Token: 69
Token: 79
Token: 78



My question is: do I have to dig around in the tokenized buffer and find vert indices (keep in mind that for multiple selected faces it will look like several 2-d arrays to walk through and get vertex indices) or is there an easier way to get a list of verts?

Ultimately I am interested in finding position and normal data for these faces -- maybe I am taking the wrong approach all together? :curious: (http://forums.cgsociety.org/misc.php?do=getsmilies&wysiwyg=1&forumid=0#)

Vitoratti
01-25-2007, 11:15 PM
Hi!

polyEvaluate -v $node
super simple, and it works very well. Will return the number of vertices, then u can do something like:


global proc vector[] rvGetPolyVtxWs( string $node )
{
vector $ws[], $posTemp;
int $numVtx[] = `polyEvaluate -v $node`;
for ($i=0; $i < $numVtx[0]; $i++)
{
$posTemp = `pointPosition ($node + ".vtx[" + $i + "]")`;
$ws[$i] = $posTemp;
}
return $ws;
}




{

vector $bla[] = `rvGetPolyVtxWs "pCube1"`;

print $bla;

}

//result:
-0.5 -0.5 0.5

0.5 -0.5 0.5

-0.5 0.5 0.5

0.5 0.5 0.5

-0.5 0.5 -0.5

0.5 0.5 -0.5

-0.5 -0.5 -0.5

0.5 -0.5 -0.5

superduper10000
01-25-2007, 11:35 PM
Yep - that's useful definitely - but this call:


vector $bla[] = `rvGetPolyVtxWs "pCube1.f[1]"`;




...errors, because polyEval seems to only works on an object level -- I want to look at a subset of the faces in the object as a list of components (e.g. some user's currently selected list of faces)

isoparmB
01-26-2007, 12:02 AM
PolySelectConvert 3;
string $pointList[] = `ls -sl -flatten`;
string $currentPoint;
vector $pointPosition;
float $pointPositions[];
clear $pointPositions;
for($currrentPoint in $pointList)
{
$pointPosition = `pointPosition -world $pointList[0]`;
$pointPositions[`size $pointPositions`] = $pointPosition.r;
$pointPositions[`size $pointPositions`] = $pointPosition.g;
$pointPositions[`size $pointPositions`] = $pointPosition.b;
};
for($i = 0; $i <= (`size $pointList` - 1); $i++)
{
print ($pointList[$i] + "\n");
print ($pointPositions[($i * 3)] + "\n");
print ($pointPositions[(($i * 3) + 1)] + "\n");
print ($pointPositions[(($i * 3) + 2)] + "\n");
};

superduper10000
01-26-2007, 12:15 AM
That's cool --

Why isn't PolySelectConvert in my MEL command reference ?

isoparmB
01-26-2007, 04:39 AM
It's a mel script, not a mel command. It's the maya script used for the Edit Polygons- Selection- Convert Selection functionality. You can find it in the maya program folder, under scripts/others.

You can have the script editor echo all commands and execute it manually to the interface to see it in action. :]

CGTalk Moderation
01-26-2007, 04:39 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.