This is a re: to one post up, Chad and I obviously did a little simul- posting :)
On Feb 12, 10:03 am, jasonosipa <jason.os...@gmail.com> wrote: > Sure - logically I get that, too, but tactically, I don't, and that's > the problem. > > Usually, in non-deformer town, to pull information about a connected > object out of the dataBlock, you'd need to have declared an MObject > for the attribute in the class, then created and added the attribute > in your init, only then do you know what you can even get at in the > compute: > > class myNode(): > myAttr = om.MObject > > def compute( self, plug, dataBlock ): > sourceMesh = dataBlock.inputValue( myNode.myAttr ).asMesh() > #and away we go... > > def nodeInit(): > tAttr = om.MFnTypedAttribute() > myNode.myAttr = tAttr.create( 'somethingCool', 'sc', > om.MFnData.kMesh ) > myNode.addAttribute( myNode.myAttr ) > > But, in a deformer some of the connecting and setup happens a little > smoke-and-mirrors, and (it would seem) I don't have access to the > mesh, to make it an MFnMesh, to be able to run > MFnMesh.getVertexNormal, OR I'll have to get that info another way, > which is the core of my question. To get at the mesh in the compute > example I just gave, I have "dataBlock.inputValue > ( myNode.myAttr ).asMesh()". Now, that's only possible because I > created and added, and can ask for the inputValue of myNode.myAttr by > name. If, as the deformer does, attributes have been created/ > connected "under the hood", how do I access them? Essentially, I'm > trying to do "dataBlock.inputValue( myNode.????? ).asMesh )", > where ????? is some access through the tweak and groupParts that are/ > were created, or there is some more magic to dataBlock eluding me. > > There has to be a way, in MPxDeformer, to get more than just > positions. I can't imagine that Maya would provide a 'basic' deformer > with MPxDeformer that couldn't do a bloody thing besides read ONLY > positions, nothing else, then tangle them, then write them. Seems > kinda silly and wildly limited. I'm sure I'm missing something, some > other access to the normals... > > So, phrased another way - "How do I get normals in a deformer? ( def > deform(...): )" > > I hope this clarifies the pretzel a little more. > > On Feb 12, 9:18 am, Matthew Chapman <chapman...@gmail.com> wrote: > > > 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 <jason.os...@gmail.com> 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. -~----------~----~----~----~------~----~------~--~---