Friday, October 19, 2012

Cloth - Level of detail

How much detail should your simulation mesh have?  When do you have too little?  When is it too dense?

That's a good question.

I saw this image a week or so before I went to SIGGRAPH:

It's one of Merida's simulation gowns from Brave.  I think they use a proprietary simulation software (it looks like some super variant of Qualoth to me), but look a the detail they have in the final mesh.  When I went to SIGGRAPH I was lucky enough to ask Claudia Chung (!!!) a question.  What are their simulation times like?  Did they have to wait minutes and minutes per frame, or was it a little faster?  She told me that if it was taking longer than a minute or two a frame, then something was very, very wrong.

For people with average computers like me, I show them this:

(click to view the original size)
Which one of these resembles your simulation mesh?

#1 Doesn't have enough information.  You can work with it, but it probably won't fold well over corners and you won't get nice billowing and wrinkling in your cloth.
#2 Is great and my personal choice.  Sim times are good, and you can get great detail (wrinkles, billowing as the character moves, nice overlap) out of it.
#3 Is too much.  If you have a fantastic computer, you might be able to pull it off.  Maybe.
#4 ... I hope your computer has a will.

I will say this.  Not every cloth object needs to have the same amount of detail.  If it's something that's not seen as much (like an underskirt), see if you can get by with less.  The same goes if your final cloth mesh is thick.  Thick cloth (like leather) wouldn't billow in the wind and fold in on itself as much as something thin (like silk), so you could probably get by with less detail.

Here's something else to keep in mind.

As a reader and colleague pointed out, the poly count of your mesh is also linked to how your simulation works, not just it's visual level of detail.  Take for example the four planes above.  The same settings wouldn't work for all four planes.  If you get the first one to work with a stretch resistance value of 30, the second one will probably need a stretch resistance value of 65 or 70 in order to behave, and so on and so forth.


Tuesday, October 2, 2012

Revisiting dockControl and Python classes

I hate floating windows with the passion of 1,000 red hot suns.  There was nothing I could do about it in version of Maya older than 2011, but now I have the ability to dock windows.  I talked about this in an earlier entry.

I've been watching a series of building UI's in Python by Jeremy Ernst that is just fantastic (and he hates floating windows too!  Yay!)  He uses the dockControl command religiously after video #4.  It's fantastic, but he never really mentions the fact that your script will error out if you use dockControl in a version of Maya that's older than 2011.  He does briefly touch on the fact that you can make docking true or false, but I thought I'd go ahead and share what I did.

If you're using Maya 2011 and higher, the window will dock.  If you're using Maya 2010 or lower, the window will float.

This may not be the most "efficient" way to do this, but it works.  If you know of a better or cleaner way to execute this, feel free to tell me.  I'm not offended if someone sends me an e-mail that says "idiot, you could do this in one line if---"

If you have no idea what the widgets dictionary in this script does, watch Jeremy Ernst's Building Maya Interfaces with Python video series, specifically video #6.  That's where he introduces it.

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

class suitSuite():
    def __init__(self):
        self.widgets = {}
        self.winName = "suitSuite"
        self.dock = ""
        self.v = mel.eval('getApplicationVersionAsFloat')
        if self.v >= 2011:
            self.dock = True
            self.dock = False

        self.createUI(self.winName, self.dock)

    def createUI(self, winName, dock):
        #If Maya version is 2011 and above, create a dockable window, else create a floating window
        if dock == True:
            if mc.dockControl(winName + "_dock", exists = True) or 
mc.window(winName, exists = True):
                mc.deleteUI(winName + "_dock")
            if mc.window(winName, exists = True):

        self.widgets["window"] = mc.window(winName, title = "Suit Suite v. 0.1", width = 350, height = 500)
        self.widgets["mainLayout"] = mc.columnLayout(width = 350, height = 500)
        if dock == True:
            mc.dockControl(winName + "_dock", label = "Suit Suite v. 0.1", area = "left", allowedArea = "left", content = self.widgets["window"] )


Monday, October 1, 2012

Python and MEL

I don't take full advantage of the fact that Python is an object oriented language.  I'm so used to the procedural MEL that I limit myself in Python.  I was writing a hair script in MEL and decided that Python would be better, but I ended up just writing it in Python the same way I'd done it in MEL.  After figuring out Python's classes and going back to my hair script... wow.  Classes make things so much easier.  I'm still muddling through, but I'm so excited.

I feel like a new world has opened up to me ^_^