PDA

View Full Version : Trying to Get A UV value from a point on a poly face


eebling
12-09-2012, 12:54 AM
Hey all, been searching forums and going through maya docs and cant find a solution. Im using mel, dont know python, so if possible, let me know a mel solution if one exists. Here's the problem, im selecting a face on a poly mesh, then converting the selection to the faces uv's and running some math proc to get the mid point of the uv's so i can place a follicle at the center of the face. This works fine, however the uv center isnt always the actual center of the poly face. Some of the uv layouts are nice and equal but the faces may have been distorted through say a lattice or deformer so placing a follicle at the middle UV value doesnt represent the face's actual center. So My idea is to select the face, convert selection to the verts, run the same math to find what the center value of the face is, but then I need to find what the corresponding UV value is from that world space center point. This is where i hit a dead end. Cant seem to find anyway of passing a point on a face to some function or command and return what the corresponding uv position is. Any one have idea's.?? Hopefully in Mel, but if it is possible to do so in python then maybe this will be what finally convinces me to open my python for dummies book and learn it.!

Thanks for any info.

E

bk3d
12-09-2012, 08:02 AM
use polyEvalute to get the bounding box of the face

polyEvaluate -bc;

to get the center of the face
((minX + maX)/2) ((minY + maxY) /2) ((minZ + maxZ) /2)

zaskar
12-09-2012, 12:43 PM
You should use a nearestPointOnMesh node to get the UV coordinate. Connect the "worldMesh" attribute of your mesh to the inMesh slot of the nearestPointOnMesh and feed it with the world space coordinate of your face center. Then query the resulting u/v parameter, done.

eebling
12-16-2012, 09:49 PM
You should use a nearestPointOnMesh node to get the UV coordinate. Connect the "worldMesh" attribute of your mesh to the inMesh slot of the nearestPointOnMesh and feed it with the world space coordinate of your face center. Then query the resulting u/v parameter, done.


sweet, sounds like that will do the trick...

thanks

E

CGTalk Moderation
12-16-2012, 09:49 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.