• 2D
  • assigning weights to bone2d on polygon2d

Yeah, I find the documentation to be generally pretty good, but for stuff like this they need to update the information (such as valid ranges for the parameters, what order or format it is expecting, what is the size of the array, etc.). It may be the vertices of the whole mesh, this would make sense, but you'd have to look into what order it is expected to be in.

Based on this code, I think the weights are per vertex and need to be an array of the same length as all the vertices. I could be wrong though, but I think that is what the code is looking for.

@TwistedTwigleg said: Based on this code, I think the weights are per vertex and need to be an array of the same length as all the vertices. I could be wrong though, but I think that is what the code is looking for.

Yeh I ended up groveling through the same source for the polygon2d editor. I had experimented with a single polygon2d being governed by several bones but a single polygon means then that each bone must list all the vertices. Flexing them with animation causes one point to oddly stretch. It's headache to debug with programatic assignment.

I now generate 1 polygon2d per bone2d, yet under bone rotation the polygons become translated in -x_axis by different amounts.

I added x and y axis line 2d on the bones themselves and all their transforms are correct, so i know its something to do with the bone governance of the poly.. fixed by setting poly global_transform to the bone's

@dotted said:

@TwistedTwigleg said: Based on this code, I think the weights are per vertex and need to be an array of the same length as all the vertices. I could be wrong though, but I think that is what the code is looking for.

Yeh I ended up groveling through the same source for the polygon2d editor. I had experimented with a single polygon2d being governed by several bones but a single polygon means then that each bone must list all the vertices. Flexing them with animation causes one point to oddly stretch. It's headache to debug with programatic assignment.

I now generate 1 polygon2d per bone2d, yet under bone rotation the polygons become translated in -x_axis by different amounts.

I added x and y axis line 2d on the bones themselves and all their transforms are correct, so i know its something to do with the bone governance of the poly.. fixed by setting poly global_transform to the bone's

Hmm, strange. I can totally see how it would be difficult though, as even looking just for the little bit of source code I linked took longer than I expected. The Polygon2D editor in the Godot source code probably is the best source of a working example, though when I looked through briefly, it looked complicated.

I'm not sure if 2D polygons and bones do this, but maybe the skewing and other issues have something to do with the rest pose? I know in 3D skeletons there are can interesting issues if the transform used for the rest gets out of alignment with the rest pose or if the basis is scaled non-uniformly.

@TwistedTwigleg I set the polygon to have the same transform as the armature just before setting the bone on the polygon:

	fiber.rest                      = fiber.transform
	fiber.apply_rest()
	p.global_transform = fiber.global_transform
	p.add_bone(fiber .get_path(), nW)

at least now and the above steps assures alignment of the polygon and bone before add_bone(), but the aggregate polygon I had before, the observed behavior looked like the weight for on point on each bone wasn't tracking. During animation one point on the polygon got dragged out. There could be a few different ways I think that could happen, but hassle and annoyance AND

The armature animation will have bones folded on itself (imagine a Z squashed flat at some point in an animation) and this leads to twisting any polygon at the bendy bits. Discrete polygons are needed.