PDA

View Full Version : distributing instances on polygons.


stooch
03-18-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.

thanks.

cbamber85
03-18-2009, 05:13 PM
MItMeshPolygon::getNormal(MVector , MSpace)

This can do it.

stooch
03-18-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.

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

http://www.christerb.com/?page_id=13
cbDuplicateOnSelected.mel

cbamber85
03-18-2009, 10:30 PM
import maya.OpenMaya as OpenMaya
selectionList = OpenMaya.MSelectionList()
selectionList.add("pCube1.f[0]")
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-18-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.