Hey , before going to C++ I wrote a python script to verify , it works
great , the behavior totally same as maya default follicle .
[image: 02.png][image: 03.png] <about:invalid#zClosurez>[image: 01.png]
<about:invalid#zClosurez>
As you can see , I test with 2 poly cubes with same manually tweaked UV ,
the method works both hard edge and soft edge . Post the script below just
a feedback of this subject.
Currently not sure the speed yet , cos it hasn't been converted to C++ .
Will have a final feedback about this method . Thanks !
import maya.OpenMaya as om
import pymel.core as pm
def getDagPath(node):
selectionList = om.MSelectionList()
selectionList.add(node)
pathNode = om.MDagPath()
selectionList.getDagPath(0, pathNode)
return pathNode
###### inputs
meshShape = 'pCubeShape1'
#uv = [0.415 , 0.495]
uvs = [(0.415,0.495) , (0.339 , 0.535)]
### use pymel to get api function and dag path
#pmm = pm.PyNode('pCubeShape1')
#dag = pmm.__apimdagpath__()
#fm = pmm.__apimfn__()
### use api to get function and dag path
dag = getDagPath(meshShape)
fm = om.MFnMesh(dag)
###### compute start
###
util2 = om.MScriptUtil()
### define normal tangents
normal = om.MVector()
uTangent = om.MVector()
vTangent = om.MVector()
### define pos MPoint
pos = om.MPoint(0.0,0.0,0.0)
### walk through meshPolygon , try to just walk through just one time for
multiply inputs to save calculation time
faceIndex = -1
mit = om.MItMeshPolygon(dag)
outMatrixes = om.MMatrixArray()
while not mit.isDone():
for uv in uvs:
util2.createFromList(uv , 2)
float2ParamUV = util2.asFloat2Ptr()
try:
mit.getAxisAtUV(normal,uTangent , vTangent , float2ParamUV)
mit.getPointAtUV(pos,float2ParamUV)
#print '+++ +++' , mit.index()
#print list(normal) , list(uTangent) , list(vTangent) , list(pos)
faceIndex = mit.index()
### start to build matrix
normal.normalize()
### get none shear tangents
newVTangent = uTangent ^ normal
newUTangent = normal ^ newVTangent
newVTangent.normalize()
newUTangent.normalize()
newUTangent = newUTangent*-1
###### output , return matrixices and faceIndex
### write om matrix , can change axis order here
matrix = om.MMatrix()
for x in xrange(3):
om.MScriptUtil.setDoubleArray(matrix[0], x, newUTangent[x])
om.MScriptUtil.setDoubleArray(matrix[1], x, newVTangent[x])
om.MScriptUtil.setDoubleArray(matrix[2], x, normal[x])
om.MScriptUtil.setDoubleArray(matrix[3], x, pos[x])
outMatrixes.append(matrix)
except:
#print '--- ---' , mit.index()
pass
mit.next()
###
### test in pymel
for i in range(outMatrixes.length()):
pmatrix = pm.dt.Matrix(outMatrixes[i])
ll = pm.spaceLocator()
pm.xform(ll,ws = 1 , m = pmatrix)
åš 2018幎11æ21æ¥ææäž UTC+8äžå2:19:04ïŒZhen HuangåéïŒ
Post by Zhen HuangThanks Michael , I found a api function to have the correctly normal and
tangents depends on UV directions which called MItMeshPolygon.getAxisAtUV ,
perfectly matched follicle's behavior , will post out soon .
åš 2018幎11æ21æ¥ææäž UTC+8äžå11:54:23ïŒMichael BoonåéïŒ
Post by Michael BoonYou can get the tangent and binormal at each corner of a face of a
MFnMesh. Those are based on the UV directions. You would have to choose
one, or interpolate for a position in the middle of a face.
Post by Angelo Sta. CatalinaI recommend you get Chad Vernon's "Applied 3d Math" video tutorial found
here
<https://www.cgcircuit.com/course/applied-3d-math?affid=084fa76a5ad4e37ee02f0fb98fd229b4ed900c0c1aea6f5ba4e330927a0d65f606af5a9ebad4b731f8b6036fa27758765636bec02ae95f3f30765a390979b9c6>
.
It goes over how to construct rotation from 3 points (basically a rivet).
Post by Zhen HuangSeems a good idea , are you mind introduce more please . Thanks .
I found the MFnMesh updated a lot , there is a getPointAtUV method .
Position solved .
How about rotation , any idea ?
Normal can get from interpolation of 3 points normal .
Tangent should base on UV , have no idea yet .
åš 2018幎11æ19æ¥ææäž UTC+8äžå10:30:17ïŒAngeloåéïŒ
Why not just use MFnMesh.getPoint? Build an orthonormal coordinate
using connected points.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/fd0ea781-6f68-4574-a9cb-ca7fb32bbbc2%40googlegroups.com
<https://groups.google.com/d/msgid/python_inside_maya/fd0ea781-6f68-4574-a9cb-ca7fb32bbbc2%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2aecc0e1-7407-44c4-ac5d-52499582be6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.