A cry for help! Blender API

Started by
1 comment, last by CodaKiller 15 years, 3 months ago
I get a list of bones then I run through the vertices and get the influences for each vertex. I then create a list limited to 4 weights and 4 indices, when I get the bone name for an influence I check to see if the name of that bone matches one in my list and thats where I get the index. Now this is where my problem happens, for some reason the bone data makes no sense... For instance when I have one bone for the mesh I would figure that the bone indices would look like this [ 0,0,0,0 ] and the bone weights would look like this [ 1,0,0,0 ] but I get kinda random weights and indices like the weights would be something like this [ 0.71, 0.39, 0, 0 ] even though there is only one bone connected to the mesh. Here is the code I use to get the bone index and weight lists:

	for vert in mesh.verts:
		influences = mesh.getVertexInfluences(vert.index)
		weights = []
		indices = []
		for influence in influences:
			if len(weights) < 4:
				weights.append(influence[1])
			if len(indices) < 4:
				for n in range(len(bones)):
					if bones[n].name == influence[0]:
						indices.append(n)
		for n in range(4-len(weights)):
			weights.append(0)
		for n in range(4-len(indices)):
			indices.append(0)
		bone_weights.append( weights )
		bone_indices.append( indices )


So I believe there is something I'm doing wrong whether its in the way I create the mesh or the way I export the data, I'm not sure. To do the skinning in blender I just created a armature, set it as the parent of my mesh and clicked Create From Bone Heat which seems to work correctly in blender but the data I get from my script makes no sense at all. [Edited by - CodaKiller on January 11, 2009 10:43:10 AM]
Remember Codeka is my alternate account, just remember that!
Advertisement
When I create a basic cube with a armature it export the data as expected but when I export my human model it exports random values that make no sense. Could there be some type of data left over from something I did while modeling it?
Remember Codeka is my alternate account, just remember that!
Why are some of the weights over 1 and how can I fix it? Should I normalize the 4 weights?

Also it seems to work on the default models such as cube and sphere but any of the models that I made seem to have random weights.


Remember Codeka is my alternate account, just remember that!

This topic is closed to new replies.

Advertisement