Discussion:
[Maya-Python] rewrite maya follicle node
Zhen Huang
2018-11-19 08:57:49 UTC
Permalink
Hi ,

I want to rewrite maya follicle node , the idea for this is because :
----1 , polygon basic follicle is much faster than classic rivet , even
matrix basic rivet , I think it's because the extra calculation on
'curveFromEdge' and 'loft'
----2 , maya default follicle can't change axis of orientation
And I'd like to remove the rest of dynamic parameters and functions.

From the rough view , seems the follicle node read the position and tangent
from polygoon directly , and after researching the MFnMesh class , I don't
get any function like getPositionAtUV or getNormalAtUV , getTangentAtUV .

Will be a great appreciation if you can figure out the key of this custom
follicle node .


Big Thanks and best ,
John HZ
--
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/46f2b559-76b0-400a-a6d0-8e87545bc646%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Angelo Sta. Catalina
2018-11-19 14:30:01 UTC
Permalink
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAJAkR62y0y8zgL5dW9m0ovayPezeUcjp%2BYavtYnJr_0JPCRdGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Zhen Huang
2018-11-20 08:07:34 UTC
Permalink
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+***@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.
Angelo Sta. Catalina
2018-11-20 13:54:37 UTC
Permalink
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).
Post by Zhen Huang
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
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/CAJAkR633iAXtErdsYoC-ijsKJhFyA%3DMn0tk0xmJD74_nU9bJAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Michael Boon
2018-11-21 03:54:22 UTC
Permalink
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.
Post by Angelo Sta. Catalina
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).
Post by Zhen Huang
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
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/9929dee8-8ecd-4c76-a49a-531cd9720a76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Zhen Huang
2018-11-21 06:19:03 UTC
Permalink
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写道
Post by 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.
Post by Angelo Sta. Catalina
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).
Post by Zhen Huang
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
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/8607f9d0-cb8e-4d5c-8342-c0eb36a14bcc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
zhen huang
2018-11-21 15:52:04 UTC
Permalink
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 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写道
Post by 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.
Post by Angelo Sta. Catalina
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).
Post by Zhen Huang
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
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.
zhen huang
2018-11-24 14:07:07 UTC
Permalink
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写道
Post by 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
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()
util2.createFromList(uv , 2)
float2ParamUV = util2.asFloat2Ptr()
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()
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)
#print '--- ---' , mit.index()
pass
mit.next()
###
### test in pymel
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 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写道
Post by 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.
Post by Angelo Sta. Catalina
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).
Post by Zhen Huang
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
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/32d4b06e-7f02-4d07-ae88-2830a62a902d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Angelo Sta. Catalina
2018-11-24 15:30:12 UTC
Permalink
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
Post by zhen huang
Hi ,
I've done for the custom follicle , and found the speed is much slower
than maya follicle .
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写道
Post by 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
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()
util2.createFromList(uv , 2)
float2ParamUV = util2.asFloat2Ptr()
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()
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)
#print '--- ---' , mit.index()
pass
mit.next()
###
### test in pymel
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 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写道
Post by 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.
Post by Angelo Sta. Catalina
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).
Post by Zhen Huang
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,
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
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+***@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.
zhen huang
2018-11-25 01:46:47 UTC
Permalink
I test with C++ plugin , I think maya follicle is so great when I had this
test .

圚 2018幎11月24日星期六 UTC+8䞋午11:30:27Angelo写道
Post by Angelo Sta. Catalina
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
Post by zhen huang
Hi ,
I've done for the custom follicle , and found the speed is much slower
than maya follicle .
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写道
Post by 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
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()
util2.createFromList(uv , 2)
float2ParamUV = util2.asFloat2Ptr()
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()
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)
#print '--- ---' , mit.index()
pass
mit.next()
###
### test in pymel
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 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写道
Post by 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.
Post by Angelo Sta. Catalina
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).
Post by Zhen Huang
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,
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
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+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/31f9ee01-f900-4c87-94c2-e689b1366e57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Zhen Huang
2018-11-21 06:14:36 UTC
Permalink
Hi Angelo ,

Thanks ! Awesome turorial , I'm going to use this solution after follicle
style method , seems ti's a pure math method base on triangle shape ,
should be a faster solution .

圚 2018幎11月20日星期二 UTC+8䞋午9:54:52Angelo写道
Post by Angelo Sta. Catalina
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).
Post by Zhen Huang
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
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/6a3c8f1a-e367-422d-aa34-a261949bd758%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...