Question on vertex normals on unsoften meshes

29 views
Skip to first unread message

Bay

unread,
Aug 4, 2014, 8:54:21 PM8/4/14
to python_in...@googlegroups.com
Hi,
    I'm attempting to write a tool that allows me to attach and align an object according to a vertex normal. So far I've gotten it to work well on meshes that are higher res (as shown in the screenshot) but on lower res meshes I run into the problem where a single vertex has multiple normals, each the same as the vertex's adjacent polygons.  How would I obtain the IDs of the faces that are connected to this vertex? Any assistance is much appreciated. 


Thank you
Gann Boon Bay 

Risto Jankkila

unread,
Aug 5, 2014, 4:21:03 AM8/5/14
to python_in...@googlegroups.com
Hi,

You can use MItMeshPolygon and it's method getConnectedFaces to obtain connected polygon id's for each vertex.

For example:

import maya.OpenMaya as OpenMaya

mSelectionList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList(mSelectionList)
mObject = OpenMaya.MObject()
mSelectionList.getDependNode(0, mObject)
polyIterator = OpenMaya.MItMeshPolygon(mObject)
while not polyIterator.isDone():
            polygonArray = OpenMaya.MIntArray()
            polyIterator.getConnectedFaces(polygonArray)
            # do something with polygonArray
            polyIterator.next()


The code is just an example of the top of my head. I can't actually check if it works since I don't have access to Maya at the moment :)

Cheers,
Risto




--
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/17296e41-ba80-485c-bbc8-d0f50db8cc73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bay

unread,
Aug 7, 2014, 7:23:57 PM8/7/14
to python_in...@googlegroups.com
Hi ristjan,
               sorry for not getting back to you earlier! Thanks for your help, I've managed to get the information I was looking for. Turns out vertex normal did gave me what I was looking for but since I did not build an up vector for the matrix the locator did not know how to orient it self. Using connectedVertices to build the up vector was what I ended up doing. Thanks again!

Thank you
Gann Boon Bay 
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages