Tuesday 16 March 2010

Ritalin - simpler camera navigation in Maya's viewports

When you come from a Max or Softimage background, you might miss that "automatic center camera interest on current selection" feature that allows you to tumble the camera around the center of the current selection without having to press the f key (or z in 3dsMax) and then dolly in and out again to fit whatever you've been working on propperly on screen.  Autodesk seems to have planned such a feature for Maya too, but never actually got around to implementing it in a truly usable way. In any view click View->Camera Tools->Tumble Tool (the little config box to the right of it actually). And there it is: A check box labelled "Tumble on object". That sounds nice, but unfortunately it only works for those objects directly under the mouse (which makes it hard to control when objects overlap), and fails on many common object types, like joints or lights.

Enter Ritalin, a Python script that will automatically set your camera's tumble pivots when the selection changes in the scene, and even when your selection is moved. Special case handling has been added for convenience that centers the tumble pivots on the currently active deformer (e.g. joint) when painting skin weights on a mesh, which is a huge time saver when painting hard to see or detailed areas like a character's fingers, where a considerable amount of time is usually spent on adjusting the camera in such a way that it tumbles without constantly loosing the paintable area out of sight, and where pressing f on your keyboard usually doesn't help because it will center on the selected mesh, not the active deformer.

Lots of text to describe such a simple thing right? A short video shows a lot better  how it looks and feels like.
If that video looks cut off on the right you might want to watch it on youtube directly:
http://www.youtube.com/watch?v=RmFiOkboAR0




Result:
You will find yourself not having to press "f" so often anymore, camera pivots are centered completely automaticlally, and your viewport "calms down" a lot. Your eyes and poor little f key will be eternally grateful, let alone the time you can save and concentrate on more important things, like creating art for a change.


Installation:
1.) Download http://keyvis-dev.googlecode.com/files/RitalinForMaya_2008-2010_1.4.zip
2.) Unpack and copy the files to your user scripts directory.

In WindowsXP this folder is normally normally located at
C:\Documents and Settings\-YourUserName-\My Documents\maya\2009-x64\scripts

In Win7 (and I think Vista too) the path usually is 
C:\Users\-YourUserName-\Documents\maya\2011-x64\scripts


For Mac finding this path can be found using a different procedure, please see Damien Hess' comments below.

For Linux: Maybe someone can help out with information here, I don't have access to a Linux workstation.

Your actual path depends on your user name and Maya version you want to install this for, so it will most likely look slightly different compared to above examples. If this folder already contains a userSetup.py, just copy the contents from the userSetup.py that comes with Ritalin and paste it at the end of your already existent useSetup.py file. Change the file path according to your user name, user scripts folder location and Maya version. Save it.
The mechanism is that Maya always runs any script code in the userSetup.py file automatically when it starts. We're simply using this mechanism to load Ritalin on startup. 

3.) (Re)start Maya.

A Ritalin menu should appear in the main menu bar. You can disable or re-enable Ritalin there.
There's also an option to disable skin weight painting integration separately.


For TD's:

The archive contains a modified version of a mel file that ships with Maya - artAttrSkinCallback.mel.
It is important that the Ritalin'ed version of it gets sourced after Maya has sourced the original file from its native ...\scripts\others folder for the code change to take effect.
 

Note: The modified file only enables paint skin weights tool panel integration, and only some lines were added at the end of the global artSkinSelectInfluence procedure.
 If you are using a modified version of this file in your own pipeline you might want to add the extra lines to the same function in your version of the file instead of replacing the whole file. In case this is not practical, simply not copy the file at all, you will simply have to live without paint skin weights tool panel integration (clicking on a deformer in the paint tool panel will not center the camera's tumble pivot on it automatically). However, you will still be able to use Ritalin when right-clicking over a deformer in th viewport and choosing "Paint Weights" from the context menu to set the tumble pivots. Anything else will work normally.

Uninstall: 

Just delete the files from your user scripts folder.
In case you have modified your userSetup.py file, comment out, or remove, the line you copied into it too.

Disclaimer: 

This tool has been used successfully in production of several commercial game titles. Yet, it is provided "as is" and free of charge. I'm not liable for any damages incurred, use and modify at your own risk.
 

Should you encounter any problems or limitations, or should you simply like it or use it successfully in production, I'd love to hear about it. In any case, just leave me a comment below.

Stefan

11 comments:

  1. it is a shame that many users seem to be unaware of that treasure . i have asked billion times of that functionality in forums but a bunch of people could guess what i talked about . thanks million times

    ReplyDelete
  2. The reason ritalin is mostly unknown is that I haven't made a lot of noise around it. Also, many are unaware of other programs that have this feature for years(max,softimage,lw) and don't see how they could benefit from it. Glad you like it. There is also an update for Maya 2011 btw.

    ReplyDelete
  3. Experienced a problem with version 1.4 in Maya 2011 x64 on Win7; 8GB RAM. Ritalin when enabled causes the undoQueue to turn off repeatedly. In preferences, undo is set to infinite.

    The previous version of Ritalin worked a charm in Maya 2010. Any ideas on a fix? Thanks!

    ReplyDelete
  4. I will have a look. I'm using 2011 32 bit at work still and haven't managed to repro what you describe. I hope it's not a 64bit only thing/bug (in which case I couldn't do much to fix it).

    It would make testing easier on my side if you could describe a few steps with good reproducability. Also, what Maya service pack are you currently using?

    ReplyDelete
  5. Hi Stefan,

    Yeah, conversely I haven't tested this in maya 2011 x86 on my machine. I'm running maya 2011x64 hotfix 3.

    I've tried to find a pattern in this behaviour - a trigger. Tumbling the view or selecting a rig control will do it.

    Have tried blowing away my maya prefs. And weeding out all mels and adding them back piecemeal.

    Here is a link to my public Dropbox folder: http://db.tt/UUlKa7

    The zip file contains a screencap and the script editor output in echoAllCommands. Hope it helps towards a fix or to exonerate Ritalin.

    Thanks!!

    ReplyDelete
  6. Right, I was able to repro using a different approach. It turned out this happens due to a bug introduced by Autodesk in Maya version 2011, but I think I found a way to work around it. Here's the update: http://plutometro.blogspot.com/2010/08/ritalin-hotfix-for-maya-2011.html

    Please try and let me know how it goes.

    ReplyDelete
  7. Can someone please explain how to get this to work on a Mac in Maya 2010/2011?

    I've tried setting the path to "/Users/Shared/Autodesk/maya/2011/scripts/Ritalin_Public.py", but when I launch the Maya application, Ritalin doesn't seem to appear.

    Any assistance with this would be most appreciated. Thanks in advance!

    ReplyDelete
  8. In Finder, press shift-command-g. Paste this directory path: ~/Library/Preferences/Autodesk/maya/ In the resulting Finder window, open the folder for your maya version, eg. 2011-x64. Then open the scripts folder. Drag a copy of Ritalin's .py files into here.

    Select Ritalin_Public.py and press command-i for Get Info. Copy the text of the directory path beside "Where". It will look like this: /Users/USERNAME/Library/Preferences/Autodesk/maya/VERSION/scripts/Ritalin_Public.py

    Close out of Get Info. Right-click on userSetup.py and select Open With…, then choose or browse to Textedit. Once userSetup.py opens in Textedit, replace the directory path for Ritalin_Public.py with the directory path text you just copied from Get Info. Make sure the result is still encased in quotations inside the brackets. Save userSetup.py and close out.

    Fire up Maya and your good to go!

    ReplyDelete
  9. Thanks for the fix Stefan! All good now.

    ReplyDelete
  10. Hi Stefan ,
    i am using ritalin i am happy with its functions . but maya still cant reach in the taste of max navigation . is there a way to convert it to max's navigation .

    thanks in advance

    ReplyDelete
  11. Hi Anonymous, Could you elaborate a bit more on what exactly it is that you miss? When you write that it's not exactly as in Max, do you mean the keyboard shortcuts which are different?

    ReplyDelete