• General Chat
  • Is there a way to get godot to import the armature as nodes?

It's a very serious problem if godot will not use the armature and it's bones as nodes. I am not very good with programming, and would hate to try and fix this problem myself. Does godot have a plan to fix this?

After looking at the source code, it looks like godot has already been programmed to use armatures and their bones as nodes. This is because of the class inheritance. I think what's needed is for the editor to use them as nodes?

After looking at the source code, it looks like godot has already been programmed to use armatures and their bones as nodes. This is because of the class inheritance. I think what's needed is for the editor to use them as nodes?

Probably. The Skeleton class has a few quirks (mainly everything is in bone space), but making an editor shouldn't be too hard.

In theory it would just be a matter of making bones for all the nodes by converting from bone space to world space, and then when the node(s) move, you just convert from world space to bone space and send the new bone position to the Skeleton.

This is what I discovered! In this source code I might be able to add the nodes, and add them to their correct parents. Problem is I don't know what to write...

Where it says set_bone_parent, I would add, set_node_parent, or add_child.

Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) {

if (p_node->type != Collada::Node::TYPE_JOINT)
	return OK;

Collada::NodeJoint *joint = static_cast<Collada::NodeJoint *>(p_node);

print_line("populating joint " + joint->name);
p_skeleton->add_bone(p_node->name);
if (p_parent >= 0)
	p_skeleton->set_bone_parent(r_bone, p_parent);

NodeMap nm;
nm.node = p_skeleton;
nm.bone = r_bone;
node_map[p_node->id] = nm;
node_name_map[p_node->name] = p_node->id;

skeleton_bone_map[p_skeleton][joint->sid] = r_bone;

if (collada.state.bone_rest_map.has(joint->sid)) {

	p_skeleton->set_bone_rest(r_bone, collada.fix_transform(collada.state.bone_rest_map[joint->sid]));
	//should map this bone to something for animation?
} else {
	print_line("no rest: " + joint->sid);
	WARN_PRINT("Joint has no rest..");
}

int id = r_bone++;
for (int i = 0; i < p_node->children.size(); i++) {

	Error err = _populate_skeleton(p_skeleton, p_node->children[i], r_bone, id);
	if (err)
		return err;
}

return OK;
}

In that source code

I ran into a problem, Please see the following error.

class Skeleton : public Spatial {

GDCLASS(Skeleton, Spatial);

struct Bone {

	String name;

	bool enabled;
	int parent;

	bool disable_rest;
	Transform rest;
	Transform rest_global_inverse;

	Transform pose;
	Transform pose_global;

	bool custom_pose_enable;
	Transform custom_pose;

	Transform transform_final;

	List<uint32_t> nodes_bound;

	Bone() {
		parent = -1;
		enabled = true;
		custom_pose_enable = false;
		disable_rest = false;
	}
};
.....

Because the bones are defined as struct under the skeleton class, I cannot fix godot to use the bones of the armature as nodes. This design makes godot weaker than it's competition. Is there some how to get the developers to fix it?

Found a way around one problem this causes. An empty node can be added to the armature bone in blender before importing into godot. This will allow the creation of mount points on the armature. All animations will have to be done in blender. I can't find a way to script the bone, except to maybe control it from the base node.

Does godot import colliders from blender?

I still think Godot is the best 2d 3d game engine I have found, even though it has this one flaw.

Because the bones are defined as struct under the skeleton class, I cannot fix godot to use the bones of the armature as nodes.

You can, it just takes some work. I've done something similar using GDScript when I made my IK plugin, so I know it's possible. Look at the LookAt_IK node. Instead of making the transform look at the target in world space, you'd instead convert the bone transform to world space, and then apply that position to a node. Then you can send the node position back by converting the node's transform to bone space, and then setting that as the position of the bone.

(In theory, I haven't tested it. It shouldn't be too hard though, because at one point I remade the BoneAttachment node, which is basically half of the work needed to make the bones follow nodes)

The IK plugin hopefully can provide a base to convert the bones in Skeleton to nodes. The big thing to remember when working with Skeleton nodes is to be using the proper space (world space, bone space, etc) when doing calculations.

Is there some how to get the developers to fix it?

You can open a issue on the Godot engine GitHub repository.

Does godot import colliders from blender?

I think meshes with the -col tag will be converted by Godot import. See this page from the documentation. :smile:

Yes that certainly is the solution to this problem. I will see if I can get that plugin.