Half-Life 2 SMD Importer (my first version)

Hi!

There was already an import script for Blender for SMD files, but that one does not work anymore, because of updates in the Blender Python API. First I rewrote that script to match the new Blender Python API. But I didn’t quite understand the entire script, so I simply wrote my own, new script from scratch.

My script does pretty much exactly the same as the old one did, but for a change, it only works with Blender 2.44 or higher (only tested in 2.44). The script imports the mesh, and the bones (armature) from the SMD file, rigs the mesh using vertex groups and adds textures. To import textures, you need the to have all the images in the same directory as the SMD. To find out what textures you need, I have made a small script that scans through the SMD file and prints the name of those images.

I would like to thank ideasman42 for helping me with the Blender Python API. I don’t know the Blender Python API too well, and he helped me when I got stuck.

For more information about the script, read the README files in the ZIP archive.DOWNLOAD PAGE
Examples of the well-known character Alyx from Half-Life 2:

http://folk.uio.no/jonmd/blender/smdimport/alyx_wire.jpghttp://folk.uio.no/jonmd/blender/smdimport/alyx_wire2.jpg

You need to have a copy of Half-Life 2 / Counter-Strike:Source to extract the models. I might write a tutorial on how to do that some other time, if people want to know how. (That guide would not be Blender-related, and for Windows users only.)

/JMD

Are there any plans for HL2 SMD exporter? Exporting to SMD would be very handy :wink:
I wonder if Doom3 md5 exporter can be taken as foundation and transformed into HL2 SMD exporter?

motorsep: yes there is a HL2 SMD exporter (not written by me). It can be found at http://forum.moddb.com/thread/13334/. That script is very recently updated (about a month ago), and fully functional (even with support for exporting animations). It has one weakness, though: Every vertex in the mesh you export MUST be attached to at least one bone! This means that even for “static” (non-moving) objects, you need to make a rig. Other than that, it works very good!

Thanks JMD, I have been looking forward to see that script exporting animation :slight_smile:

JMD: fantastic work, thank you very much!
I’d like to ask though: do you have plans of adding animation also? If so - this script could open Blender for making mods for Source engine. Sweet.
Thank you for any answer!

Hi,

I tried to add animation import into the script. But i still have no clue how to get quaternion from bone’s tail and head (it seems i can’t use method toTrackQuat(track, up) in this case, am I?). Could someone help me to finish this script? I would be much obliged…
Oh, and right now to import animation you have to use initial script from JMD to import reference model, then use this script to import action into existing model.

Here is link to the file:
import_smd_animation.py

Thanks anyone for any reply

well it’s great:yes: but how can i use it(the steps please)thx

This is probabley a stupid question but ive installed the script and cant find any SMD files, could someone please tell me where to look ( i was looking around in the steam folder)

You won’t find any smd’s just floating around. As far as I know, you have to extract .mdl’s from the .gcf files, then decompile them into .smd’s. I think…not really sure lol.

not working for me, I have Blender version 2.48a and Python 2.52-30

there is no script subfolder so I created one, didn’t help…

Yearh, I had the same problem. Checkthis thread. The .blend has been relocated. :confused:

Thanks, going to give this a try.

I tried this script with .smd models exported from GTA IV models with Spark IV. Works good. :slight_smile:

Thanks.

First, thanks JMD for the wonderful script. I pulled out some characters out of Team Fortress 2 and got them into Blender with the script and the whole nine yards. Now here comes the newb question.

When I import static mesh with textures the model loads just fine. I change the draw type to textured and the skin looks perfect. Now here is the problem when I render the texture does not show up on the model. Also, it does not look like a material has been created. If I save, exit and return, the texture will be gone. Has anyone else done this? Am I missing a step, I am sure it is something obvious.

Many thanks.
Jim

Never mind … got it. Went in to the outliner. Made the material local … assigned it and good to go.

Here is an extension to import animations
http://lsa-svn.svn.sourceforge.net/viewvc/lsa-svn/trunk/characters/SMD%20importer.rar