Mathematical problem

225 views
Skip to first unread message

Rémi Deletrain

unread,
Oct 13, 2015, 3:06:29 AM10/13/15
to Python Programming for Autodesk Maya
Hello everyone,

I try to move a vertex based on its local matrix.
For that I took the normal, position, tangent and binormals (I make an average of them).

So I was creating my matrix like this
Matrix = [tangent, normal, binormal, position]

to move the vertex based on a distance I do this.
position_start += position_target * Matrix.inverse

But I do not have the desired result.
for example whith sphere, I should be able to change this size.
Moving vertex of 10 cm based on the normal. But it makes me a banana ... And I do not understand why I have this result ...

Anyone have an idea?

Marcus Ottosson

unread,
Oct 13, 2015, 3:39:57 AM10/13/15
to python_in...@googlegroups.com
Clarifying question, aren't vertices always moving along their local matrix? You are referring to the object space, the transform node in which the shape is located? Secondly, how are you getting `position_target`? If you already have it, couldn't you simply do `position_start = position_target` and be done?

It sounds like you are expecting to move vertices along their normal, in that case it might be enough to simply add the values of the normal, e.g. [1, 0, 0] to the vertex, e.g. [0, 1, 0] to end up with e.g. [1, 1, 0].

--
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/abda985c-729b-4868-8397-618f13f17ca9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



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

Rémi Deletrain

unread,
Oct 13, 2015, 4:21:21 AM10/13/15
to Python Programming for Autodesk Maya
 This is a test for an animated tool.

I took the vertex position of two identical mesh but with one deformed.
So they will have the same local matrix it's transform node

Finally I would like to move my point according to the normal but with an offset position which corresponds to the end point.
It is for this reason that there is "position_target" in calculating that I showed.
Currently it just gives me a distance without the position offset, but it will bring a change when the deformation along the normals work.

The utility is to able deform a mesh over all deformer without the order of inputs.
It is like a blendshape but which still takes into account the normal shift points.

Marcus Ottosson

unread,
Oct 13, 2015, 5:33:57 AM10/13/15
to python_in...@googlegroups.com
Are you talking about shrink wrapping? About projecting the vertices of an inner mesh onto an outer mesh, along it's own normals? Maybe if you could make a simple drawing of what you're looking for, it would be easier to understand.

--
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.

For more options, visit https://groups.google.com/d/optout.



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

Rémi Deletrain

unread,
Oct 13, 2015, 5:41:30 AM10/13/15
to Python Programming for Autodesk Maya
I will try to draw a picture this afternoon, I also think it will be easier

Rémi Deletrain

unread,
Oct 13, 2015, 11:35:49 AM10/13/15
to Python Programming for Autodesk Maya
http://www.noelshack.com/2015-42-1444749454-draw.jpg

The objective is to obtain a position offset between two vertex based on the matrix (or normal) of the initial vertex.

This will provide a desired deformation after any deform.

for exemple:
With Maya blendshape, if you apply a shape with the deformer above the skin deformation is not good because the point change position.
I know it is possible to change the order of deformers but this principle to apply a offset based on matrix allows for many more things.

Rémi Deletrain

unread,
Oct 13, 2015, 11:38:24 AM10/13/15
to Python Programming for Autodesk Maya
with my picture I show you what I want as a result.

Always with the Maya blendshape if I apply the shape after deformation point move only in Y axes and don't follows deformation

Marcus Ottosson

unread,
Oct 13, 2015, 12:53:44 PM10/13/15
to python_in...@googlegroups.com

On 13 Oct 2015, at 17:38, Rémi Deletrain <remi.de...@gmail.com> wrote:

with my picture I show you what I want as a result.

Always with the Maya blendshape if I apply the shape after deformation point move only in Y axes and don't follows deformation

--
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.

Roy Nieterau

unread,
Oct 13, 2015, 3:28:25 PM10/13/15
to Python Programming for Autodesk Maya
Sorry for any typos, typed on phone:

To avoid any further confusion I think the matrix you're trying to build is the Vertex' tangent-space matrix.

These are per-vertex as opposed to per object like he local matrix.

So what you'd do is retrieve the "delta" in tangent-space of and re-apply that delta on the other mesh.

Note that a Vertex' position multiplied by its own inverse matrix would always be zero since its tangent-space matrix is based on its own position.

What I think you're trying to do is create Tangent-space blendshapes.

Basically you create the delta by having two meshes and store the delta:

delta = blendshapePt * tangentSpace.inverse()

And then apply that delta to another mesh's point in that vertex' tangent space:

targetPt += delta * targetTangentSpace

Not sure about the order of matrix multiplication here, I always tend to mess it up in Maya when doing it out the top of my head.

Cheers,
Roy

Rémi Deletrain

unread,
Oct 14, 2015, 9:18:10 AM10/14/15
to Python Programming for Autodesk Maya
Marcus:

I already made a tool to do that but not deform as it is very interesting!

It looks indeed has what I want to do. The difference is that this tool makes a difference and is then applied to deform below. What I seek to do is to apply above all the deformers


Roy:
With my calculation I try to retrieve the vertex tangent space .
But from what you say I do not apply it at all as it should be ...
I'll try this with you to explain.

If you want to watch my code:

I found some code on SouP forum

Rémi Deletrain

unread,
Jan 7, 2016, 3:13:44 AM1/7/16
to Python Programming for Autodesk Maya
Hello everyone,

I return to this topic I abandoned for lack of time ...

I think doing a lot easier than what I had expected. Instead complicate my life with the matrix simply play with the normals.

I have a point that a normal.
I have two points, so a direction (so a normal) and length.

So just make a difference between these two points and two normals ...

-----------------------------------

So in theory :


suffix 1 = initial mesh
suffix 2 = secondary mesh (shape for blendshape)
suffix 3 = final mesh target (target for blendshape+)

dif_point = pt2 - pt1
dif_normal = n2 - n1
new_normal = n3 + dif_normals
new_point = pt3 + (new_normal * dif_point.length)

-----------------------------------

With that I find the right position while I don't rotate my joint.
So I have a great blendshape ... :)

The problem now is that when I rotate my joint the points move more or less in the good direction but not deformed properly. I'm still looking why ...

Marcus Ottosson

unread,
Jan 7, 2016, 4:08:37 AM1/7/16
to python_in...@googlegroups.com

I hesitated a bit in sharing this, as I can’t vouch for it’s accuracy or performance, but young Marcus once attempted something along these lines. I remember also struggling with rotations as well, and detailed variations of the input surface during the transformation. Maybe my former goals can in some way help you reach yours.

It’s (to my own surprise) fairly well documented and logical in the comments of each relevant function.


--
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.

For more options, visit https://groups.google.com/d/optout.



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

Geordie Martinez

unread,
Jan 7, 2016, 4:38:48 AM1/7/16
to python_inside_maya
you have a joint. do you also have skinning?

if so,
is your blendshape before enveloping in the defomation stack ?


Rémi Deletrain

unread,
Jan 11, 2016, 11:13:49 AM1/11/16
to Python Programming for Autodesk Maya
Thank you very much Marcus. I'll watch it as soon as possible.

the problem of putting the blendshape first is that we must constantly do a subtraction between the two mesh. This operation is very simple but it's still a step ...
The goal is to avoid this step.

Dilen Shah

unread,
Jan 29, 2016, 9:53:56 AM1/29/16
to Python Programming for Autodesk Maya
Hey,

Well i dont know you got the answer but what i think from your picture you drew, you can take the local space position of original mesh. then add your offset and calcualte the offste with this original mesh points. may be even a vector of direction
v = pt2-pt1

then add your deformation and then get position of the deformed mesh and then add the same vector to this point position on it local space.

this should give you something like your drawing.

goodluck

D.

Rémi Deletrain

unread,
Mar 3, 2016, 5:07:25 AM3/3/16
to Python Programming for Autodesk Maya
I have solution.

obj_1 --> base mesh
obj_2 --> target mesh
obj_3 --> mesh reveiver


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#    Maya variable
object_space = OpenMaya.MSpace.kObject
world_space = OpenMaya.MSpace.kWorld

#    Maya node
obj_1 = pmc.selected()[0]
obj_2 = pmc.selected()[1]
obj_3 = pmc.selected()[2]

#    Maya MFn
mfn_obj_1 = obj_1.__apimfn__()
mfn_obj_2 = obj_2.__apimfn__()
mfn_obj_3 = obj_3.__apimfn__()

#    Points
points_1 = OpenMaya.MPointArray()
mfn_obj_1.getPoints(points_1, object_space)
points_2 = OpenMaya.MPointArray()
mfn_obj_2.getPoints(points_2, object_space)
points_3 = OpenMaya.MPointArray()
mfn_obj_3.getPoints(points_3, object_space)

#    Normals
normals_1 = OpenMaya.MFloatVectorArray()
mfn_obj_1.getVertexNormals(False, normals_1, world_space)
normals_2 = OpenMaya.MFloatVectorArray()
mfn_obj_1.getVertexNormals(False, normals_2, world_space)
normals_3 = OpenMaya.MFloatVectorArray()
mfn_obj_1.getVertexNormals(False, normals_3, world_space)

#    Offset
for idx in xrange(points_1.length()):
    
    offset_point = points_2[idx] - points_1[idx]
    offset_normal = offset_point.normal() - OpenMaya.MVector(normals_1[idx])
    
    final_normal = OpenMaya.MVector(normals_3[idx]) + offset_normal
    final_point = points_3[idx] + (final_normal * offset_point.length())
    
    mfn_obj_3.setPoint(idx, OpenMaya.MPoint(final_point), object_space)

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 

With this script I move the points offset relative to the normal.
I tried on my node but I still encounter some problems.

Thanks for your reply. I post python node when is finish
Reply all
Reply to author
Forward
Message has been deleted
0 new messages