View Full Version : API: Getting normal from the deform method.

04 April 2011, 07:25 AM
Hi! I am currently writing a deformer for Maya using the Maya API with Python. I am using the standard iteration method to iterate through each point on a polygon mesh. I want to retrive each vertex "original" normal, that is, the normal before the mesh is being deformed by my deformer. I have figured out that I have to do something with inputGeom.
I have been googling around a bit, as well as spent way to much time trying to figure out things from the API examples Autodesk provides us with. All without any luck. Well I found some help, but I am having trouble converting the information from c++ to Python.


Robert Bateman
04 April 2011, 09:40 AM
Just attach an MFnMesh to the input geom (Make sure you get the MObject from the MDataHandle input in the compute!). *If* the surface has normals, you'll be able to get the normals from it....

04 April 2011, 02:00 PM
// get the connected geometry mesh, it is connected to input[i].inputGeom
MArrayDataHandle hInputArr = data.inputArrayValue(input, &mstat);
// this is a data handle to index[multiIndex]
MDataHandle hInputData = hInputArr.inputValue(&mstat);
// this is a data handle to index[multiIndex].inputGeom
MDataHandle hInputGeom = hInputData.child(inputGeom);
MObject inputMesh = hInputGeom.asMesh();

You can attach MFnMesh to this MObject

04 April 2011, 02:07 PM
theflash: I found that description on the internet too, but I didn't manage to port that in to Python.

04 April 2011, 02:10 PM
Ah I see. I am not sure if I can help with python API.
So when using python you don't get correct MObject?

04 April 2011, 06:45 AM
input = dataBlock.inputArrayValue( OpenMayaMPx.cvar.MPxDeformerNode_input)

self.inputGeomObj = input.inputValue().child( OpenMayaMPx.cvar.MPxDeformerNode_inputGeom ).asMesh()
if self.inputGeomObj.isNull():

self.inputGeomFn = om.MFnMesh(self.inputGeomObj)

04 April 2011, 08:03 AM
Thank you very much uiron! :D
That solved it!

CGTalk Moderation
04 April 2011, 08:03 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.