Skeleton "Hacking" / "Swapping" for Half-Life
OK, So in this tutorial I will show you how to "hack" or "swap" already rigged models to use different skeletons. We will then compile the targeted model to be used as our beloved Half-Life 1 Barney security Guard. For this tutorial I will be using the Leet model from CSS that I UV Chopped in my "UV Chopping for 3D Model Textures" tutorial.
What are we going to need?
- Rigged model and textures. Well, I will use the Counter-Strike Source Leet that I "UV Vhopped" with really high resolution textures for this one. Feel free to use anything else.
- The SD Barney model. I will use te one from "Diamond's Pack" - Basically the A.I. SD Barney. All I actually need is the skeleton. :)
- MilkShape 3D 1.7.8 I'm not sure if this is possible in the latest version of MilkShape 3d. I'll refer the tool as "MS3D" in any future references.
- Crowbar GoldSource and Source Engine Modding Toolset. This will be used for decompiling the SD barney. I don't like the results when using the original tools or the MS3D decompilers.
- Jed's Half-Life Model Viewer - We will use this to open for previewing our results. I'll refer the tool as "hlmv"
- Notepad++ This one is optional. You can always rename the bones in MilkShape 3D. I find it faster and easier to do so in Notepad++.
- Half-Life
Ok let us start.
Skeleton "Hacking" / "Swapping" for Half-Life Tutorial
- Open the barney.mdl file in hlmv.
Figure 01: Barney in HLMV
- De-compile the model with crowbar
Figure 02: Barney De-compile
-
Open 2 instances of MS3D. We'll use this to compare the bones.
-
Load the barney and the leet model in the two instance. Note: When importing the models make sure you un-tick "Rename Bones"
Figure 03: CSS Leet bones in MS3D
Figure 04: Barney bones in MS3D
Ok, compare the two models... They are in different pose, and the bones are quite different are they not?
So the number of the bones is different and also the names of the bones are also different... We need to change that...
Here is how they look like in Notepad++ if you open the .smd files
Figure 05: Leet .smd in Notepad++
Figure 06: Barney .smd in Notepad++
What we need to do is to take the SD barney skeleton as a guide and we need to rename every bone in our new model to match the bones of the barney.
For example:
"ValveBiped.Bip01_L_Thigh" will be named: "Bip01 L Thigh" "ValveBiped.Bip01_L_Calf" will be named: "Bip01 L Calf" "ValveBiped.Bip01_Spine" will be named: "Bip01 Spine"
I hope you got the point. :)
You can do that in Notepad++ or in MS3D. I prefer to do that in MS3D since I can see what is each bone responsible for, still Notepad++ has its advantages.
- So renaming the bones in MS3D is easy. Go to the "Joints" tab and click on the bone you would like to rename, in the field where the name is put the new name and push the "Rename" button.
Figure 07: Renaming Leet bones in MS3D
Note: If a bone is missing in the barney model, then it is not used. If the bone in the new model has something assigned to it you will need to re-assign it later to another of barney's bones. For now you can leave the original name. Just like the "ValveBipped.Bip01_L_Toe0" bone.
-
After you are ready export your modified SMD file (do not override the original).
-
Go to the second instance if MS3D, there you should have the barney model we are going to replace.
Go to "File" > "Import" > "Half-Life SMD" and select our Leet model we exported (the one with the renamed bones).
Figure 08: Importing model in MS3D
Select the reference .smd file and Click "Open".
IMTPORTANT: in the pop-up "SMD Import" un-tick "Skeleton" . If you do not the conversion will not work properly. :)
- OK, now the fun part begins! The model you just imported is not with the same size and shape of the original barney model!
You'll need to manually scale the model to fit in the skeleton and to move some parts of it as well.
Let us start with the fun part.
I like to do this in "Wireframe" mode and I like to use all of the possible viewpoints in MS3D. That way I can put the model to the exact size and shape needed.
To get the different position click on the blue field and "Right" click to get the menu open.
Figure 09: Projection Menu in MS3D
- Go to "Group" Tab and select every group of our Leet model.
Note: Make sure "Auto Smooth" is not selected!
- Then go to "Model" panel > "Scale" and scale down the model to get the same size as the one it will replace.
Figure 10: Model > Scale Tab
Note: You can do that manually, but I prefer to use "Center Of Mass" and to specifying the values of "X", "Y" and "Z" to "0.9" then I can get back or forwards.
To scale up I can just change the values of "X", "Y" and "Z" to "1.01"
Figure 11: Model positioning in MS3D The Front position is kinda okayish now, minus the arms positions, but we will fix that shortly. You need to check the model from left and top as well.
Figure 12: Side model positioning in MS3D
- I am happy with what I see here. Let us get the hands in the right position.
The easiest way to do this is to hide the Leet groups, then go to "Model" > "Select" > "Vertex" and pick all the vertexes of the original Barney. The go and hide the selection. This will hide the vertexes, but will leave the faces.
Figure 13: Hide Selection
Now it is question of moving the vertexes of the Leet to fit the skeleton. I will leave that to you.
You should make sure that the model fits as bets as possible the skeleton. If you do not, when you compile it you will see some odd stretching of the model. Furthermore if the model you are compiling is going to be for Counter-Strike, you will have consistency errors if the model does not fit precisely the skeleton.
Figure 14: Vertex Manipulation
- Use the "Rotate" and "Move" options to place the hand correctly to match the skeleton.
You will have to also correct it from "Left" and "Right" perspective
Figure 15: Ah.. Perfection!
When you are ready and happy with the result, un-hide the barney grooups and delet them. Then export the full Leet mesh (do not override).
- You got error message when trying to export to .smd? Ah yeah... Remember when I said that there are some bones that are missing? You need to assign them to their appropriate bones. :) Go to the "Joints" tab and click on any bone. Then select "SelUnAssigned". Do you see something marked in Red? That is what you need to re-assign to bones.
Figure 16: Lit like a Christmas Tree!
Hopefully you did not see the whole model red :). As you can see in this screenshot I sort of messed up...
If you do, have no fear. All you need to do is to select vertex by vertex the red ones and assign them to the correct bones. Nothing to worry about.
16. **Few hours later...****
- Now if you go to compile your new model you will get a lot of errors regarding the policount. Basically another limit of Half-Life engine. So we need to split the model.
My advise would be to split the model in 3 parts - head, legs and body. I'm not entirely sure what is the exact limit, but around 2300 should be easily compilable.
You can check your polycount in MS3D (make sure you have select all the parts of your model) - Go to "Tools" > "SellPoliCount" - OK.. so our model is 5007... that's not going to compile in 1 piece. :)
Figure 17: A lot of plies...
OK... I have split the model in 3 parts. Let us next edit the QC and try to compile and see our resulting model.
Figure 18: Spare parts... just kidding
- Open "barney.qc" and add the lines for your new reference .smds. My advise would be to have the "legs" part first, especially if you are compiling a player model (Valve has noyt packed that cool bug as of time of writing).
Important: Something to avoid is not to have "$externaltextures". Having this defined in the .qc file will make a "T" model and those could be a trouble later on.
So here is how my QC looks like. I named the 3 parts of my leet: "leet_barney_legs", "leet_barney_body" and "leet_barney_head"
Figure 19: QC example
Note that I kept the pistol since I will need it for the Barney Leet to have one. :) I could have replaced it with USP from CSS or another gun, but got lazy.
-
Go and compile the model. Note that the .bmp textures need to be indexed... or the compiler will crash. :)
-
OK, let us look at the model in HLMV... kinda cool right!
Figure 20: Leet Barney in HLMV
- Let us check him in-game.
Figure 21: Dead Leet in-game
Figure 22: Few seconds in the past...
Note: If you do not like how the model looks like in-game or in HLMV, maybe you messed up something with the skeleton. Go back in MS3D and tweak the rigging.
I hope you enjoyed this one and you learned something.
Have fun modding.
If you don’t like something – MOD it!
Napoleon was here at some undisclosed time in 2021…