This post will cover how to fix weight maps for Half-Life 2 characters after you've extracted them, as described in the previous how-to post. The XSI import is broken, so you have to do a bit of work before you can create animations!
So far, you've extracted all the textures and models from a .mdl file. Now, we'll import them into XSI and fix the weight maps so that you can animate. This process would also work for tweaking your weight map after you've rigged a character from Poser or some other source.
You will need
A decompiled model and its textures
XSI Mod Tool 6.01
XSI Valve Source Plugin
Patience!
How it's done
Importing a model
1) This is the easy part. Drop down on the ValveSource menu in XSI and choose "Import SMD..." and a dialogue box will come up. Navigate to your SMD file (you probably want to choose the one that is a reference model), and choose the folder that all your textures are in. Check off "Import textures" so that you can get an accurate view of how your model will look. Make sure your textures are all in .bmp format or the importer won't be able to find them. Click OK, and your model will import!
2) Some quick key commands that will help you: press 'z' for the zoom and pan tool (middle and right click zooms, left click and drag pans), and 'o' for the orbit tool, which lets you move the camera around in the user view panel. Go ahead and use the 'z' tool so you can see your whole character in the User view. Now we'll turn on a couple shading options so that we can see them better.
3) First, on the top right menu for the viewport, click "Constant" for the shading option.
Then, under the eyeball menu, make sure that both "Weight Points" and "Weight Maps" are checked off.
When you do that, and select the object, you'll get a multicolored model:
All these colors represent how the joints of this character affect the vertices around them. For example, look at the bright red on the right toe (to your left!) of the character. Everywhere that bright red is will be affected by the joint that is associated with the right toe.
4) Let's modify a joint. It'll be easier if we use Project Explorer. Press '8' to bring up an explorer window. Go ahead and switch to an orthographic view--I'm going to use right side. (You can do this by using the drop-down menu at the upper left of the viewport: click and change from 'User' to 'Right'.). Reposition using the 'z' tool so that you can see the whole model again.
5) See all those little multicolored plus marks? Those are your character's joints. It's kind of hard to tell which belongs where since we have no sense of depth, but using the Explorer we can narrow them down.The character's left leg is the one closest to it, so I'm going to show you one of the joints associated with that. There's a little star looking thing in the Explorer that says 'Bip01_Pelvis'. Click on it to expand that tree. When you find Bip01_L_Thigh, click on it, and you'll see that joint highlighted in white.
6) So, let's say I'm trying to get my character in a sitting position. I would want to rotate the thigh so that her leg is at a near 90 degree angle to her torso. I choose the rotation button ('r' on your right panel) and I rotate about the y-axis (green) by clicking and dragging around it.
7) Something's obviously wrong. See how those points near the back of her calf are incorrectly positioned? If you look around in the user view using 'o' to rotate around, you'll also see that her knee has caved in and her waist is doing some strange things too. This is because the weight map isn't working correctly. The thigh joint is inappropriately affecting those points, so we need to fix them. Translation isn't the answer because the animation for this character won't be saved on the basis of each point's location, but only on the basis of how those joints have moved.
Fixing the weight map: Smoothing things out
There are several ways of fixing the weight map, but before we go to tweaking individual sections and points, there's a way to automate a good bit of that process.
1) Switch back to user view and weightmap shading (as described in the first step of this tutorial). I'm also going to put her leg back to normal position, but you don't have to. Now, click Animate > Envelope > Smooth Envelope Weights.
2) A dialogue box with a little graph pops up. Now, to be quite honest with you, I only understand on a very basic level what this graph does. In my definition, it modifies how the weights are distributed for the points. There's also sliders for Neighborhood Depth and Distance Profile Scaling. All of these settings together determine how points are weighted. Now, it's your job to play with those settings until the weights are mostly right.
If you click the "?" button in that dialogue box it will tell you a bit about how the graph works. If you look up the help file for "Smooth EnvelopeWeight Operator Property Editor" then it will tell you a bit about each of those attributes. The summary is that for each point, the weight is calculated as a weighted average of what's going on in the points near to it. Changing the neighborhood depth changes the amount of nearest points it takes into account. I don't really understand what the distance profile scaling is. The distance effect profile is a graph of a function that determines how the weighting works when calculating the average.
I'm sure there's a scientific method for doing this, but because I don't understand it, I opt more for art than science. Look at the picture of the weight mapped model now. See how it's all splotchy? In the splotchy areas, that means that multiple joints are affecting those areas. For example, check out my character's face:z
So, you can see that it's mostly blue, but it has these pink and yellow splotches. That means that those points are affected by something different than the "blue" joint. If I sift through my joint tree enough, noting that the joint colors correspond to the weight colors, I find that the Head1 joint is blue (that makes sense!), the Neck1 joint is yellow, and who even knows what that pink color represents!
For all those points on the face, it makes sense for the position and orientation of the head joint to influence them, but not the neck joint. Now, note that the head joint is still related to the neck joint, and what's not what we're editing. We're just editing how points relate to joints, not how joints relate to each other.
3) So, the way I edit visually is to play with the parameters until the model doesn't look so splotchy. This indicates to me that the points that are near to each other are influenced by the same joint(s) and not a strange combination of joints. You kind of want clearly separated colors with smooth transitions between them.
In this case, I set the neighborhood depth to 5 and the distance profile scaling to 25. This leaves me with a much smoother, more coherent model. All the blue points are together. Colored points are grouped with similarly colored points (although colors are reused). Colors transition smoothly but there's clear definition between body parts. I'm pretty happy with this so I go ahead and exit out of that dialogue box.
4) If I go back to an orthographic view (or really, however you prefer) and try my movement again, you'll see I get a much cleaner look!
5) You might want to go ahead and save this model in the state it's in now just in case you mess something up down the road. Assuming all your weights are correct (which they may or may not be) this could turn into your "reference pose", which is the standard pose that your character takes with all the correct weights. I'd recommend saving it in XSI proprietary format so that you won't run into strange problems importing it later if you do mess up. There's something weird about having to save these in a proper location. If you saeve them in C:\Softimage\XSI_6.01_Mod_Tool\Addons\ModTool_Database\Scenes it works out for me.
Fixing the weight map: Tweaking points
Play around with your joints a little. You'll see that they're mostly working like they should. However, you may run into some points that are still doing some strange things that you'll want to tweak a bit. I'd suggest going through and rotating each of the joints to see if there's anything that looks strange when you do. Now, of course things will look strange if you rotate the joints beyond what your own body would do. Rotate them within normal bounds, though, and everything should look okay.
My model's looking pretty good right now, but I'll step you through the correction process. Let's say that for some reason your weighting is wrong and points are being misplaced from your hand when you move some joint that shouldn't affect your hand (say, your neck or something).
1) Select the object, then drag a box around the points that are affected. Right now, I'm dragging a box around the hand. All the points inside that box will turn red to indicate they are selected.
2)Go to Animate > Envelope > Edit Weights... A dialogue box will appear.
This dialogue box holds a whole lot of animation. There is a row for each vertex selected (each is numbered in the leftmost column) and a column for each "deformer" or joint that affects those set of points. If a box is highlighted in purple, that means that the point is affected by that joint.
2) An easy way to get rid of improper weighting is to look at those column names (mouse over and pause to see a tooltip with the full name) and see if there are any that shouldn't be there. For example, I've selected the left hand, so it's reasonable for me to expect all five fingers to be there, and the hand, and maybe the wrist. Even the neck and the back might affect the way my hand is positioned a little. However, if I see something like the character's right foot, I know that's incorrect.
Find the columns that shouldn't be there. Select the whole column by clicking on its header. Adjust the weights to be equal to 0 for that column by using the slider just above the chart, and chosing a mode: Abs sets the weights to what you slide on the slider, Add adds or subtracts what you choose on the slider, and Add % modifies the weight by what percentage you slide on the slider. You also want to make sure "Normalize" is selected because it's necessary for the weights for any one joint to add up to 100%. That way, as you adjust a point, the extra percentage is given to other joints. Here, I've reduced the Neck's influence to 0 over my hand as an example
Do this for each column. You can also use this dialogue box to tweak point by point, or decrease (instead of eliminate) the influence of a joint on a point.
3) Again, it's a mostly visual check to see whether this worked or not. An alternative check besides trying animation is to investigate each of the joints and check which point they influence. To do this, keep the weight editor window open and press '8' to open the explorer. Zoom out to see the character's full body. Now, select any given joint, and the points it affects will be highlighted in white. For example, I've selected the right upper arm in this screenshot.
Like I said, my weighting looks pretty good, so all those points look like they're ones that could be affected by upper arm movement. But, if there was a stray point or two, I could single it out from there and change its weighting using the Weight Editor.
Another method: Weight Painting
Another method of changing weightmaps is painting them, which is a bit more visual and possibly more intuitive.
1) Press 'w' to get the weight paintbrush, then press Ctrl + w to get the Brush Properties box.
2) I really don't understand how to pick which "color" or joint to paint with from here, and I can't find good documentation on it, but the idea is that you can then paint on the weights that you want to change, whether it's adding weight, replacing with a new weight, or smoothing out the nearby weights.
That's pretty much it for weightmapping! After you get a good weightmap be sure to save a copy, then you can begin animating. The next tutorial I write will probably be about that!
For now, I'm saving everything in XSI proprietary format so that import/export is not an issue. Later on, I'll also be writing about getting things back out to .smd format and compiling them into a usable model for the Source Engine.
















No comments:
Post a Comment