You can still create the geometry iterator. From the docs:
MStatus
exampleDeformer::compute(const MPlug& plug, MDataBlock& dataBlock)
{
MStatus status = MS::kUnknownParameter;
if (plug.attribute() == outputGeom) {
// get the input corresponding to this output
//
unsigned int index = plug.logicalIndex();
MObject thisNode = this->thisMObject();
MPlug inPlug(thisNode,input);
inPlug.selectAncestorLogicalIndex(index,input);
MDataHandle hInput = dataBlock.inputValue(inPlug);
// get the input geometry and input groupId
//
MDataHandle hGeom = hInput.child(inputGeom);
MDataHandle hGroup = hInput.child(groupId);
unsigned int groupId = hGroup.asLong();
MDataHandle hOutput = dataBlock.outputValue(plug);
hOutput.copy(hGeom);
// do the deformation
//
MItGeometry iter(hOutput,groupId,false);
for ( ; !iter.isDone(); iter.next()) {
MPoint pt = iter.position();
//
// insert deformation code here
//
iter.setPosition(pt);
}
status = MS::kSuccess;
}
return status;
}
You'll see your same code as before but since it's in the compute method, it
hasn't been called yet. Calling it in the deform method is actually the
second time it gets called, which is why you get the extra evaluation.
On Thu, Nov 20, 2008 at 10:43 PM, <[EMAIL PROTECTED]> wrote:
> Would you not lose access to geomIter? For evaluating over the membership.
>
> I created a plug-in to displace the mesh based off a 2D texture and a
> membership. Suppose not looping through vertices that will stay at their
> default locations is worth the extra computations.
>
>
> -brian
>
> -------- Original Message --------
> Subject: [Maya-Python Club:1337] Re: MFnMesh outputGeom from deformer?
> From: "Chad Vernon" <[EMAIL PROTECTED]>
> Date: Fri, November 21, 2008 12:31 am
> To: [email protected]
>
> You actually shouldn't get the mesh object this way as it will cause an
> extra evaluation of the upstream dependency graph nodes. If you need the
> mesh object, you should override the compute method instead. If you look in
> the documentation for MPxDeformerNode, it gives an example of how to do it.
>
> On Thu, Nov 20, 2008 at 8:04 PM, mePt <[EMAIL PROTECTED]> wrote:
>
>>
>> perfect! this did the trick!
>>
>> thanx brian!
>>
>> i was trying too hard to get something with using
>> OpenMayaMPx.cvar.MPxDeformerNode_outputGeom i think! ;)
>>
>>
>>
>>
>> On Nov 20, 7:10 pm, <[EMAIL PROTECTED]> wrote:
>> > I dealt with the very same issue recently creating a custom deformer.
>> > This is what I used to get the mesh into a MFnMesh:
>> > def deform(self,dataBlock,geomIter,matrix,multiIndex):
>> > inputH = OpenMaya.MArrayDataHandle(
>> dataBlock.inputArrayValue(self.input) )
>> > inputH.jumpToElement(multiIndex)
>> > inputGeomH = OpenMaya.MDataHandle(
>> inputH.inputValue().child(self.inputGeom) )
>> > inputObject = OpenMaya.MObject(inputGeomH.data() )
>> > meshFn = OpenMaya.MFnMesh( inputObject )
>> > Hope that helps,
>> > -Brian
>> > www.meljunky.com
>>
>>
>
>
> --
> www.chadvernon.com
>
>
> >
>
--
www.chadvernon.com
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---