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][b]ABOUT VIEW MODELS[/b]
As read [url=http://developer.valvesoftware.com/wiki/View_Models]here[/url], 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 [url=http://developer.valvesoftware.com/wiki/Activity]activity[/url] list is what the engine uses to call animations in a viewmodel.[sp]Obviously not a complete list[/sp]
[list][*]ACT_VM_PRIMARYFIRE
[*]ACT_VM_SECONDARYFIRE
[*]ACT_VM_DRAW
[*]ACT_VM_HOLSTER
[*]ACT_VM_RELOAD
[*]ACT_VM_IDLE
[*]ACT_VM_DRYFIRE[/list]
Assigning animations to these activity's will cause your weapon to come to life in the source engine.[/release]
[release][b]MAKING A SIMPLE VIEWMODEL AND PUTTING IT INTO GARRYSMOD[/b]
As you read below, I expect you to know simple compiling skills.
I also expect your steam to be installed in C:\Steam.
[b]WHAT IS COVERED:[/b]
[list][*]How to decompile
[*]How to import and smooth smd's (And keep skin data)
[*]How to apply a texture
[*]How to animate and export .smd's
[*]How to fix improperly placed viewmodels[/list]
[b]WHAT YOU NEED:[/b]
[list][*][url=http://nemesis.thewavelength.net/index.php?p=26]GCFscape by Nem[/url]
[*][url=http://www.facepunch.com/showpost.php?p=8791804&postcount=1]Ironsights Designer by Devenger[/url]
[*][url=http://www.chaosincarnate.net/cannonfodder/cftools.htm]MDLdecompiler by Cannonfodder[/url]
[*][url=http://www.wunderboy.org/3dapps.php]3ds Max smd importer and exporter by WunderBoy[/url]
[*]Counter-Strike: Source[/list]
[b]STARTING OUT[/b]
[b]1)[/b] You need a hand rig. Open up [i]GCFscape[/i], and press [b]file->open[/b]. Browse to [b]C:\Steam\steamapps\[/b] and double click on [b]counter-strike source shared.gcf[/b].
[img]http://www.1337upload.net/files/2010-08-25_14.53.34.png[/img]
Browse to [b]cstrike\models\weapons\[/b] within the .gcf and export all the files that start with [b]v_knife_t.*[/b] to your desktop.
[img]http://www.1337upload.net/files/2010-08-25_15.02.30.png[/img]
[b]2)[/b] Now that you have your model, you need to decompile the hand rig from it! Place your [i]MDLdecompiler.exe[/i] in [b]C:\Steam\steamapps\lolname\sourcesdk\bin\ep1\bin[/b], Then open it up.
Decompile [b]v_knife_t.mdl[/b] to a location of your choice.
[img]http://www.1337upload.net/files/2010-08-25_15.06.24.png[/img]
Make sure all of the boxes are [b]UNCHECKED[/b] they just break the decompile for me.
[b]3)[/b] You now should have a bunch of workable files, open up [i]3ds Max[/i] and go to [b]file->import[/b]. Import the hands_reference.smd.
[img]http://www.1337upload.net/files/2010-08-25_15.11.28.png[/img]
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 [b]Rebuild smoothing normals[/b]. This will just cause fake smoothing and confusion for you.
[img]http://www.1337upload.net/files/2010-08-25_15.12.56.png[/img]
Press [b]OK[/b] and let it import.
[b]4)[/b] 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 [b]Editable Mesh[/b].
Press [b]4[/b] on your keyboard, and select all the polygons on the arms. Then scroll down in the [b]Editable Mesh[/b] modifier panel till you see [b]Smoothing Groups[/b].
Click on the [b]Auto Smooth[/b] button.
Then press [b]6[/b] to deselect the arm. (Important) (Sometimes 6 opens a particle editor, if that happens just go in the [b]Editable Mesh[/b] modifyer and click the red square at the top to deselect it.)
[img]http://www.1337upload.net/files/2010-08-25_15.18.45.png[/img]
[sp]I'd save this somewhere right about now so you can use it again[/sp]
[b]5)[/b] Time to start making the animations. First we will start out with the [b]ACT_VM_IDLE[/b] animation.
At the bottom of 3ds Max, make sure the animation slider is to the left (or on the first frame). And that your [b]AutoKey[/b] button is pressed.
Rightclick on the arms and press [b]Freeze Selected[/b].
Then pose the the model till it's in an idle position!
[img]http://www.1337upload.net/files/2010-08-25_15.28.21.png[/img]
[b]6)[/b] Now that your model's all posed up, Select all your bones and click [b]Animation->Set as Skin Pose[/b]. 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 [b]Animation->Assume Skin Pose[/b].
If you move the slider back and forth you should see your model playing a shoot animation!
This will get our [b]ACT_VM_PRIMARYATTACK[/b] animation out of the way too.
[img]http://www.1337upload.net/files/2010-08-25_15.35.48.png[/img]
[b]7)[/b] 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 [url=http://www.1337upload.net/files/v_hands.tga]here.[/url]
Download it and place it on your desktop.
Press [b]M[/b] in 3ds max and select a blank sphere. Press [b]Maps->Defuse color (None)->Bitmap[/b] and browse to the [b]v_hands.tga[/b].
[img]http://www.1337upload.net/files/2010-08-25_15.41.30.png[/img]
Right-click somewhere on your scene and press [b]Unfreeze all[/b]. 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 [b]Material Editor[/b].[img]http://www.1337upload.net/files/2010-08-25_15.43.15.png[/img]
[img]http://www.1337upload.net/files/2010-08-25_15.44.11.png[/img]
[b]8)[/b] Your model is completely ready to be compiled! Go to [b]file->export[/b] and save with these names and options:
[list][*][b]ref.smd[/b]
[img_thumb]http://www.1337upload.net/files/2010-08-25_15.50.45.png[/img_thumb]
[*][b]idle.smd[/b]
[img_thumb]http://www.1337upload.net/files/2010-08-25_15.51.58.png[/img_thumb]
[*][b]shoot.smd[/b]
[img_thumb]http://www.1337upload.net/files/2010-08-25_15.53.01.png[/img_thumb][/list]
[b]9)[/b] Now you need a [b]QC[/b]. Make one where you exported all your smd's. Then put this in it:
[code]$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[/code]
I will explain the [b]QC[/b] after the tutorial.
Compile using your own methods and you're nearly done!
[b]10)[/b] Put your model into your garrysmod and load up a singleplayer game with the [b]Ironsight Designer[/b].
Press [b]Q[/b] and click the [b]Browse[/b] tab. Find your model, Rightclick on it and press [b]Copy to Clipboard[/b].
[img]http://www.1337upload.net/files/2010-08-25_16.14.45.png[/img]
Go to the weapons tab and give yourself the [b]Ironsight Designer[/b]. Press shift and paste your weapon model directory into the [b]Model:[/b] box.
Then press [b]Set[/b], You'll see the model is 'flipped', toggle the [b]Model flip[/b]
[img]http://www.1337upload.net/files/2010-08-25_16.17.08.jpg[/img]
[b]11)[/b] 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 [b]USE[/b] and copy the first line that was printed in console.
[code]SWEP.IronSightsPos = Vector (-1.7981, 1.2534, -4.4532)[/code]
All you need is the last three numbers.
[code]-1.7981 1.2534 -4.4532[/code]
But the last number needs to be negated (because the designer's is backwards). So your final number combo would look like this:
[code]-1.7981 1.2534 4.4532[/code]
[b]12)[/b] With your new number combo, open back up your [b]QC[/b]. Edit the
[code]$origin 0 0 0[/code]
to read your number combo
[code]$origin -1.7981 1.2534 4.4532[/code]
(You can also put a [b]Yaw[/b] value after the position vector, read more [url=http://developer.valvesoftware.com/wiki/$origin]here[/url].)
[b]13)[/b] Re-Compile and you are [highlight]DONE[/highlight]. You have a perfectly functioning model that's lacking some animations![/release]
After some extensive research I figured out how some events work.
[release][b]ADDING EVENTS TO YOUR VIEWMODEL[/b]
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 [url=http://developer.valvesoftware.com/wiki/$sequence]$sequence[/url], on a [b]QC[/b].
Here are the events I will cover:
[list][*]AE_MUZZLEFLASH
[*]AE_CL_PLAYSOUND
[*]6001[/list]
[release][tab]AE_MUZZLEFLASH:[/tab]
This event creates a "flash" on an [url=http://developer.valvesoftware.com/wiki/$attachment]$attachment[/url] when it is called.
This event requires an [url=http://developer.valvesoftware.com/wiki/$attachment]$attachment[/url] named "muzzle".
This event takes two parameters, [B]frame number[/B], and [u]flash type[/u].
[B]frame number[/b] is when to show the muzzleflash during the animation.
[u]flash type[/u] is basically the flash color and size.
Flash types:
[list][*]AR2 MUZZLE
[*]SHOTGUN MUZZLE
[*]SMG1 MUZZLE
[*]SMG2 MUZZLE
[*]PISTOL MUZZLE
[*]COMBINE MUZZLE
[*]357 MUZZLE
[*]RPG MUZZLE[/list]
Final Code:
{ event AE_MUZZLEFLASH [b]0[/b] [u]"PISTOL MUZZLE"[/u] }[/release]
[release][tab]6001:[/tab]
This event causes a client-side 'shell' to eject from an [url=http://developer.valvesoftware.com/wiki/$attachment]$attachment[/url].
This event requires an [url=http://developer.valvesoftware.com/wiki/$attachment]$attachment[/url] named "1"(?).
This event takes two parameters, [B]frame number[/b] and [u]shell type[/u]
[B]frame number[/b] is when to eject a clientside shell.
[u]shell type[/u] is what kind of shell to eject.
Shell types:
[list][*]0 = pistol
[*]1 = rifle
[*]2 = shotgun[/list]
Final Code:
{ event 6001 [b]0[/b] [u]"0"[/u] }[/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 [url=http://developer.valvesoftware.com/wiki/Soundscripts]SoundScript[/url] to go with it.
This event takes two parameters, [B]frame number[/b] and a [u]SoundScript entry name[/u].
This event is typically used in reload animations.
Final Code:
{ event AE_CL_PLAYSOUND [b]0[/b] [u]"finger.reload"[/u] }[/release]
Example usage (Using the above tutorial's [b]QC[/b] with an added reload animation):
[code]$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" }
}[/code]
With the soundscript (mysound.txt):
[code]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
}[/code]
placed in [b]garrysmod\scripts\sounds[/b].
[B]Final Product: [img_thumb]http://www.1337upload.net/files/2010-08-26_18.06.36.jpg[/img_thumb][/B][/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 :D
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
[QUOTE=johnnyaka;43356471]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[/QUOTE]
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?
Sorry, you need to Log In to post a reply to this thread.