-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbone.h
32 lines (26 loc) · 883 Bytes
/
bone.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include "mgs/model/kmd/kmd.h"
#include "noesis/plugin/pluginshare.h"
inline
void worldToParent(modelBone_t* bone) {
RichMat43 currentMat(bone->mat);
RichMat43 parentMat(bone->eData.parent->mat);
bone->mat = (currentMat * parentMat).m;
}
inline
modelBone_t* bindKMDBones(KmdMesh* mesh, int numBones, noeRAPI_t* rapi) {
modelBone_t* noeBones = rapi->Noesis_AllocBones(numBones);
for (int i = 0; i < numBones; i++) {
float x = mesh[i].pos.x;
float y = mesh[i].pos.y;
float z = mesh[i].pos.z;
RichVec3 bonePosV3 = { x, y, z };
memcpy_s(&noeBones[i].mat.o, 12, &bonePosV3, 12);
if (mesh[i].parent > -1) {
noeBones[i].eData.parent = &noeBones[mesh[i].parent];
worldToParent(&noeBones[i]);
}
}
rapi->rpgSetExData_Bones(noeBones, numBones);
return noeBones;
}