Calculating Vertex Positions Based on Weights and Bones

My Godot version is 4.2.1 stable

I have been experimenting with SurfaceTool, MeshDataTool, ArrayMesh, and other procedural mesh generation stuff, these tools have some methods to add vertices, and alter the attributes of those vertices. You can also assign weights and bones to certain vertices and that’s what i’m interested in.

Basically, what i think godot does is that it renders the weight assigned mesh(skinned mesh) with an offset in vertex locations(calculated using weights and bones whiich we assigned) while keeping the actual position of vertices stationary.

There must be some sort of mathematical function or algorithm which calculates this “offset”, i searched the source code(with my helloworld.cpp level of C++ experience) to find something but, i’m really new to this engine, and game dev in general, so can please somebody help me, i’ve been looking for days

TL;DR: i want to know if there is a way to calculate rendered vertex locations from a mesh that has been assigned a skeleton, with the previous knowledge about the actual location of the vertices of the mesh, and the weights and bones assigned to those vertices.

Thank You to anybody willing to help ; __ ;

Each vertex has weights from up to 4 or 8 bones. If you have the global bone transform for each bone you can calculate how much each vertex is offset by the bone transform.

See PR Add option to bake a mesh from animated skeleton pose by smix8 · Pull Request #85018 · godotengine/godot · GitHub as example.

No, i cannot understand it, HOW do i actually do that, consider this:
vertex position: Vector3(1.5, 2.5, 3.5),
weights: PackedFloat32Array([0.25, 0.25, 0.25, 0.25]),
bones: PackedInt32Array([2, 0, 0, 0]),

so as far as i think i know, this vertex is being affected by the bone with index 2, and with given weights, now day i have this Quaternion(0.25, 0.5, 0.25, 0.5) as our bone’s rotation how do i calculate the current position of our vertex which is offseted from its original location which was Vector3(1.5, 2.5, 3.5)

I would just wait until the PR get merged.