Closest Point On Mesh

328 views
Skip to first unread message

Dilen Shah

unread,
Apr 27, 2015, 2:46:13 AM4/27/15
to python_in...@googlegroups.com
Hey Guys,

I am writing a script to transfer blendshape based on closest point algorithm, I am using the MMeshIntersector and getting the closest point and face id and also using triangle id getting the barycentric coordinates, with which I can get the new position of the blendshape.

But I have run in some problem if the there is an offset, lets say for example I have a cube and i want to recreate the blendshape onto another cube which is smaller or bigger than it and so has an offset per vertex.

So at the moment I get the distance vector between the vertices and multiply it to get the offset. But lets say I have extra edge loop on new cube and I want it to get the exact position using barycentric coordiantes from original mesh and also offset with it.

When I apply the new blendshape position all works well but there is an offset on the extra vertices. I am attaching pics of what I exactly want.

So first image is the original in white outline and target mesh in the green outline mesh. and I am getting the offsets.

Second image, I apply the blendshape I extract using the closest point and barycentric coordinates. But when you see the extra vertices is not exactly in position ideal.

Can anyone help me out with this, I know I need to multiply another vector position or is there a way to get the distance from the vertices to its closest edge and get the distance that I can calculate?

Thank you.

D.
blendShape01.png
blendShape02.png

Marcus Ottosson

unread,
Apr 27, 2015, 3:03:40 AM4/27/15
to python_in...@googlegroups.com
Is this for practice/learning? Otherwise, you might be able to achieve what you're looking for using Transfer Attributes.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f84c63ee-ce65-45a8-a5c6-3f9c2cf38ac1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Dilen Shah

unread,
Apr 27, 2015, 3:08:43 AM4/27/15
to python_in...@googlegroups.com
Hey marcus,

I think you didnt understand my question, if i use transfer attributes it will place vertices in the exact position i dont want that. please see the images so you get what I mean.

D,


On Monday, April 27, 2015 at 9:03:40 AM UTC+2, Marcus Ottosson wrote:
Is this for practice/learning? Otherwise, you might be able to achieve what you're looking for using Transfer Attributes.
On 27 April 2015 at 07:46, Dilen Shah <dilen...@gmail.com> wrote:
Hey Guys,

I am writing a script to transfer blendshape based on closest point algorithm, I am using the MMeshIntersector and getting the closest point and face id and also using triangle id getting the barycentric coordinates, with which I can get the new position of the blendshape.

But I have run in some problem if the there is an offset, lets say for example I have a cube and i want to recreate the blendshape onto another cube which is smaller or bigger than it and so has an offset per vertex.

So at the moment I get the distance vector between the vertices and multiply it to get the offset. But lets say I have extra edge loop on new cube and I want it to get the exact position using barycentric coordiantes from original mesh and also offset with it.

When I apply the new blendshape position all works well but there is an offset on the extra vertices. I am attaching pics of what I exactly want.

So first image is the original in white outline and target mesh in the green outline mesh. and I am getting the offsets.

Second image, I apply the blendshape I extract using the closest point and barycentric coordinates. But when you see the extra vertices is not exactly in position ideal.

Can anyone help me out with this, I know I need to multiply another vector position or is there a way to get the distance from the vertices to its closest edge and get the distance that I can calculate?

Thank you.

D.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

Marcus Ottosson

unread,
Apr 27, 2015, 3:55:50 AM4/27/15
to python_in...@googlegroups.com

I suppose I still don’t understand. I tried recreating your example with a wrap deformer, but I can’t reproduce your results.

Inline images 1

Have you tried using the wrap deformer for this? You could:

  1. Wrap the new topology onto the original mesh
  2. Apply the original blendshape onto the original mesh, the new topology follows
  3. Clear history on new topology, this would be your new blendshape​

Dilen Shah

unread,
Apr 27, 2015, 4:59:48 AM4/27/15
to python_in...@googlegroups.com
Well this is a simple example I was using to show me problem, try doing it for facials and complex meshes and topologies.

you will know why I cant use wrap. thanks for reply.

D.

Marcus Ottosson

unread,
Apr 27, 2015, 5:32:54 AM4/27/15
to python_in...@googlegroups.com
I have indeed used it for quite complicated geometry, including faces.

If your concern is in meshes with close proximity such as eyelids, then you can utilise multiple wrap-deformers and associate each on a per-point basis, e.g. one for the lower and one for the upper, and assign both to the same blendshape.

Dilen Shah

unread,
Apr 27, 2015, 6:36:15 AM4/27/15
to python_in...@googlegroups.com
Hey Marcus,

Thanks but I am looking for something in maya API if you got some idea in that, would like to hear it.

D.

Janos Hunyadi

unread,
Apr 27, 2015, 6:57:03 AM4/27/15
to python_in...@googlegroups.com
Hey Dilen,

One thing I know for sure that the MMeshIntersector uses a different algorithm (octree) than the ClosestIntersection method of the MFnMesh (just comparing distances I guess). So its quite dependent on the size of the object, and to this day I could`t figure it out how is it possible to set the resolution of the octree. So if your object is too small, as I can see it from the screenshot, than the voxels of the octree will be too big. Try increasing your size of your object to see if you are getting a desirable result. I would use the closestintersection with a MMeshIsectAccelParams accelerator, gives a decent speed. That always gave me correct results, with any size. Although its not thread-safe.

Greets,
Janos

Dilen Shah

unread,
Apr 27, 2015, 7:11:30 AM4/27/15
to python_in...@googlegroups.com
Hey Janos,

sounds good, yaa i will try some results and see what i get. this is what I needed to know.

Going to try and see what I get and will keep posted.

Thanks.

D.
Reply all
Reply to author
Forward
0 new messages