Did you do that test with a python plugin? It will always be slower then
Maya's method. Also, rivets aren't GPU friendly so things are a lot slower

On Sat, Nov 24, 2018 at 8:07 AM zhen huang <qeej...@gmail.com> wrote:

> Hi ,
>
> I've done for the custom follicle , and found the speed is much slower
> than maya follicle .
>
> So I did what @Angelo mentioned method to have another plugin with 3
> points orthonormal coordinate . The inputs is 5 , index of A,B,C point and
> UV , so sad even this simple pure math function can't run faster than maya
> follicle ,
> the frame rate of 3 points method is around 16 fps with 1000 rivets , (I
> just did crossing from BA and CA , define the U from A to BC , define V
> from AB to BC , to have the tangent and position , basic simple math
> operation ).
> and maya follicle in same number is around 60 fps
>
> What a terrible result that I've done all I can do , please help and
> discuss if you got anything about this topic .
>
> Thanks ,
>
> 在 2018年11月21日星期三 UTC+8下午11:52:04,zhen huang写道:
>>
>> 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][image: 01.png]
>>
>>
>> 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写道:
>>>
>>> Thanks 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写道:
>>>>
>>>> You 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.
>>>>
>>>> On Wednesday, 21 November 2018 00:54:52 UTC+11, Angelo wrote:
>>>>>
>>>>> I 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).
>>>>>
>>>>> 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+unsubscr...@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
>>>>>> <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+unsubscr...@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
> <https://groups.google.com/d/msgid/python_inside_maya/32d4b06e-7f02-4d07-ae88-2830a62a902d%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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAJAkR621Bvq8NY8MP1E-CJA6b6BKqQ61mYjRUurY86imJq%2B-2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to