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 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/fd0ea781-6f68-4574-a9cb-ca7fb32bbbc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I recommend you get Chad Vernon's "Applied 3d Math" video tutorial found here.It goes over how to construct rotation from 3 points (basically a rivet).
On Tue, Nov 20, 2018 at 2:07 AM Zhen Huang <qeej...@gmail.com> wrote:
--Seems 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 an email to python_inside_maya+unsub...@googlegroups.com.
I recommend you get Chad Vernon's "Applied 3d Math" video tutorial found here.It goes over how to construct rotation from 3 points (basically a rivet).
On Tue, Nov 20, 2018 at 2:07 AM Zhen Huang <qeej...@gmail.com> wrote:
--Seems 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 an email to python_inside_maya+unsub...@googlegroups.com.
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)
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/fd0ea781-6f68-4574-a9cb-ca7fb32bbbc2%40googlegroups.com.
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_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/32d4b06e-7f02-4d07-ae88-2830a62a902d%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fd0ea781-6f68-4574-a9cb-ca7fb32bbbc2%40googlegroups.com.
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+unsub...@googlegroups.com.