Making a simple ViewModel using 3ds Max '10

I’m not good at tutorials, but lots of people need help with this.
First of all I’d like to tell you how view models work so you can realize how easy it is. Then I’ll tell you how I make view models and some tips on it.
If you have information to add please post it.

[release]ABOUT VIEW MODELS
As read here, a view model is just an animated prop.
That’s it,
there’s no special bones or collision models, hell the only thing you need to know is how to include animations into a QC.

There is several animations that need to be made for a view model to look nice, but truthfully you don’t need any animations.
This activity list is what the engine uses to call animations in a viewmodel.[sp]Obviously not a complete list[/sp]
[ul][li]ACT_VM_PRIMARYFIRE[/li][li]ACT_VM_SECONDARYFIRE[/li][li]ACT_VM_DRAW[/li][li]ACT_VM_HOLSTER[/li][li]ACT_VM_RELOAD[/li][li]ACT_VM_IDLE[/li][li]ACT_VM_DRYFIRE[/ul][/li]Assigning animations to these activity’s will cause your weapon to come to life in the source engine.[/release]

[release]MAKING A SIMPLE VIEWMODEL AND PUTTING IT INTO GARRYSMOD
As you read below, I expect you to know simple compiling skills.
I also expect your steam to be installed in C:\Steam.

WHAT IS COVERED:
[ul][li]How to decompile[/li][li]How to import and smooth smd’s (And keep skin data)[/li][li]How to apply a texture[/li][li]How to animate and export .smd’s[/li][li]How to fix improperly placed viewmodels[/ul][/li]
WHAT YOU NEED:
[ul][li]GCFscape by Nem[/li][li]Ironsights Designer by Devenger[/li][li]MDLdecompiler by Cannonfodder[/li][li]3ds Max smd importer and exporter by WunderBoy[/li][li]Counter-Strike: Source[/ul][/li]

STARTING OUT
1) You need a hand rig. Open up GCFscape, and press file->open. Browse to *C:\Steam\steamapps* and double click on counter-strike source shared.gcf.

http://www.1337upload.net/files/2010-08-25_14.53.34.png

Browse to cstrike\models\weapons* within the .gcf and export all the files that start with v_knife_t. to your desktop.

http://www.1337upload.net/files/2010-08-25_15.02.30.png

2) Now that you have your model, you need to decompile the hand rig from it! Place your MDLdecompiler.exe in C:\Steam\steamapps\lolname\sourcesdk\bin\ep1\bin, Then open it up.
Decompile v_knife_t.mdl to a location of your choice.

http://www.1337upload.net/files/2010-08-25_15.06.24.png

Make sure all of the boxes are UNCHECKED they just break the decompile for me.

3) You now should have a bunch of workable files, open up 3ds Max and go to file->import. Import the hands_reference.smd.

http://www.1337upload.net/files/2010-08-25_15.11.28.png

During import, it will ask you if you want to “Skip mesh” or “Skip animation”, make sure they are both deselected.
Then on the next menu, deselect Rebuild smoothing normals. This will just cause fake smoothing and confusion for you.

http://www.1337upload.net/files/2010-08-25_15.12.56.png

Press OK and let it import.

4) You’ll see that your hands are now on screen with a bunch of bones, but the hands are very blocky.
Select the hands, then in the upper right, click Editable Mesh.
Press 4 on your keyboard, and select all the polygons on the arms. Then scroll down in the Editable Mesh modifier panel till you see Smoothing Groups.
Click on the Auto Smooth button.
Then press 6 to deselect the arm. (Important) (Sometimes 6 opens a particle editor, if that happens just go in the Editable Mesh modifyer and click the red square at the top to deselect it.)

http://www.1337upload.net/files/2010-08-25_15.18.45.png

[sp]I’d save this somewhere right about now so you can use it again[/sp]

5) Time to start making the animations. First we will start out with the ACT_VM_IDLE animation.
At the bottom of 3ds Max, make sure the animation slider is to the left (or on the first frame). And that your AutoKey button is pressed.
Rightclick on the arms and press Freeze Selected.
Then pose the the model till it’s in an idle position!

http://www.1337upload.net/files/2010-08-25_15.28.21.png

6) Now that your model’s all posed up, Select all your bones and click Animation->Set as Skin Pose. This will let us set it back to this point again.
Move the animation slider to about frame 15, and move your weapon a bit to look like it has just been shot.
Then go to frame 30, select all your bones and press Animation->Assume Skin Pose.
If you move the slider back and forth you should see your model playing a shoot animation!
This will get our ACT_VM_PRIMARYATTACK animation out of the way too.

http://www.1337upload.net/files/2010-08-25_15.35.48.png

7) Time for texturing. Now that all your animations and rigs are set up, you need to texture your arm so it will export correctly.
I have supplyed the bare .tga of the hand texture here.
Download it and place it on your desktop.
Press M in 3ds max and select a blank sphere. Press Maps->Defuse color (None)->Bitmap and browse to the v_hands.tga.

http://www.1337upload.net/files/2010-08-25_15.41.30.png

Right-click somewhere on your scene and press Unfreeze all. Then drag and drop your textured sphere onto your hands.
It won’t show up in the viewport unless you press this button in the Material Editor.

http://www.1337upload.net/files/2010-08-25_15.43.15.png

http://www.1337upload.net/files/2010-08-25_15.44.11.png

8) Your model is completely ready to be compiled! Go to file->export and save with these names and options:
[ul][li]ref.smd[/li][img_thumb]http://www.1337upload.net/files/2010-08-25_15.50.45.png[/img_thumb]
[li]idle.smd[/li][img_thumb]http://www.1337upload.net/files/2010-08-25_15.51.58.png[/img_thumb]
[li]shoot.smd[/li][img_thumb]http://www.1337upload.net/files/2010-08-25_15.53.01.png[/img_thumb][/ul]

9) Now you need a QC. Make one where you exported all your smd’s. Then put this in it:


$modelname "mymodel\handgun.mdl" 
$cdmaterials "models\mymodel" "models\weapons\v_models\hands" 

$body studio "ref.smd"

$origin 0 0 0

$sequence idle "idle.smd" loop ACT_VM_IDLE 1 fps 30.00
$sequence fire "shoot.smd" ACT_VM_PRIMARYATTACK 1 fps 30.00

I will explain the QC after the tutorial.
Compile using your own methods and you’re nearly done!

10) Put your model into your garrysmod and load up a singleplayer game with the Ironsight Designer.
Press Q and click the Browse tab. Find your model, Rightclick on it and press Copy to Clipboard.

http://www.1337upload.net/files/2010-08-25_16.14.45.png

Go to the weapons tab and give yourself the Ironsight Designer. Press shift and paste your weapon model directory into the Model: box.
Then press Set, You’ll see the model is ‘flipped’, toggle the Model flip

http://www.1337upload.net/files/2010-08-25_16.17.08.jpg

11) You’ll see that your model looks like this:
[img_thumb]http://www.1337upload.net/files/2010-08-25_16.18.51.jpg[/img_thumb]
Changing position of the model using Leftclick you can position it the way you want it. (Notice: You shouldn’t change pitch or roll)
[img_thumb]http://www.1337upload.net/files/2010-08-25_16.24.46.jpg[/img_thumb]
After you’re done press USE and copy the first line that was printed in console.


SWEP.IronSightsPos = Vector (-1.7981, 1.2534, -4.4532)

All you need is the last three numbers.


-1.7981 1.2534 -4.4532

But the last number needs to be negated (because the designer’s is backwards). So your final number combo would look like this:


-1.7981 1.2534 4.4532

12) With your new number combo, open back up your QC. Edit the


$origin 0 0 0

to read your number combo


$origin -1.7981 1.2534 4.4532

(You can also put a Yaw value after the position vector, read more here.)

13) Re-Compile and you are


DONE

. You have a perfectly functioning model that’s lacking some animations![/release]

After some extensive research I figured out how some events work.

[release]ADDING EVENTS TO YOUR VIEWMODEL
These handy little things called events can add lots of functionality to your weapon. This won’t be much of a tutorial, just some documentation.

Events are flags that are put into a frame of an animation that tells the Engine to do something.
They are integrated into a $sequence, on a QC.

Here are the events I will cover:
[ul][li]AE_MUZZLEFLASH[/li][li]AE_CL_PLAYSOUND[/li][li]6001[/ul][/li][release][tab]AE_MUZZLEFLASH:[/tab]
This event creates a “flash” on an $attachment when it is called.
This event requires an $attachment named “muzzle”.
This event takes two parameters, frame number, and flash type.
frame number is when to show the muzzleflash during the animation.
flash type is basically the flash color and size.

Flash types:
[ul][li]AR2 MUZZLE[/li][li]SHOTGUN MUZZLE[/li][li]SMG1 MUZZLE[/li][li]SMG2 MUZZLE[/li][li]PISTOL MUZZLE[/li][li]COMBINE MUZZLE[/li][li]357 MUZZLE[/li][li]RPG MUZZLE[/ul][/li]
Final Code:
{ event AE_MUZZLEFLASH 0 “PISTOL MUZZLE” }[/release]
[release][tab]6001:[/tab]
This event causes a client-side ‘shell’ to eject from an $attachment.
This event requires an $attachment named “1”(?).
This event takes two parameters, frame number and shell type
frame number is when to eject a clientside shell.
shell type is what kind of shell to eject.

Shell types:
[ul][li]0 = pistol[/li][li]1 = rifle[/li][li]2 = shotgun[/ul][/li]
Final Code:
{ event 6001 0 “0” }[/release]

[release][tab]AE_CL_PLAYSOUND:[/tab]
This event causes a sound to be played, when used in viewmodels, other people will not hear the sounds.
This event requires to have a SoundScript to go with it.
This event takes two parameters, frame number and a SoundScript entry name.

This event is typically used in reload animations.

Final Code:
{ event AE_CL_PLAYSOUND 0 “finger.reload” }[/release]
Example usage (Using the above tutorial’s QC with an added reload animation):


$modelname "mymodel\handgun.mdl" 
$cdmaterials "models\mymodel" "models\weapons\v_models\hands" 

$body studio "ref.smd"

$origin -1.7981 0 4.4532

$attachment "muzzle" "v_weapon.Right_Index03" 0 0 0 //Where the muzzle 'flashes'
$attachment 1 "v_weapon.Right_Index03" 0 0 0 rotate 0 90 0 //Where brass is ejected

$sequence idle "idle.smd" loop ACT_VM_IDLE 1 fps 30.00
$sequence fire "shoot.smd" ACT_VM_PRIMARYATTACK 1 fps 60.00 {
	{ event AE_MUZZLEFLASH 0 "PISTOL MUZZLE" }
	{ event 6001 0 "0" }
}
$sequence reload "reload.smd" ACT_VM_RELOAD 1 fps 30.00 {
	{ event AE_CL_PLAYSOUND 0 "finger.unload" }
	{ event AE_CL_PLAYSOUND 10 "finger.reload" }
}

With the soundscript (mysound.txt):


finger.unload
{
	volume		VOL_NORM
	pitch		PITCH_NORM
	soundlevel	SNDLVL_NORM
	wave		weapons\fingerunload.wav
}
finger.reload
{
	volume		VOL_NORM
	pitch		PITCH_NORM
	soundlevel	SNDLVL_NORM
	wave		weapons\fingerload.wav
}

placed in garrysmod\scripts\sounds.

Final Product: [img_thumb]http://www.1337upload.net/files/2010-08-26_18.06.36.jpg[/img_thumb][/release]

I appreciate post, so please do.

Looks like a good tutorial so far.

I’ll be adding some .qc tips later, involving events. But i’m a tad busy right now so i can’t.

Subscribed, and added to my favorites!

Nice tutorial :razz:

I see you’ve made the tutorial :smiley:

That origin method is genius. I’ll have to use that.

I added some event documentation, hopefully more understandable than the valve wiki’s.

I will soon add a tutorial on how to make world models.

Thank you for this useful guide.
The above user linked me to it

Edit: My fucking god I just realised this is a tutorial

When i move the bones, the rest of the mesh isn’t moving, is there anything i do wron?

Using 3ds Max 2014 with Wall Worm

I had that proplem too. I unchecked all boxes except for one in the SMD Importer. also 3 Year old Thread.

Yea i know, but there’s is no up-to-date Tutorial at all. (That stuff is pretty undocumented…)

Did you use Wall Worm?