PDA

View Full Version : API: creating and adding springs


ottom
09-07-2006, 09:30 PM
hello,

I am new to Maya-API and would like to create my own add-springs-command.
How do I create spring object and add springs to it without executing the mel-command spring?

dbsmith
09-07-2006, 09:41 PM
Look in the Maya devkit/plugins folder and find an example of a command. These are the classes that extend MPxCommand. A really good example of a command is the HelixCmd.cpp (or Helix2Cmd.cpp or something like that), which is very similar to the kinda thing you want to do (eg make a command that creates something).
Have a look at the methods in there and whats going on, you need a creator() method, a doIt() method (which is called when you call your MEL command in maya).
Then you need two methods outside of your class called initializePlugin and uninitializePlugin, which register your MEL command.
eg (inside initializePlugin)
status = plugin.registerCommand( "createMySping", mySpringCmd::creator );

Most other questions can be answered by checking out Rob the Blokes site, or just wandering around the devkit examples and their docs

ottom
09-12-2006, 03:23 PM
thank you for the advice.
Now I know how to create my own command-plug-ins with undo/redo-capability, I know how to iterate though polygon objects and manipulate them. But I still do not know how to create a spring node and add springs to it. In the API classes I only found the MPxSpringNode for creating spring nodes with custom spring laws - this is not what I want... I want to use the default spring node and add springs to it - how to do that?

dbsmith
09-13-2006, 02:38 AM
What you can do is create a normal spring attachment in Maya, open up the hypergraph/hypershade and have a look at all the connections. I haven't done this myself, so I don't know what happens with the spring command.

But I assume that it creates a spring node that is somehow connected to the particle/softbody node. Have a look at the input/output connections/attributes so you get a feel for how things work.

In your API, you can create new instances of the nodes you require. Eg, you may select your particle, then call in MEL your custom spring command. This runs your API doIt()/redoIt() method. From there you can get a handle to the currently selected particle, create your spring node, then manually connect up the appropriate attributes.

Remember, your plugin should really have two parts: a command, and a node. When the command is called, it creates your spring node and connects it up to your currently selected particle (or whatever).

Apart from that, Im not sure I can help further

ottom
09-16-2006, 02:25 PM
thank you for the advice.
I found out that idMapping is the attribute that holds the information about connections. Here is a quotation from maya-help:

This attribute holds the mapping information for the particle IDs<<==>>Index into per-particle attribute arrays. It will connected with aIdMapping of particle nodes.


Well, but how do I access this data? There is no attribute idMapping (or like it) neither in MPxSpringNode nor in MPxNode :(

CGTalk Moderation
09-16-2006, 02:25 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.