View Full Version : distributing instances on polygons.

03 March 2009, 01:13 AM
Hi. so im trying to wrap my head around this problem. I need to place a bunch of instances aligned at each normal of a poly mesh, there are LOTS of them. (several thousand)

im playing with the `polyInfo -fn `

command but not getting what i want. any ideas or suggestions for this? Basically im trying to translate the normal vector into a transform.


03 March 2009, 05:13 PM
MItMeshPolygon::getNormal(MVector , MSpace)

This can do it.

03 March 2009, 09:55 PM
hmmm.... im getting pretty far with my existing code, but its a bit slow. do you have a usage example of this? do i have to compile this into a plugin or something? i see its in the API section of the help docs.

MItMeshPolygon::getNormal(MVector , MSpace)

This can do it.

03 March 2009, 10:25 PM
Christer Bjørklund have a nice script that may already do what you want to do

03 March 2009, 10:30 PM
import maya.OpenMaya as OpenMaya
selectionList = OpenMaya.MSelectionList()
mDagPath = OpenMaya.MDagPath()
mObj = OpenMaya.MObject()
normal = OpenMaya.MVector()
space = OpenMaya.MSpace.kWorld

selectionList.getDagPath(0, mDagPath, mObj)
fn = OpenMaya.MItMeshPolygon(mDagPath, mObj)
fn.getNormal(normal, space)

print normal.x, normal.y, normal.z

There's probably simpler ways, but this works. As it's Python you don't need to compile anything.

CGTalk Moderation
03 March 2009, 10:30 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.