View Full Version : MEL-Problem: faceNormalOutput

08 August 2007, 06:17 PM

i get an error with MEL...

when i want to query all normals of a mesh, i use:

string $pi[] = `polyInfo -fn $eachFace`;

//Result: FACE_NORMAL 5: -1.000 0.000 0.000

even though the object has been rotated.
it seems the normal is put out in local space, not world space... what could i do ??

* * *


08 August 2007, 07:21 PM
//create a test plane
$plane = `polyPlane -ax 0 1 0`;
setAttr ($plane[0]+".rz") -90;

string $pi[] = `polyInfo -fn ($plane[0]+".f[0]")`;
string $buf[];
$numTokens = `tokenize $pi[0] " " $buf`;

//cast string to float
float $normal[];
$normal[0] = $buf[2];
$normal[1] = $buf[3];
$normal[2] = $buf[4];

$m = `xform -q -ws -m $plane[0]`;
float $worldspaceVec[] = pointMatrixMult($normal, $m);

print ($worldspaceVec);

08 August 2007, 08:35 PM
yay ! yahoo ! *jump* *jump*

that's it ! thanks a lot !

* * *

some time ago, i've written a little script that directly selects all faces within a certain range of degrees compared to the world-up vector (via a selection-constraint command, i don't remember the name right now). well, it's the same i want to achieve in the end, but like this it will work for sure !

thx again !

CGTalk Moderation
08 August 2007, 08:35 PM
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.