Jason,

This shoud work in the deform as well. Even though the deform is passed some
extra objects it still has a standard dataBlock that you can pull any data
from.  I think the reason why the deform is setup this way is because the
MItGeometry is only passed the components that are in the "deform
set"/"group parts". This  guarantees  **that only the components that need
it get deformed. The MitGeom should be used to set the output back into the
data block, but anything can be pulled out of the data block for querying.

Matt


srcMesh     = dataBlock.inputValue( <node>.aSourceShape ).asMesh()
srcFnMesh = om.MFnMesh( srcMesh )
srcVerts     = om.MPointArray()
srcFnMesh.getPoints( srcVerts, om.MSpace.kWorld )
vertCount   = srcVerts.length()

getVector   = om.MVector()

for i in range( 0, vertCount ):
 srcFnMesh.getVertexNormal( i,
                                            False,
                                            getVector,
                                            om.MSpace.kWorld )

On Thu, Feb 12, 2009 at 7:59 AM, jasonosipa <[email protected]> wrote:

>
> I have a pretzel I need some cheese and mustard for...
>
> So, I am trying to take a node and turn it into a deformer.  The
> MPxDeformer route, for the most part looks/feels significantly cleaner
> and easier to deal with, but I've run into this one weird thing.  I
> don't know how to get all the information I need in the deform def,
> specifically a vertex normal.  A deform gets this stuff:
>
> def deform( self, dataBlock, itGeo, localToWorldMatrix, mIndex ):
>
> And a compute gets this stuff:
>
> def compute( self, plug, dataBlock ):
>
> But the dataBlock for the compute has attributes *I* set up to get the
> meshes connected, whereas in the dataBlock for the deform, there are
> important attributes "magically" added that I'm not sure how to
> interface with.  So, I've got the deform def working, minus one thing
> - I need to do get at vertex normals, but am missing key information.
> The way I did that in a compute def was (condensed to only the
> relevant bits):
>
> srcMesh     = dataBlock.inputValue( <node>.aSourceShape ).asMesh()
> srcFnMesh = om.MFnMesh( srcMesh )
> srcVerts     = om.MPointArray()
> srcFnMesh.getPoints( srcVerts, om.MSpace.kWorld )
> vertCount   = srcVerts.length()
>
> getVector   = om.MVector()
>
> for i in range( 0, vertCount ):
>  srcFnMesh.getVertexNormal( i,
>                                             False,
>                                             getVector,
>                                             om.MSpace.kWorld )
>
> But I can't seem to figure out any way to set up an MFnMesh object to
> allow this to work in the deform def, like it did in the compute,
> because you're already passed a MItGeometry iterator (itGeo), from
> which it seems tricky to find a mesh to work with.  In a compute, you
> can get at attributes like a source mesh because it was defined by you
> in the init, but in a deform's datablock, certain thing are "just
> magically there".  How does one get at the *now orig* shape to set up
> an MFnMesh with?
>
> OR is there some other trick to getting at normal information while
> working in an MItGeometry object (looks like all you can get is
> position...)
>
> Thanks!
> >
>

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

Reply via email to