In order to create a Maya plugin I utilized Brent's information from his power point presentation and also information from Complete Maya Programming by David Gould.
| Step 1: The project creation wizard is not installed (but if you try to create a project then a blank file will be created so that you don't have to follow Brent's instructions for creating a Maya file) so click on MayaPlugInWizard, name the file and hit OK. |
|
Step 2: After hitting OK in the Step 1, this window should appear. I was working with Maya 7.0 so I changed it to that version. I then clicked on Plug-in Type and gave my plug-in a new name. You can also click on Included libraries to add more libraries to be automatically included when the wizard creates the default .cpp file. |
![]() |
Step 3: Go to File->Open->Project and look for the project just created. Then hit Open. |
![]() |
Step 4: Go to File->Open->File and a there should be a .cpp file given the name specfied in Step 2. Hit OK. |
![]() |
Step 5: At this point I had a blank Maya C++ API file. I then used Brent's instructions: 1) Make a Win32Project
| |
Step 6: Write the C++ funtion in the function called doIt | |
Step 7: After writing and compiling the project, an mll file should be created. In Maya, go to Window->Settings/Preferences->Plug-in Manager
Scroll to the bottom of the Plug-in Manager window and click Browse. A new window will open. Find the location of the .mll file and hit OK. The .mll file should now be loaded into Maya. And the command available for use. | |
Step 8: I opened up the Expression Editor ( Window->Animation Editors->Expression Editor ) and created a script that would run before everyframe. In this case, the command created by the .mll was sphere_sphere_interesection. Here is the C++ API code. |
|
Problems: For some reason, Maya did not want to find the sphere_sphere_collision plug-in in the rag doll scene. It always says that it could not find the plug-in. Maya also doesn't like to include more than 5 other plug-ins, luckily we only needed 5 of the 7 that I had made. All in all it was probably not worth it to use the Maya API and we should have used MEL instead. We would have saved a lot of time and energy had we researched the requirements of the API sooner and not made so many assumptions: the number one being that we could simply write the functions in regular C++ and then simply create a 'mask' Maya C++ API function overtop that would simply make calls to the classes we had written. Well, whenever we tried to make those calls, Maya would complain. As soon as we copy and pasted the code into the C++ API class then Maya would work just fine. A lot of C++ code did not get used as well because it had to be converted into MEL. Another fact about MEL that we were not aware of before the C++ code was written, was the fact that a MEL command could only return one value. So it became tricky to figure out how a single value was going to get returned when some functions had 15 parameters getting passed by reference and updated in the function. We also didn't know that the API could only return a few different kinds of obejct types. For example, I was never able to figure out how to return a vector from the C++ API to MEL, so I have to create an array of doubles and pass it back that way. I initially was having trouble passing vectors to the API as well and was passing everything in as a double, but luckily towards the end I figured out how to do that with the help of the Complete Maya Programming book. It was also frustrating to use the book because it was written when Maya 4 was the standard, which is definitely not the case today. Also, the Maya Visual Studio Plug-in Wizard is not installed on the computers at ACCAD, so it took some time to figure out how to use the project creation that Brent had described and the file genereation that the Wizard provided (so that I didn't have to sift through all of the rest of Brent's required code). |
|
-