Friday, November 1, 2013

Defending my demo reel - How I started simulating cloth and hair

I can't believe I haven't made a post since February!  My how time flies!

I mention this a lot in person, but I don't think I've ever gone into how I got into hair and cloth simulation.

The TL:DR answer: I fell into it by complete chance.

The thick of it is, on The Rock in the Road, the project that comprises 70% of my current demo reel, was an animation project that I worked on as a junior and senior.  I was an effects major and I wanted to learn how to do effects on the project, but the only effect needed was cloth simulation.  I didn't even know cloth simulation was a thing!  My introduction to nCloth was about 10 minutes and then I was told to do the cloth simulation on a shot.  It was an unmitigated disaster.  I had no idea what I was doing and the documentation available online was minimal at best and definitely not aimed at total beginners.  It was a humiliating, devastating process for me.  Unable to finish shots caused my grade in the class to plummet.  I had nothing to show while my peers were learning and completing all sorts of things.

This went on for an entire semester.

I was determined to have not wasted my time.  I was determined to figure this out.  During the summer, I was able to work on the project and I'd learned just enough to work on a shot, but during the entire summer I still didn't successfully finish one shot.  Early in the fall semester, they were finally approved.  I later found out that I had been struggling on two of the hardest shots in the entire short!  The next shot I was assigned, I finished in less than ten minutes.  The same for the next one.  And the next one.  And the next one.  After all of my sweat and tears, I'd finally gotten the hang of it.  I can't tell you how rewarding it was to have my teacher (a total genius and a total perfectionist by the way) approve my shots.  It felt so good!

I'd become addicted to the struggle.  Figuring out what parameters to change in order to get the cloth to behave a certain way was like working on a puzzle.  I love puzzles.  I love solving them.  I love how it feels when it's finally been solved too.  That's how I feel every time I work on a cloth shot, no matter how complex or simple it is.  The same goes for hair simulation, since the process is very similar.

I can't tell you how much I love what I do.

I'm still looking for a place to do it full time, but hopefully that'll come along at some point!

My demo reel hasn't gotten a LOT of attention, but many of the people who see it ask me a certain question quite often.  It's about the cloth in my reel, and why it seems stiff.

The answer to that:

During my struggles, I saw the midnight showing of Up.  Like Rock in the Road, the characters of Up have clothing that looks very thick.  Look at the main characters jacket for goodness sake.  Look at the thickness of his lapels and sleeves!  Cloth that thick wouldn't billow in the wind, that was my reasoning at least, and imagine how validated I felt when I saw how the cloth reacted in Up.  It was very understated, but very true to the model.  The end result just blew me away.  I loved it!

That was my intention in Rock and the Road.  It's not that I don't know how to make skirts flow and capes billow, it's that a 7 inch thick cape 'wouldn't' billow like an average cape would, in my honest opinion.  Sure it would move, just not a whole lot.  I'm proud of the work on my demo reel, and I hope to add more projects to it soon.


Monday, February 11, 2013

Python - Keeping things brief AND readable

I've always believed that clarity should trump brevity when it comes to scripting.  This is especially true of Python, since it's already so readable.  That's why some things I've written area little longer than they really need to be.  However, if I stumble across a way to keep things brief and readable, I try to use it as often as possible.

For instance, in Maya with Python this is how you check for a window and delete it if it exists:

if mc.window(winName, exists = True):

But you could do the same thing with less typing:

try: mc.deleteUI(winName)
except: pass

I also like to check the version of Maya that the user is using to avoid conflicts and such.  I like dockable UI's but versions of Maya older than 2011 can't support them.  So if the user has Maya 2011+, the will dock, otherwise it will float.  I've been doing it like this:

class ExampleClass():
  def __init__(self):
  self.dock = ""
         #Get the users version of Maya
  self.v = mm.eval("getApplicationVersionAsFloat")

  if self.v >= 2011:
  self.dock == True
  self.dock == False

But you can do the same thing with FAR less lines:

class ExampleClass():
  def __init__(self):

  #Get the users version of Maya
  self.v = mm.eval("getApplicationVersionAsFloat")
  self.dock = True if self.v >= 2011 else False

And it's just as readable.

When I deleted my dockControl, sometimes my window wouldn't delete.  By using a try, escape and else clause you can ensure that everything will be deleted if it exists in your scene.

import maya.cmds as mc
import maya.mel as mm

class ExampleClass():
  def __init__(self):
  self.winName = "exampleWin"
  self.v = mm.eval("getApplicationVersionAsFloat")
  self.dock = True if self.v >= 2011 else False

  self.exampleUI(self.winName, self.dock)

  def exampleUI(self, winName, dockOption):
  try: mc.deleteUI(winName + "_dock")
  except: mc.deleteUI(winName)
  else: pass

  exWindow = mc.window(winName, widthHeight = [300, 300])
exLayout = mc.rowColumnLayout()

  if dockOption:
  dockWindow = mc.dockControl(winName + "_dock", area = "right", allowedArea = "right", content = exWindow)