Page 1 of 1

maya api closet location equivalent?

Posted: 09 Sep 2017, 10:35
by anhungxadieu
Hi everyone?
Sorry to asks this? :) but if someone already know maya api, can give me some idea regarding "closet location"?
thanks in advantage!

Re: maya api closet location equivalent?

Posted: 10 Sep 2017, 13:26
by rray
Maya's closest location function is inside the plugin called "nearestPointOnMesh".
It's one of the plugins that likes to turn itself off quite often and you have to go to your plugin list to enable it.
Also it only works when your scene units is meters...
All that taken care of I think you pass the function (which is also called nearestPointOnMesh same as the plugin I think) a mesh and a 3d position vector, and get back a 3d position back that's on the mesh. It's rather slow btw not being multithreaded like the ICE version.

Re: maya api closet location equivalent?

Posted: 11 Sep 2017, 11:39
by anhungxadieu
Thank for the reply rray,
But i want to get the "location" or another attribute inside the mesh.

Re: maya api closet location equivalent?

Posted: 11 Sep 2017, 11:43
by rray
I don't think that's possible without custom coding ~o)

Re: maya api closet location equivalent?

Posted: 11 Sep 2017, 12:59
by anhungxadieu
recently, i start to learn c++ maya api. If you already familiar with it, please point me some direction! :-B

Re: maya api closet location equivalent?

Posted: 11 Sep 2017, 15:13
by rray
I'm not familiar but I'm guessing there's no such concept as locations.

You might have to do actual coordinate comparisons to find the closest triangle to your point, get its 3 points, 3 attributes values from those points, and interpolate these after that, depending on the exact position of your lookup point on the triangle.

If you're not using accelerating data structures you can expect that to be like a 100 times slower than ICE.

If there's something in Maya's API to look up closest UV that would help a lot. Bake your attribute to a texture then and look that up. You could start with looking for that.

Re: maya api closet location equivalent?

Posted: 11 Sep 2017, 18:29
by anhungxadieu
rray wrote: 11 Sep 2017, 15:13 I'm not familiar but I'm guessing there's no such concept as locations.

You might have to do actual coordinate comparisons to find the closest triangle to your point, get its 3 points, 3 attributes values from those points, and interpolate these after that, depending on the exact position of your lookup point on the triangle.

If you're not using accelerating data structures you can expect that to be like a 100 times slower than ICE.

If there's something in Maya's API to look up closest UV that would help a lot. Bake your attribute to a texture then and look that up. You could start with looking for that.
Thanks rray, i will research in that way!

Re: maya api closet location equivalent?

Posted: 26 Oct 2017, 14:50
by myara
I haven't used nearestPointOnMesh but, you I guess it does the same as Open Maya's getClosestPoint.

I used this method to calculate the distance between a point and segment, so it's more 2D, but it could give you an idea. I don't know, maybe using the cross of 2 vectors.
https://nodedangles.wordpress.com/2010/ ... e-segment/

This link is pretty interesting too.
http://paulbourke.net/geometry/pointlineplane/