Monday, 6 August 2018

PyQt Character Picker

I finally got my lazy ass into gear and posted up my example of a character picker. This is used by our animation department who happily don’t seem to have much in the way of complaints about it.
In this post I will run quickly through the main tool. In a further post I will describe the building process in a little more detail.

The tool is built using PyQt. The main display runs on an QGraphicsView which takes a list of shapes stored in a json file rebuilds them as QGraphicsPolygonItem before display. These shapes are simply a stored set of points with extra details such as colour, functionality and applied commands. These are all derived from the building process within Maya where a set of curve objects are created to define the appearance of the picker view. It is during this creation process that the behaviors of the picker items are also defined before being written out to the json file which then becomes available for that character or object whenever it is loaded into a scene.
When an animator runs the viewer it looks in the scene for an attribute that holds the path to the json file. There is usually one per character but there can be any number of these for any use case. We use them for complex characters but it could be also be utilised for anything such as a set of basic props or more complex mechanical objects. The tool lists the characters in a drop down and switches it’s visual context based on which one is currently active. The use of the QGraphicsView class gives the ability to zoom, pan and drag select items. The QGraphicsPolygonItem class also allows you to control the way picker objects are highlighted and their standard appearance down to features such as controlling the size of outlines.
By right clicking on the picker view the animator gains access to a set of hidden commands that appear in a menu. Again these can be anything at all but would obviously be best suited to commands where using a click-able button does not make sense or simply to remove clutter in the picker.
Additional features include the use of a QDockWidget for the dock-able menus at the bottom of the interface. In our case these contain common animation tools so that animators do not need to move far away from the picker to find tools that they will need to use. Of course some do not like them visible so additional to the ability to position them anywhere on the screen they can also be hidden away if needed.
All of this is pulled together into the standard QMainwindow which allows animators to resize the window for certain purposes. When closed the picker remembers the way it has been laid out and adopts this style the next time it is opened.

I have to give a shout out to Cesar Seaz who was my inspiration in the way I approached this picker. Check out his example here. You can navigate his document by using the cursor keys.

Here is an example video of the final picker.

PyQT Character Picker for Maya from SBGrover on Vimeo.

1 comment:

  1. Hey, nice job. Actually was trying to do exactly same type of GUI, but images based, not maya curves. I was wondering could you explain a little more about how do you store curve data in json and apply it QGraphics? Cause it looks much nicer to do in a long run. Thank you