Your Ad Here

Subscribe
 Post #1
 1st May 2009 Last edited by dvondrake; 5th March 2010 at 05:58PM..
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
I'm making a SourceMod with a buncha friends, and we needed a couple models. Now I don't know about you, but I don't have $3,000 lying around for 3DS Max and I don't intend on pirating it--so naturally, Blender is the best choice here. Free and relatively simple to use once you get past the UI. That's not what this is about, though. If you want to learn about how to use Blender as a beginner, this tutorial should nudge you in the right direction. I may do some "beginners" video tutorials of my own similar to the one below in the future if there is a need.

Since originally writing this tutorial, I've made my own Blender script to export to SMD files as the other ones out there either don't work at all or don't export UVs properly. Mine fixes all of that, and I've made a video tutorial to go along with it. Enjoy.

Download Plugin
Use this script for animations (And the top one if you're having root bone trouble)


idle.smd
Code:
version 1
nodes
0 "joint0" -1
end
skeleton
time 0
0 0.000000 0.000000 0.000000 0 0.000000 0.000000
end
material.vmt
Code:
"VertexLitGeneric"
{
	"$basetexture" "models/props/<materialname>"
	"$surfaceprop" "metal"
	"$model" 1
}
model.qc
Code:
$modelname		"props/<modelname>.mdl"
$body mybody	"<modelname>.smd"
$staticprop
$surfaceprop	"metal"
$cdmaterials	"models/props"
$scale			1

$sequence idle	"idle.smd" loop fps 1

$collisionmodel	"<modelname>-phy.smd" { 
	$automass
	$concave
}

$keyvalues
{
   "prop_data"
   {
       "base"  "Metal.Medium"
   }
}
run_studiomdl.bat
Code:
@"c:\program files\steam\steamapps\<username>\sourcesdk\bin\ep1\bin\studiomdl.exe" -game "c:\program files\steam\steamapps\<username>\garrysmod\garrysmod" <model>.qc
pause
To spawn your model in the console:
Code:
sv_cheats 1
prop_physics_create props/<model>.mdl
Anyway, hope you found this somewhat useful. Have fun modeling, and have fun doing it all for free!


To use animations:
Simply make your animation just as you normally would with the Action Editor.
Select the animation you want to export in there, and do a File > Export > SMD > Animation and you're done.
Just use the $sequence command in your QC file to tell Source what your animation is.


VTA Exporting
Here's a modified script by windwakr that supports VTA exporting.


Major credit to Pluss Roland for the original SMD exporter script.
 Post #2
 1st May 2009
jefflol's Avatar
August 2008
185 Posts
Well played, sir.
 Post #3
 2nd May 2009
Lord Hayden II's Avatar
April 2009
345 Posts
Very nice, I like it.
 Post #4
 2nd May 2009 Last edited by Kookas; 2nd May 2009 at 02:32PM.. (Added Q)
Kookas's Avatar
October 2006
387 Posts
Many thanks! But what is a good poly count to have as a maximum?
 Post #5
 3rd May 2009 Last edited by dvondrake; 3rd May 2009 at 04:56AM..
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
I've made my own Blender script that exports UVs properly, as none of the ones on the VDC wiki work properly. I've also remade this tutorial as a video, as well as added a lot of new content and posted my script in the OP.
Enjoy!

Many thanks! But what is a good poly count to have as a maximum?
Honestly I've never really met any limits or had any models so high-poly that they lag. Just try to make your models as low-poly as you possibly can without compromising quality, and you should be fine.
 Post #6
 8th May 2009
Gold Member
Dennab
January 2008
3,477 Posts
It looks good, thank you for this, it really helped me!
 Post #7
 9th May 2009
chill_dude's Avatar
December 2008
306 Posts
When i try to export mine says "there is no mesh selected with an attached armature" could you help please?
 Post #8
 9th May 2009
Gold Member
Dennab
January 2008
3,477 Posts
I have gotten my models in-game perfectly, without textures that is. I just seem to have a disability to be able to get textures on them.

And chill_dude, what version of Blender are you using?
 Post #9
 9th May 2009
chill_dude's Avatar
December 2008
306 Posts
the newest i think i dont know how to check it!

But im using python script 2.5.2
 Post #10
 9th May 2009
OttoGrainer's Avatar
August 2006
330 Posts
Wow, this is Awesome! Thanks a lot, friend.
 Post #11
 9th May 2009
MrSinistar's Avatar
January 2008
73 Posts
When i try to export mine says "there is no mesh selected with an attached armature" could you help please?
Add an armature in your blender scene. Next, select your model then the armature (using Shift), and hit CTRL + P to parent the armature to the model. Select armature and Don't Create Vertex Groups. Then select the model and export!
 Post #12
 10th May 2009
Gold Member
Dennab
January 2008
3,477 Posts
You don't need an armature, well at least I don't. You need to make sure to UV Map it properly though, I am expecting you have done that...
 Post #13
 10th May 2009
Gold Member
Dennab
January 2008
3,477 Posts
How do I add hands to my weapon models? Can I do this in Blender? I would really like to be able to make weapon models as well but have no idea how to add the hands in. Do I need to make my own? Is there some sort of pre-made type...?
 Post #14
 10th May 2009
Banisher's Avatar
May 2009
7 Posts
Cool!
 Post #15
 10th May 2009
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
You don't need armature for my plugin--if you don't have it, it'll automatically add one for you to the export.
You also shouldn't have to UV either, unless I've mucked up some code somewhere.

As for the hands, my guess is that you can just make your own or mod the CSS ones. I really wish there was some easy way.
 Post #16
 12th May 2009
Gold Member
Dennab
January 2008
3,477 Posts
I can get the CSS ones? How/where can I get that? They are pretty much perfect for what I need!
 Post #17
 12th May 2009 Last edited by Lord Hayden; 12th May 2009 at 09:09AM..
Gold Member
Dennab
January 2008
3,477 Posts
-snip-

Damnit these forum changes are really pissing me off, every post I make is a double one! :/
 Post #18
 14th May 2009
armopride's Avatar
April 2009
109 Posts
I think zbrush is better then blender in my opinion.
 Post #19
 14th May 2009
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
You're comparing helicopters to volcanoes here, armopride. Blender is a general multi-purpose app, as Zbrush is pretty much just for modeling. You can't animate in Zbrush, and you also can't export to SMD.
 Post #20
 14th May 2009 Last edited by Datsun; 14th May 2009 at 06:08PM..
Datsun's Avatar
January 2008
976 Posts
I am getting some errors when trying to export the model into .smd.


Plus the ignoring factor is strange because the old script I used to use did not have that.

 Post #21
 15th May 2009
Beau Phos's Avatar
December 2008
1,575 Posts
Um... how do I install the script?
 Post #22
 15th May 2009
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
I am getting some errors when trying to export the model into .smd.


Plus the ignoring factor is strange because the old script I used to use did not have that.

Did you look at the video, by any chance? It clearly says you have to join all meshes together with CTRL+J. I'm not quite sure why you're getting that error about the material index though, but it works just fine for me. You must be doing something funky (which you're already doing).


Um... how do I install the script?
Put it in your scripts folder. Usually one of the following:

Windows XP: C:\Program Files\Blender Foundation\Blender\.blender\scripts
Windows XP (alt): C:\Documents and Settings\USERNAME\Application Data\Blender Foundation\Blender\.blender\scripts
Windows Vista: C:\Users\USERNAME\AppData\Roaming\Blender Foundation\Blender\.blender\scripts
 Post #23
 15th May 2009
Beau Phos's Avatar
December 2008
1,575 Posts
How do I download it?
When I click, it is just text.
 Post #24
 15th May 2009 Last edited by Datsun; 15th May 2009 at 03:50AM..
Datsun's Avatar
January 2008
976 Posts
(which you're already doing).
I just used some modeling techniques I picked up when exporting models using Pelle Johnsen's script then exporting using the script you have. Don't assume things.

I haven't thoroughly used your script to produce results as of yet.
 Post #25
 15th May 2009
Gold Member
Dennab
January 2008
3,477 Posts
How do I download it?
When I click, it is just text.
Copy it all into a new file. Name is smdexporter.* or something. You might need Notepad++
 Post #26
 17th May 2009
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
I just used some modeling techniques I picked up when exporting models using Pelle Johnsen's script then exporting using the script you have. Don't assume things.

I haven't thoroughly used your script to produce results as of yet.
That's great, but the video says exactly what to do.
No testing needed anyhow, I know it works. (So long as you're doing everything right.)

How do I download it?
When I click, it is just text.
Do what Lord Hayden said, or just right click the link and save as.
 Post #27
 26th May 2009
exequte's Avatar
March 2009
15 Posts
Great tutorial, though i would like a tutorial on how to make a weapon.

Ps. If you intend to make those tutorials, please let me know!
 Post #28
 30th May 2009
Gold Member
Dennab
January 2008
3,477 Posts
So, are we going to be able to get some hand models any time soon? If not I might have to make a crappy set...
 Post #29
 4th June 2009
mineragua's Avatar
June 2009
5 Posts
Any chance of an SMD importer for Blender? I find a couple that work but nothing near the level of your exporter.

I'm following superaldo's tutorial (http://www.fpsbanana.com/tuts/8485), and the only importer I find that works with 2.48/9 (http://folk.uio.no/jonmd/blender/smdimport/) keeps screwing up the textures.
 Post #30
 8th June 2009
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
Great tutorial, though i would like a tutorial on how to make a weapon.

Ps. If you intend to make those tutorials, please let me know!
Thanks! I'll probably be making more tutorials on how to use Blender from a more-or-less beginner's standpoint over the summer. Nothing as specific as how to make a weapon though, I'm sure there are a lot of other tutorials out there for that already, but more about how to use the different tools and what different techniques you have at your disposal.

So, are we going to be able to get some hand models any time soon? If not I might have to make a crappy set...
I'm going to be making a hands viewmodel for my SourceMod soon, so I'll be sure to keep it nice and simple so it's easily adaptable to different skins, as well as release it here for other people to use seeing as there's a severe lack of them. :)

Any chance of an SMD importer for Blender? I find a couple that work but nothing near the level of your exporter.
Possibly in the future, but I've had no use for one as of yet. If I have some free time, sure.
 Post #31
 9th June 2009
mineragua's Avatar
June 2009
5 Posts
Possibly in the future, but I've had no use for one as of yet. If I have some free time, sure.
Here's hoping! I'm using Blender to modify some TF2 models, and a solid path back and forth between Blender and Source would be terrific.
 Post #32
 13th June 2009 Last edited by Lord Hayden; 13th June 2009 at 06:11AM..
Gold Member
Dennab
January 2008
3,477 Posts
I hope you can make some for us! I would love to have some! Also, why don't you compile models the way everyone else does? eg. with something like a reference model or something?

...Although I like the way yours exports better...

Edited:

I need a little help, I can get a model in-game, but it is textureless.

This is my QC file:

Code:
$modelname		"Lord Hayden/sacredslight.mdl"
$body mybody	"sacredslight.smd"
$staticprop
$surfaceprop	"glass"
$cdmaterials	"Models/Lord Hayden/SacredsLight"
$scale			1

$sequence idle	"idle.smd" loop fps 1

$collisionmodel	"sacredslight-phy.smd" { 
	$automass
	$concave
}

$keyvalues
{
   "prop_data"
   {
       "base"  "Metal.Medium"
   }
}
The model is called "sacredslight" by the way. All I want is the textures to be in .../ep2/materials/Lord Hayden/SacredsLight/sacredslight.vmt etc. and the models to be in .../ep2/models/Lord Hayden/SacredsLight/sacredslight.vtx etc.

What am I doing wrong?
 Post #33
 13th June 2009
Gold Member
Zyx's Avatar
February 2005
7,993 Posts
Change it to:
$cdmaterials "models/Lord_Hayden/SacredsLight"

And place the material in <Game folder>/materials/models/Lord_Hayden/SacredsLight.vtf

As I don't think source likes spaces
 Post #34
 14th June 2009
Gold Member
Dennab
January 2008
3,477 Posts
Ah, ok, i will try it again. Thank you so much, Zyx.

Edited:

Damn, it still doesn't have textures.

Could someone please give me a step by step walkthrough of how to compile model? (Not make) And maybe post a compile log I will need...?
 Post #35
 14th June 2009
Gold Member
dvondrake's Avatar
August 2006
3,791 Posts
In Blender, name the material sacredslight.vtf

Code:
$modelname		"models/lord_hayden/sacredslight.mdl"
$body mybody	"sacredslight.smd"
$staticprop
$surfaceprop	"glass"
$cdmaterials	"models/lord_hayden"
$scale			1

$sequence idle	"idle.smd" loop fps 1

$collisionmodel	"sacredslight-phy.smd" { 
	$automass
	$concave
}

$keyvalues
{
   "prop_data"
   {
       "base"  "Metal.Medium"
   }
}
Save the material as materials/models/lord_hayden/sacredslight.vtf and be sure to make the vmt as well.

(Just an FYI, the video covers this as well.)
 Post #36
 15th June 2009 Last edited by mineragua; 16th June 2009 at 02:33PM.. (My mistake!)
mineragua's Avatar
June 2009
5 Posts
Aha! I was having trouble with this too, but renaming the material in Blender fixed it.

I was still getting a mapping error in the engine though -- while most of the texture displayed fine, some parts were mapped incorrectly. I'll post some screencaps to describe what's happening when the SDK update finishes downloading.

EDIT:

Figured out the problem was I'd accidentally used an old version of the texture for an older set of UVs. Redid the correct texture in VTFEdit and the problem was fixed -- the export worked fine and now I've got a test custom model in TF2!

What's the procedure for models that have two alternating textures, like for 'RED' and 'BLU' in TF2?

Code:
$cd "D:\c_energy_drink\smd"
$modelname "weapons/c_models/c_energy_drink/c_energy_drink.mdl"
$model "c_energy_drink_reference" "c_energy_drink_reference.dmx.smd"
$cdmaterials "models\weapons\c_items\"
$texturegroup skinfamilies
{
	{ "models/weapons/c_items/c_energydrink.vmt" }
	{ "models\weapons\c_items\c_energydrink_blu.vmt" }
}
$hboxset "default"
$hbox 0 "weapon_bone" -1.983  -3.945  -1.983  1.983  3.945  1.983
// Model uses material "models/weapons/c_items/c_energydrink.vmt"
// Model uses material "models\weapons\c_items\c_energydrink_blu.vmt"
$attachment "drink_spray" "weapon_bone" 0.00 0.00 0.00 rotate 0.00 0.00 0.00
$surfaceprop "default"
$sequence idle "idle" fps 30.00
$collisionmodel "phymodel.smd" {

	$mass 3.0
	$inertia 1.00
	$damping 0.00
	$rotdamping 4.00
}
 Post #37
 18th June 2009
Gold Member
Dennab
January 2008
3,477 Posts
Do I have to open it up in Blender? I didn't do that. Whoops. I will try it a little later. Thanks.
 Post #38
 19th June 2009
Gold Member
Dennab
January 2008
3,477 Posts
As much as i try and get my material into Blender, i just can't.

I have played around with the texture/material editor for hours without being able to see an "import" button or anything. I will try and watch the video for 3rd time and see what I can get out of it.

Edited:

What the hell happened with automerge...?
 Post #39
 19th June 2009
mineragua's Avatar
June 2009
5 Posts
You don't have to open the vtf in Blender, just rename the material assigned to the model (the material, not the texture) 'sacredslight.vtf,' and export the model.

 Post #40
 19th June 2009 Last edited by Lord Hayden; 19th June 2009 at 11:45PM..
Gold Member
Dennab
January 2008
3,477 Posts
Ah, ok, thanks, I will try that now.

Edited:

Ok, i did it, but now my model is all messed up. All I can see is the inside of the model not the outside (and yes, i re-exported it after re-whatevering the normals outside)

Edited:

Oh, and it is still textureless...

This is my compile log:

Code:
GUIStudioMDL 2.2/Source - © 2007 Neil 'Jed' Jedrzejewski - http://www.wunderboy.org/

Created command line: "H:\Program Files\Steam\steamapps\mice109\sourcesdk\bin\orangebox\bin\studiomdl.exe" -game "h:\program files\steam\steamapps\mice109\half-life 2 episode two\ep2" -nop4 -nox360 "C:\Documents and Settings\Hayden\Desktop\Models\SacredsLight\sacredslight.qc"

qdir:    "c:\documents and settings\hayden\desktop\models\sacredslight\"
gamedir: "h:\program files\steam\steamapps\mice109\half-life 2 episode two\ep2\"
g_path:  "C:\Documents and Settings\Hayden\Desktop\Models\SacredsLight\sacredslight.qc"
Building binary model files...
Working on "sacredslight.qc"
SMD MODEL sacredslight.smd
SMD MODEL idle.smd
SMD MODEL sacredslight-phy.smd
Model has 1 convex sub-parts
Collision model completed.
Computed Mass: 0.00 kg
---------------------
writing h:\program files\steam\steamapps\mice109\half-life 2 episode two\ep2\models/props/Lord_Hayden/sacredslight.mdl:
bones          964 bytes (1)
animations     112 bytes (1 anims) (1 frames) [0:01]
sequences      220 bytes (1 seq) 
ik/pose        164 bytes
eyeballs         0 bytes (0 eyeballs)
flexes           0 bytes (0 flexes)
textures        72 bytes
keyvalues       56 bytes
bone transforms        0 bytes
Collision model volume 29200.58 in^3
collision        0 bytes
total         1796
---------------------
writing h:\program files\steam\steamapps\mice109\half-life 2 episode two\ep2\models/props/Lord_Hayden/sacredslight.vvd:
vertices      4416 bytes (92 vertices)
tangents      1472 bytes (92 vertices)
total         5952 bytes
---------------------
Generating optimized mesh "h:\program files\steam\steamapps\mice109\half-life 2 episode two\ep2\models/props/Lord_Hayden/sacredslight.sw.vtx":
body parts:         8 bytes
models:            20 bytes
model LODs:        12 bytes
meshes:             9 bytes
strip groups:      25 bytes
strips:            27 bytes
verts:            828 bytes
indices:          768 bytes
bone changes:      16 bytes
everything:      1737 bytes
---------------------
Generating optimized mesh "h:\program files\steam\steamapps\mice109\half-life 2 episode two\ep2\models/props/Lord_Hayden/sacredslight.dx80.vtx":
body parts:         8 bytes
models:            20 bytes
model LODs:        12 bytes
meshes:             9 bytes
strip groups:      25 bytes
strips:            27 bytes
verts:            828 bytes
indices:          768 bytes
bone changes:      16 bytes
everything:      1737 bytes
---------------------
Generating optimized mesh "h:\program files\steam\steamapps\mice109\half-life 2 episode two\ep2\models/props/Lord_Hayden/sacredslight.dx90.vtx":
body parts:         8 bytes
models:            20 bytes
model LODs:        12 bytes
meshes:             9 bytes
strip groups:      25 bytes
strips:            27 bytes
verts:            828 bytes
indices:          768 bytes
bone changes:      16 bytes
everything:      1737 bytes

Completed "sacredslight.qc"
Reply

All times are GMT. The time now is 06:16AM.

Facepunch Studios 2010 - Server 'MARGE'