/* Currently makes upper arm, lower arm, and 5 hand bones; * joints at elbow and wrist * First bone added must be root */ void makeBones() { bones = std::vector<struct Bone *>(); struct Bone *a = new struct Bone; struct Bone *b = new struct Bone; struct Bone *c = new struct Bone; struct Bone *d = new struct Bone; struct Bone *e = new struct Bone; struct Bone *f = new struct Bone; struct Bone *g = new struct Bone; std::vector<struct Bone *> children; children.push_back(b); // upper arm makeBone(a, 0.3, 0.3, 0.0, 0.35, 0.05, 0.05, 0.0, 0.0, 0.0, 0.0, 0.0, 135.0, 20.0, -90.0, 90.0, children, RGBColor(0.5, 0.3, 0.6)); // lower arm children[0] = c; children.push_back(d); children.push_back(e); children.push_back(f); children.push_back(g); makeBone(b, 0.0, 0.0, 0.0, 0.3, 0.05, 0.05, 0.0, 0.0, 180.0, 0.0, -90.0, 90.0, 40.0, 0.0, 135.0, children, RGBColor(0.2, 0.8, 0.2)); // fingers makeBone(c, 0.0, 0.0, 0.0, 0.05, 0.005, 0.005, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, 10.0, 0.0, 20.0, std::vector<struct Bone *>(), RGBColor(0.8, 0.2, 0.2)); makeBone(d, 0.0, 0.0, 0.0, 0.05, 0.005, 0.005, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, 5.0, -5.0, 15.0, std::vector<struct Bone *>(), RGBColor(0.8, 0.2, 0.2)); makeBone(e, 0.0, 0.0, 0.0, 0.05, 0.005, 0.005, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, 0.0, -10.0, 10.0, std::vector<struct Bone *>(), RGBColor(0.8, 0.2, 0.2)); makeBone(f, 0.0, 0.0, 0.0, 0.05, 0.005, 0.005, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, -5.0, -15.0, 5.0, std::vector<struct Bone *>(), RGBColor(0.8, 0.2, 0.2)); makeBone(g, 0.0, 0.0, 0.0, 0.05, 0.005, 0.005, 0.0, 0.0, 90.0, 0.0, 0.0, 0.0, -10.0, -20.0, 0.0, std::vector<struct Bone *>(), RGBColor(0.8, 0.2, 0.2)); bones.push_back(a); bones.push_back(b); bones.push_back(c); bones.push_back(d); bones.push_back(e); bones.push_back(f); bones.push_back(g); }
TEST(BoneWeightLoader, loadMeshBoneWeights_SingleBone) { aiMesh mesh; aiVertexWeight bone1Weights[] = { {// vertex 1 .mVertexId = 1, .mWeight = 0.5}, {// vertex 2 .mVertexId = 3, .mWeight = 0.3}, {// vertex 3 .mVertexId = 0, .mWeight = 0.2}, }; aiBone* b1 = makeBone("bone1", bone1Weights, 3); aiBone* bonesStack[] = {b1}; makeMesh(mesh, 4, bonesStack, 1); // initialize the bone weight set BoneWeightLoader boneWeights; bool loaded = boneWeights.loadMeshBoneWeights(&mesh, 8); ASSERT_TRUE(loaded); // check output is valid std::vector<uint8_t> expectedBoneCounts = { 1, 1, 0, 1, };