View Full Version : Getting face normal using UV?

05-10-2011, 07:09 PM
Getting face normal using UV?
How do you get the face normal fi you have the UV.
Lets say for a polygon you have U = .2 and V = .5.
how do you get the normal of that face at that UV.

Thanks you.

05-10-2011, 08:43 PM
you could plug a follicle at the exact uv and get its orientation, or get its position and extract the normal with a closestPointOnMesh or pointOnMeshInfo don't remember whitch of the 2 one can extract normal or a normal constraint maybe of a locator at that point may return soemthing usefull...

this should get you going, there is probably even a command polyInfo maybe that can return exactly that at uv cord but not sure and I don't have maya here to test sorry.


05-10-2011, 09:06 PM
What do you want to do with the UV?

05-11-2011, 08:23 PM
Is this even possible? What relation do uvs have to a mesh? A single uv doesn't need to have a unique point on a mesh (overlapping uvs for example) - so if a uv represents 2 or more points on a mesh which does it return?

A point on a mesh can give you a uv coordinate but the reverse is not really possible I don't think.

Need more info on what you're trying to do!

05-12-2011, 09:56 AM
seriously try with the follicles once plug give them the uv you need, and query the outNormal from the follicleShape, fast and easy. Of course as it's been mention above no overlapping Uv or it wouldn't work.


05-12-2011, 04:08 PM
Funny thing - yesterday I was attempting to do the same thing with particles. They collide with a body - gore/blood/dirt - and it (the particles' instances) stick to the surface upon collision.

The issue I have is that the particles are floating above the surface - I have the collision tolerances very small - 0.01 - however, there seems to be an issue with nParticles. I am using the radiusPP ramp to size the instances - and it uses the largest radiusPP value as the distance off the surface that the particles sit.

So, thinking I could use a goalOffset, I need to bring the particles closer to the surface. However, I couldn't get the normal at the point of collision. nParticles even have goalWorldNormal0PP when you add goals - to cause the sticking part. Again, thinking I can make use of this, but unsure of how?

goalOffset = -0.5*normal (at point of collision)

normal... would be calculated? Be aquired by? read in through? Mind blank....

I'd like to know?


05-12-2011, 05:45 PM
Hahaha! I don't know if this will help you or not, but I solved my problem - MAYA's wonderful feature - the MEL version of the command does not work - and so I tried it in python and guess what? It works!

//get UV parameter
float $u = goalU;
float $v = goalV;
//get normal at point
float $normal[] = python("cmds.nearestPointOnMesh('pPlane1',q=True,nr=True,u=0,v=0)");
//offset the particle goal by the normal value and scale it basic on the instance size value
goalOffset =radiusPP*<< ($normal[0]), ($normal[1]) ,($normal[2])>>;

CGTalk Moderation
05-12-2011, 05:45 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.