View Full Version : pointOnSurface/pointOnMesh questions

10 October 2005, 07:18 PM
Here's the deal:

From a mesh, I need to, at minumum, derive the world-space position from a given UV coordinate.

pointOnSurface does this quite nicely for NURBS surfaces.

However, pointOnMesh doesn't work in the same way. Instead of returning a position, the call attaches an info node. pointOnMesh has the additional requirement that one must provide a particular face index. My guess is that this requirement is due to the fact that UV mapping can be arbitrary for mesh surfaces, leading to the potential of having more than one surface position for any given UV.

As a side note, In desperation, I have written a MEL command plug-in that would give me the position on a mesh from an input UV, with the assumption that there is no case where two or more faces share any UV space. However, I don't want to trust this plugin because it is untested, but moreso because it probably won't give interpolated results that sync up properly with other maya-based utilities such as the surfaceInfo shader plugin.

The bottom line: Without "knowing" what face is being tested, is there some simple way to get a world-space surface coordinate from a given mesh with a given UV?

I feel like I'm jumping through hoops, for something that Maya/MEL probably has as an intrinsic component. But since the documentation on this sort of thing is a little spotty, perhaps there is a command or command usage of which I am unaware that would solve my problem.

Thanks in advance to anyone who can help.

10 October 2005, 08:23 PM
In a quick test, I selected a UV and ran

xform -q -ws -t;

I then selected the appropriate vertex that corresponded to the UV and re-ran the xform command, and the values returned were the same.

Does this do what you want?

10 October 2005, 09:00 PM
Thanks for the response, but unfortunately, no. The UVs from which I need to use to derive the world-space position info aren't coming from any known indexed mesh vertices themselves.

I'm looking for more of an arbitrary programmatic thing, where the input UV values could be anything from 0.0 to 1.0 in U and V, and I get back the corresponding world-space position on the mesh. It would be cool to get the surface normal back as well, but I can make due without it.

10 October 2005, 12:44 PM
Here is what I was thinking. Given an input mesh, select all the UV's, loop through and use the xform command to derive the world space position of the vertex that the UV is assigned to.

I only used xform on the corresponding vertex in my previous post to test that the values returned using xform on a UV, were in fact the world space position of the corresponding vertex.

If that isn't what your looking for, I need more input, because I am obviosly confused. :)

10 October 2005, 03:00 PM
After re-reading your posts, I gather you want to hand in an arbitrary UV value, say 0.25 0.25, and find out the world space position of that UV point, regardless of whether it is attacehed to a particular vertex.

Is that correct?

10 October 2005, 05:10 PM
exactly. :thumbsup:

10 October 2005, 06:31 AM
I ran into the same problem a couple of days ago, when I was trying to make a better (i.e. better suited for my purposes) button/rivet script. As far as I understand, the pointOnMeshInfo node doesn't allow you to use arbitary UV:s without a face index, and neither does the getPointAndNormal method that its based on. On an API level, you could use the MItMeshPolygon:: getPointAtUV - maybe that's what you've been using already.

It would be cool to get the surface normal back as well, but I can make due without it. Well, if there was a way to solve the problem with getting position from UV, it would be simple enough to use a closestPointOnMesh node with that position as input.

If you use your command in an expression, I don't see why it shouldn't work with samplerInfo.

May I ask what it is you want to do, maybe there's a workaround.

10 October 2005, 06:25 PM
Hey Anders,

For my plugin, I wasn't using the mesh interator or MItMeshPolygon:: getPointAtUV, but it might be something to try in order to simplify things. Maybe better than my current approach of using a custom scan-conversion algorithm in UV space.

I would give you more details if I were free to do so, but unfortunately I can't go into it about what I'm doing due to the proprietary nature of our pipeline. :shrug:

But thanks for mentioning that API method. It might help.

CGTalk Moderation
10 October 2005, 06:25 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.