View Full Version : Maya Python API - deformer interacting with another geometry
11 November 2011, 02:53 PM
Hello, all. I am going to attempt to write a deformer which will make the geometry interact with another object for collision. it is kind of like a fake soft body effect and does not need to be accurate.
Can anybody please show me which API class I should be looking into? Currently, I am studying the mpxDeformerNode using the reference and whatever I can get over the net, which is not much.
Thank you very much, it would be best if somebody can show me an example commented code using the Maya Python API as I do not know C++ and I do not have any plans of learning it in the near future.
11 November 2011, 04:43 PM
MPxDeformerNode is the class to build a deformer. You have to write your algorithm in the deformer function. There you have a dataBlock from which to extract input data like in the normal compute method of the MPxNode class. To apply the transformations use the iterator, which is the second argument passed to the deform, and multiply any point by the matrix, which is the third argument, so you can work in world space coordinates.
If you don't intend to use manipulator/deformer handles my advice is to use a standard MPxNode and it's compute method. You can easy manually connect the nodes in the hypershade like so:
srcMesh.outMesh -> myNode.inGeometry
myNode.outGeometry -> resultMesh.inMesh
, where inGeometry and outGeometry are just typed attributes (MFnData.kMesh)
If you want to paint weights you can create a doubleArray attribute and just force Maya to paint over it by the
artSetToolAndSelectAttr "artAttrCtx" ("myNode.myNode1.weightMap");
Just have in mind that python is not exactly fast when polycount rises, and if you plan to use ray intersections between two complex geometris it will become really slow.
11 November 2011, 06:35 PM
Thank you very much. I have been reading some of your posts as cached search file from Google.
Yes, I came across the mpxDeformerNode while I was studying the yTwistNode example. I can make some simple deformers with the modification of that scripted example of the Maya Python API.
My intention at the moment is to use "accessories", I think I will need the MPxNode class?
Thank you for the examples, in the reference, it says that I can have as many input geometries as I want, so am I right to assume that inputGeo can be displaced by inputGeo?
Lastly, I hope that anybody can please point me to a site that has some Python API resources and guides, looking for commented codes and websites can be hard. This is something not many people want write about.
11 November 2011, 06:35 PM
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.