Converting armatures to mesh objects...

I know this is easy, but how do you convert an armature to a mesh object?

Is there a convertor, that keeps the correct paranting, or does the model need to be built from scratch with a mesh armature object?

I am not exactly sure what you are asking, but if you are wishing to use bones with a mesh, the way to do that is first select the mesh, and then shift select the armature and click ctrl+p. Select armature, and name groups, then go about making all your vertex groups and stuff.

No, I need to make an armature a mesh object… I know it’s possible… because the NIF exporter requires it, and it is an option in the OGRE exporter.

You can’t do it in Blender. Maybe the exporter does it or you can convert it once in Ogre. Or maybe it needs Empties at armature joints/vertgroup joints?

because the NIF exporter requires it

I’d like to see your reference (not that I’d ever need it but for educations sake)

The guys in the GameEngine forum who use Ogre will know better though.

%<

When trying to export a model with the .nif exporter, it throws an error, and in the console, it says something to the effect of “the (armature) must be a mesh obect”

Oh well, the nif exporter is for morrowind files, and unfortunately, civilization 4 sems to use a sifferent .nif format any ways. :frowning:

Thank you for the answer.

Or maybe it needs Empties at armature joints/vertgroup joints?

Maybe… I have read in the .nif documentation something like this… but what does it mean?

I think what it’s saying is that “what you want exported must be a mesh object”. Iow, we don’t export armatures.

It probably puts an empty on the root and tip of each bone and draws an IPO for each empty based on the action IPO’s of that bone. Try selecting just the mesh and exporting (but I’m shooting in the dark here).

%<

Thanks, that was close enough to a good explanation. Regardless, the exporter I was using I found would not help me in making .nif’s for civ IV… :frowning:

YOu should try the Ogre XML exporter. YOu can get it via CVS from the Ogre repository. WHen it exports a skeleton, it exports an accompanying mesh version of the skelton, which is basically a mesh over the bones. It will be in XML format, so you’ll need to convert it to the Ogre binary format using the OgreMeshConverter tool, which you can find in the Ogre SDK.

Hey, thanks for the tip… I actuallly figured this out about 3 days ago when I accidently exported my armature instead of my model to OGRE…

…unfortunately, I was misunderstanding the problem, and I don’t need a mesh of the armature for the .nif format for civ IV, but just in case someone does one day…

I have found this python
it is from a year ago and it doesn’t work

import bpy
import math
import os

Meshname = "armature_mesh";

def convertVector(v):
    return [v.x,v.y,v.z]

def main():
    #make sure what we're going to work on is an actual armature.     
    if bpy.context.scene.objects.active.type != 'ARMATURE':
        print("Active object must be an armature!!");
        return 1;

    theArmature=bpy.context.scene.objects.active;

    #delete any previous attempts
    if bpy.data.objects.get(Meshname) is not None:
        bpy.ops.object.select_all(action='DESELECT')
        bpy.data.objects[Meshname]
        bpy.data.objects[Meshname].select = True
        bpy.ops.object.delete(use_global=False)

    #time to copy the armature to mesh
    #define our data containers for the new obj
    Verts=[]
    Edges=[]
    Faces=[]

    #select the armature and enter edit mode, and get all the bones. 
    bpy.context.scene.objects.active = theArmature
    bpy.ops.object.editmode_toggle()
    bpy.ops.armature.select_all(action='SELECT')
    bones = bpy.context.selected_bones

    #loop through the bones, putting all the coords in the data containers. 
    for bone in bones :
        Verts.append(convertVector(bone.head))
        Verts.append(convertVector(bone.tail))
        VertID = len(Verts)
        Edges.append([VertID-2,VertID-1])


    bpy.ops.object.editmode_toggle()


    #make the object and add all the data.     
    mesh=bpy.data.meshes.new(Meshname)
    mesh.from_pydata(Verts,Edges,Faces)
    newMesh=bpy.data.objects.new(Meshname,mesh)
    bpy.context.scene.objects.link(newMesh)


    #connect the connected bones by removing doubles
    bpy.context.scene.objects.active = newMesh
    bpy.ops.object.editmode_toggle()
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.mesh.remove_doubles()
    bpy.ops.object.editmode_toggle()

    bpy.ops.object.modifier_add(type='SKIN')


main();

if you get someone to code this properly

you can also use the skinify addon.

woah this post is old

It’s the thought that counts :rofl:

wow. necro thread. How appropriate, as Blender now has custom mesh shapes.
make custom bones, and you can make instaskeletons!

this is cool because i want my game to have skeleton and zombie version of anything living.
I made the zombie shader, and experimented for weeks trying to make a skeleton shader, but failed.

Now I woukd probably be best off using your script, so, Thanks!

I’m happy that trough my usage of necromancy l helped you indirectly
Make great games!

I tried to update this script for 2.92, so here it goes:

import bpy
import math
import os

Meshname = "armature_mesh";

def convertVector(v):
    return [v.x,v.y,v.z]

def main():
    #make sure what we're going to work on is an actual armature.     
    if bpy.context.active_object.type != 'ARMATURE':
        print("Active object must be an armature!!");
        return 1;

    theArmature=bpy.context.active_object;

    #delete any previous attempts
    if bpy.data.objects.get(Meshname) is not None:
        bpy.ops.object.select_all(action='DESELECT')
        bpy.data.objects[Meshname]
        bpy.ops.object.delete(use_global=False)

    #time to copy the armature to mesh
    #define our data containers for the new obj
    Verts=[]
    Edges=[]
    Faces=[]

    #select the armature and enter edit mode, and get all the bones. 
    bpy.context.view_layer.objects.active = theArmature
    bpy.ops.object.editmode_toggle()
    bpy.ops.armature.select_all(action='SELECT')
    bones = bpy.context.selected_bones

    #loop through the bones, putting all the coords in the data containers. 
    for bone in bones :
        Verts.append(convertVector(bone.head))
        Verts.append(convertVector(bone.tail))
        VertID = len(Verts)
        Edges.append([VertID-2,VertID-1])


    bpy.ops.object.editmode_toggle()


    #make the object and add all the data.     
    mesh=bpy.data.meshes.new(Meshname)
    mesh.from_pydata(Verts,Edges,Faces)
    newMesh=bpy.data.objects.new(Meshname,mesh)
    bpy.context.scene.collection.objects.link(newMesh)


    #connect the connected bones by removing doubles
    bpy.context.view_layer.objects.active = newMesh
    bpy.ops.object.editmode_toggle()
    bpy.ops.mesh.select_all(action='SELECT')
    bpy.ops.mesh.remove_doubles()
    bpy.ops.object.editmode_toggle()

    bpy.ops.object.modifier_add(type='SKIN')


main();
2 Likes

That script works. Thank you