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
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/2dfe0f44-881b-450c-b81c-2ba11735a8dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.