Hi Marcin,

Looks like you need to first iterate your mesh to store the normals in an
array, then iterate again to translate each point along these normals.

Right now, each time you move a point, you are affecting the normals of all
other points that share an edge with it, so its normal has been changed by
the time the iterator gets to it to read the normal.

-Adam

On Mon, Feb 16, 2009 at 10:49 AM, marcin <[email protected]> wrote:

>
> Hi!
>
> I want to displace my mesh along normals using deformer. So I wrote
> following code in compute method
>
>        thisNode = self.thisMObject()
>
>        index = plug.logicalIndex()
>        inPlug = OpenMaya.MPlug( thisNode,
> OpenMayaMPx.cvar.MPxDeformerNode_input )
>        inPlug.selectAncestorLogicalIndex( index,
> OpenMayaMPx.cvar.MPxDeformerNode_input )
>
>        hInput = dataBlock.inputValue( inPlug )
>
>        hGeom = hInput.child
> ( OpenMayaMPx.cvar.MPxDeformerNode_inputGeom )
>        hGroup = hInput.child
> ( OpenMayaMPx.cvar.MPxDeformerNode_groupId )
>        groupId = hGroup.asLong()
>        hOutput = dataBlock.outputValue( plug )
>        hOutput.copy( hGeom )
>
>        pt = OpenMaya.MPoint()
>        normalvec = OpenMaya.MVector()
>
>        mesh = hOutput.data()
>        iter = OpenMaya.MItMeshVertex(mesh)
>
>        while iter.isDone() == False:
>            pt = iter.position()
>            iter.getNormal(normalvec)
>            iter.setPosition(pt+normalvec*2)
>            iter.next()
>
> and I've got mesh distorted in random directions instead of normals.
> When I replace normalvec with
> some arbitrary vector everything is working fine. What I'm doing
> wrong ?
> >
>

--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to