PDA

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


GabrielPettersson
04-04-2011, 08: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.

Cheers!
/Gabriel

Robert Bateman
04-04-2011, 10: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....

theflash
04-04-2011, 03:00 PM
// get the connected geometry mesh, it is connected to input[i].inputGeom
MArrayDataHandle hInputArr = data.inputArrayValue(input, &mstat);
hInputArr.jumpToElement(multiIndex);
// 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

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

theflash
04-04-2011, 03: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?

uiron
04-05-2011, 07:45 AM
input = dataBlock.inputArrayValue( OpenMayaMPx.cvar.MPxDeformerNode_input)
input.jumpToElement(multiIndex)

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

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

GabrielPettersson
04-05-2011, 09:03 AM
Thank you very much uiron! :D
OpenMayaMPx.cvar.MPxDeformerNode_input
That solved it!

CGTalk Moderation
04-05-2011, 09: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.