mstam at August 26th, 2010 17:30 — #1
I've kind of run out of Google, not really sure what to specifically search for so I decided to write up a thread here.
I was wondering how one usually implements characters/avatars with different physical features and/or different equipment. An (what I'm guessing advanced) example of this would be when creating a sim in Sims 3 (http://games.softpedia.com/screenshots/The-Sims-3-Create-a-Sim-Trailer\_2.jpg). How do they support different physical features? Not just changing nose but also making the characters skinny/fat, tall/short, different hair and so on.
Blend shapes/morph targets? All I can find regarding this is facial expressions and animations.
I'm lost, and I'm hoping that you can kind of point me in the right direction.
reedbeta at August 26th, 2010 18:16 — #2
Blend shapes would be my guess. I think the MakeHuman tool works that way; it has one master base mesh and then everything else is blend shapes. Anyway, it's open source so it might be useful to study to see how it does various transformations.
For height changes you presumably apply an overall scale to the skeleton as well. For accessories or switching among hairstyles etc. it's usually a simple matter of having many authored pieces of geometry that can be turned on and off. They're all pre-skinned to the same skeleton so they'll attach to the right spot.
thenut at August 26th, 2010 20:18 — #3
Yes, the common way is morph targets. You typically clone the base mesh, as Reed put it, and apply a different characteristic. There are some optimizations involved, but that's the gist of it. You can then morph your base mesh to the target by altering the range from 0.0 to 1.0. In its basic mathematical form:
final.vertex = base.vertex + Sum, 0, i**
Note: You can optimize this by working only with the vertices you need to and also by precalculating the delta target values rather than working with the target mesh directly, thus eliminating a subtraction from the above.
Real-time implementations add morph targets rather than multiply them however, especially when there are many morph targets. The mathematical forumla above is an example of multiplicative blending, which is non-degenerative and slow (O(n)). With additive blending, you end up with the formula:
current.vertex += ((target.vertex - base.vertex) * delta)
- Where delta is the difference in target values. If your slider was at 0.5 and it moved to 0.6, the delta would be 0.1.
- Notice there is no summation here. It's all done "on the fly".
This is done for improved run-time performance (O(1)), but you risk quality issues when users recurrently alter character features that share vertices, often resulting in geometric goo (which I have seen in some games). To a smaller extent, floating point precision also plays a role, but can be virtually eliminated by using doubles. Some implementations fix this by linking targets so that advancing one feature may undo another, or several others. I'm sure you've seen some sliders retract as you advance another? Oblivion does this. It's not a sure-fire solution, but often enough to help prevent such cases.
mstam at August 26th, 2010 23:56 — #4
Thanks a bunch, I'm off to try this out.
Have a nice day.