PDA

View Full Version : Getting face normal


BarbaPappa
02-03-2004, 09:03 PM
I'm trying to get the normal of a face. The way i'm doing it now gives me a string. Instead of getting it as a string i would like to get it as a vector variable or to be able to easily convert it to a vector. Here's what i currently do:

polyInfo -faceNormals $selection;


// Result: FACE_NORMAL 43: 0.171929 -0.000000 -0.985109 //


Is there an easy way to get the normal vector of a face? Or is there an easy way to convert this string into a vector variable?

thanks

rendermaniac
02-04-2004, 12:11 AM
Don't know if this is any help, but it goes into getting normals from MEL and was pretty useful for me.

http://www.ewertb.com/maya/mel/mel.php?howto=05

Simon

BarbaPappa
02-04-2004, 07:31 AM
Thanks!

I found this little script to help me get a vector of the string i talked about in my last post:

proc vector translatePolyInfoNormal( string $pin )
{
vector $normal;
float $x;
float $y;
float $z;

string $tokens[];
int $numTokens = `tokenize $pin " " $tokens`;

// Make sure we're looking at polyInfo data:
if ( ( $numTokens > 3 ) && ( $tokens[0] == "FACE_NORMAL" ) )
{
// Maya performs data-type conversion here.
$x = ($tokens[$numTokens-3]);
$y = ($tokens[$numTokens-2]);
$z = ($tokens[$numTokens-1]);

$normal = << $x, $y, $z >>;

// Normalize it.
$normal = `unit $normal`;
}

// Return it.
return $normal;
}


gonna try it out... thanks again

CGTalk Moderation
01-17-2006, 08:00 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.