You should implement the compute method instead of deform if you need the geometry MObject. Getting the inputGeom handle in the deform function causes an extra graph evaluation. It will also let you get the MObject of the output mesh (deformed geometry).
Chad On Tue, Sep 14, 2010 at 1:56 PM, Skarone <[email protected]> wrote: > I m trying to figure out how I could use the MMeshIntersector for > collision. > If I use it in an MPxDeformerNode, in conjunction with the geomIter, I > will get the vertex position without the deformation? > Because the MMeshIntersector::getClosestPoint can use the vertex > position to detect a closest point to another mesh, I think if the > actual vertex position is the point use it for the > MMeshIntersector::getClosestPoint. > The vertex will continue moving if the mesh collide with that point. > But I dont know how to get the deforming mesh inside the deform() > > Heres is my code: > > def deform(self,dataBlock,geomIter,matrix,multiIndex): > > input = OpenMayaMPx.cvar.MPxDeformerNode_input > inputArray = dataBlock.inputArrayValue(input) > inputArray.jumpToElement(multiIndex) > inputData = inputArray.inputValue() > inputGeom = OpenMayaMPx.cvar.MPxDeformerNode_inputGeom > inputGeomDataH = inputData.child(inputGeom) > inputMesh = inputGeomDataH.asMesh() > sourceFnMesh = OpenMaya.MFnMesh( inputMesh ) > > connected = False > verts = OpenMaya.MPointArray() > geomIter.allPositions(verts) > maxDistHandle = dataBlock.inputValue(self.aMaxDistance) > maxDist = maxDistHandle.asDouble() > > try: > colliderMesh = > dataBlock.inputValue( sk_collideNode.aCollider ).asMesh() > colliderFnMesh = OpenMaya.MFnMesh( colliderMesh ) > connected = True > > except: > connected = False > > if (connected): > intersector = OpenMaya.MMeshIntersector() > intersector.create(colliderMesh) > point = OpenMaya.MPoint() > > while geomIter.isDone() == False: > ind = geomIter.index() > > sourceFnMesh.getPoint(ind,point,OpenMaya.MSpace.kObject) > meshPoint = OpenMaya.MPointOnMesh() > try: > intersector.getClosestPoint(point, > meshPoint,maxDist) > FinalPoint = > OpenMaya.MPoint(meshPoint.getPoint()) > except: > FinalPoint = OpenMaya.MPoint(point) > verts.set(FinalPoint,ind) > geomIter.next() > > geomIter.setAllPositions(verts) > > -- > http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
