r/howdidtheycodeit • u/QuestionsOfTheFate • Jun 11 '22
How do the character sliders that work with clothes, armor and animations work?
Weight, height, noses, etc.
22
Upvotes
r/howdidtheycodeit • u/QuestionsOfTheFate • Jun 11 '22
Weight, height, noses, etc.
13
u/felipunkerito Jun 11 '22
The slider is tied to a variable that gets updated once you touch the slider, that drives other attributes like colour or whatever. If the stuff it drives is computed on the GPU, then the parameter is passed as a uniform to seed whatever you wanna drive with it. But not sure if you are asking how a UI is programmed instead
9
u/MaciGuy Jun 11 '22 edited Jun 11 '22
With shapekeys. You create a mesh for thin, then adapt it to fat and muscular or any other way around and then interpolate between them depending on where you are in the weight triangle. Similarly there are additive shapekeys, for example breast size or bizeps size, which offsets a group of vertices by some fixed amount on some fixed direction, you can then apply that additive shapekey to whatever your mesh currently looks like on the body weight triangle and it'll just work because it's additive. As for the clothes it's the same thing driven by the same triangle or sliders.
6
u/thor_sten Jun 11 '22
"It depends" A) Resized skeletons. Characters and cloth meshes are rigged to follow an animated "skeleton". The same way they follow the "bones" rotations and translations on x,y and z (say a shoulder rotates everything attached to it -> the arm the hand, the fingers), they can react to a size change of a bone. This works to a certain degree but will often look comical & grotesque. So just resize the "elbow" of a character and his lower arm and hands (as well as the clothing associated with it) will follow in most engines. Do it a bit to much and you end up with Popey or the Hulk.
B) Shapekeys: Games like Skyrim use the same skin/mesh, with slightly variations of the body. Say, one slim, one fat and the engine calculates a middle ground between the two, depending on the slider you've chosen. But this also means you have to make just as many variations of clothing - one for slim, one for fat, otherwise a fat belly might stick through the clothing.
C) Deformation maps: Whatever Vodoo they are doing here: https://youtu.be/s7R_HHxCokU?t=1372 (seems less of a hassle than Shapekeys in the long run).
2
u/siorys88 Jun 12 '22
Check out "shape keys" (also known as "morph targets" or "blend shapes"). It's not a programming thing per se, but once I discovered how to do them in Blender it clicked within me: I had an epiphany as to how sliders work! In fact I immediately proceeded to make a customisable model that I then imported into my game engine. Using variables tied to sliders that tweak the mesh shape keys you can achieve this effect quite easily.
3
u/Domarius Jun 15 '22
Morph targets. So in the Sims, for the body weight slider, they have a skinny model at one end and a fat model at the other end. The 2 models are made from the EXACT same vertices, so all the game has to do is move the vertices between their positions in the 2 models based on the percentage of the slider.
For more extreme changes you could have several more targets along the slider, eg. It's more likely they have a "normal" body mesh at the 50% mark of the slider, and then the skinny and fat ones at either end, so 3 morph targets.