I am trying to make an import-script for Half-Life 2 SMD files. There’s an old script from 2005 written by 3d2toy that can be found at http://www.3d2toy.com/downloader.php?ID=47, but it doesn’t work (because of the updates of the blender python API).
I have been able to:
Import the bones and create an armature.
Import the mesh (with faces).
Make a vertexgroup for EACH bone, and assign vertices to it (with the weight each vertex is deformed)But how do I get the Armature to deform the mesh? I have given the same name to each vertexgroup as the bones that shall deform it. The Armature has Vertex Groups enable under Deform Options.
When I move the bones around in pose mode, the mesh isn’t following. I have done some testing, and tried to search around in the documentation/tutorials, but haven’t found any solution.
What I need is a short explanation on how rig the mesh to the armature. (In python. I think I know how from a normal users side, it’s just been a while since I did it :p)
Thanks!
EDIT: Figured it out, partly. I had to parent the one object (mesh) to the other (armature). I haven’t done it in python, and if anybody now how to, please post here. (Meanwhile I try figure it out.)
ideasman42: it worked. I have currently been able to attach the mesh to the armature,BUT I have to save it as a .blend file and reopen it before it works.
Is there anyway I can make Blender aware of the change? (The modifier is drawn in the buttons window, and in the outliner)
@ideasman42: bpy.data.scenes.active.update(0) is enough. When using it, my_mesh_object.makeDisplayList() is not needed.
@gabdab: I haven’t released it yet. There are two reasons for that:
It’s not finished yet (TODO: resizing of model, importing texture coords, set normals correctly (I think blender does it more or less automatically), clean up the code)
Some parts of the code is just copy/past of the old script. And I don’t want to release anything I haven’t made 100%. At least I think I should have a little chat with the creator, first.
Meanwhile, I can give you some images. These are the one model called ct_urban in Counter Strike: Source. It’s skin number 1 of the 4 CT’s. The SMD format does not contain information on how long the bones should be (just the head’s position, rotation ), so they are all at same length…