Feb 18

I thought I would let people know that I will be giving a talk on our Character Pipeline at a conference called Evolve CG. Evolve CG’s main focus is to give students a chance to learn from people in the industry. The conference will be held at the Hilton Marina in Ft. Lauderdale, Florida on May 15-16.

http://evolve3d.net/feature-speaker-ryan-trowbridge/

Cheers,
Ryan

Feb 10

Did you ever wonder what Python does with all those variables and functions you write in the Maya script editor? No? Well I am going to tell you anyway. I recently refered to the Maya Script Editors Python global scope or main namespace as the main module to a friend. He said that I must have been tired and meant something else, but I didnt and here is why.

Type in and execute the following code into your script editor in a Maya Python tab:

print __name__

Which will print:

__main__

When you print __name__ in a module it will give you the namespace of the module itself. So why did printing __name__ work inside of the Script Editor? Now write a quick function and execute it in the Script Editor:

def test():
    """this function is a test"""
    print "test"

Next type and execute the following line:

help(test)

#Result:
Help on function test in module __main__:

test()
    testing

Continue reading »

Feb 06


Uncharted2: Game of the Year 2009

This post has nothing to do with Python or anything to do with character rigging. With that warning given I thought I would post something I had made to remember Uncharted 2: Among Thieves. My last project was by far the best project I have ever worked on. So far we have won more awards than we can count. Last time I looked there were 98 major magazine or online publications that had given us the Game of the Year award for 2009. So to celebrate this I decided to make something to remember the game by.

I had a poster we had on hand signed by all my colleges at ND, then I had a plaque engraved with Uncharted 2:Among Thieves Game of the Year 2009. I had all of these framed in a shadow box style frame. The boarders use the black, red, and white Naughty Dog colors. The shadow box style frame let me put the game cd, box, and plaque to the side of the poster. The frame shop did a great job.

I look forward to shipping our next game,
Ryan

Feb 04

Its been awhile since I posted. Ive been creating a lot of Python UI’s of late. I have seen others struggle with creating their first UI. There are a few gotchas and the best way to set up a Python UI is different than setting it up with MEL.

A good way to setup your UI is to encapsulate the UI in a class including the functions you will use with the UI. You dont need all of your functions inside of the class. If you need to work with a function that is external to the class, you can use a partial function. When you set a button command to use a function it is best not to give it a string like you would in MEL. You should pass the functions directly to the command. You should not pass the functions as if you called them however like function() but by just giving it the name. If you need to pass an argument you need to use a partial function so the function does not get called until the user presses the UI item. You should note the UI button command happens to always pass one argument even if you dont pass anything to the function. If you pass your function one argument it will receive two, or if you pass two it will receive three. This is easily remedied by adding an extra unused argument.

I have several personal projects taking up my time right now so I am going to be brief on the how to and what does what part. The following example should help you get started. You can execute it from the script editor and start playing around with it.

import maya.cmds as cmds
from functools import partial

def myfunc(inst=None, thing=None, arg=None):
    print 'arg: ', arg
    print 'inst: ', inst
    print 'thing: ', thing
    data = cmds.button(inst.btnA, query=True, label=True)
    print data

class ui():
    def __init__(self, winName="winTheWindow"):
        self.winTitle = "The Window"
        self.winName = winName

    def create(self):
        if cmds.window(self.winName, exists=True):
            cmds.deleteUI(self.winName)

        cmds.window(self.winName, title=self.winTitle)
        self.mainCol = cmds.columnLayout( adjustableColumn=True )
        self.btnA = cmds.button( label='Press Me - External Func', c=partial(myfunc, self, 'say...') )
        self.btnB = cmds.button( label='Press Me - Internal Func', c=partial(self.a, 'something...') )
        self.btnC = cmds.button( label='Press Me - Internal Func No Args', c=self.b)
        cmds.showWindow( self.winName )
        cmds.window(self.winName, edit=True, widthHeight=[250,75])

    def a(self, myarg=None, arg=None):
        print 'myarg: ', myarg

    def b(self, arg=None):
        print 'buttons require an argument'
        print 'the argument passed in will always be the last argument'

# create the window
inst = ui()
inst.create()

Have fun,
Ryan