enum CharacterStance
{
Standing,
Crouching,
Crawling,
Downed
};
enum Bone {
Head = 7,
Neck = 6,
Chest = 5,
Mid = 4,
Tummy = 3,
RightFoot1 = 21,
RightFoot2 = 22,
RightFoot3 = 23,
RightFoot4 = 24,
LeftFoot1 = 17,
LeftFoot2 = 18,
LeftFoot3 = 19,
LeftFoot4 = 20,
LeftHand1 = 13,
LeftHand2 = 14,
LeftHand3 = 15,
LeftHand4 = 16,
RightHand1 = 9,
RightHand2 = 10,
RightHand3 = 11,
RightHand4 = 12
}
pub static BONE_CONNECTIONS: &[(Bone, Bone)] = &[
(Head, Neck),
(Neck, Chest),
(Chest, Mid),
(Mid, Tummy),
(Tummy, LeftFoot1),
(LeftFoot1, LeftFoot2),
(LeftFoot2, LeftFoot3),
(LeftFoot3, LeftFoot4),
(Tummy, RightFoot1),
(RightFoot1, RightFoot2),
(RightFoot2, RightFoot3),
(RightFoot3, RightFoot4),
(Neck, LeftHand1),
(LeftHand1, LeftHand2),
(LeftHand2, LeftHand3),
(LeftHand3, LeftHand4),
(Neck, RightHand1),
(RightHand1, RightHand2),
(RightHand2, RightHand3),
(RightHand3, RightHand4),
];
class RefdefView {
public:
ImVec2 tanHalfFov; // 0x00
ImVec3 vieworg; // 0x08
ImVec3 axis[3]; // 0x14
ImVec3 origin; // 0x6C
};
class refdef_t {
public:
int x; // 0x00
int y; // 0x04
int width; // 0x08
int height; // 0x0C
RefdefView view; // 0x10
};
class PosInfo {
public:
ImVec3 Origin; //0x40
float Rotation; //0x58
};
class refdefKeyStruct {
public:
DWORD ref0; // 0x00
DWORD ref1; // 0x04
DWORD ref2; // 0x08
};
uint64_t DecryptRefDef()
{
refdefKeyStruct crypt = driver::read<refdefKeyStruct>(g_Sock, process_id, module_base + offsets::ref_def);
DWORD lower = crypt.ref0 ^ (crypt.ref2 ^ (unsigned __int64)(module_base + offsets::ref_def)) * ((crypt.ref2 ^ (unsigned __int64)(module_base + offsets::ref_def)) + 2);
DWORD upper = crypt.ref1 ^ (crypt.ref2 ^ (unsigned __int64)(module_base + offsets::ref_def + 0x4)) * ((crypt.ref2 ^ (unsigned __int64)(module_base + offsets::ref_def + 0x4)) + 2);
uint64_t refDefKey = (uint64_t)upper << 32 | lower;
return refDefKey;
}
bool WorldToScreen(ImVec3 vOrigin, refdef_t refdef, ImVec2* vOut)
{
ImVec3 vLocal, vTrans;
vLocal = ImVec3(vOrigin.x - refdef.view.vieworg.x, vOrigin.y - refdef.view.vieworg.y, vOrigin.z - refdef.view.vieworg.z);
vTrans.x = vLocal.x * refdef.view.axis[1].x + vLocal.y * refdef.view.axis[1].y + vLocal.z * refdef.view.axis[1].z;
vTrans.y = vLocal.x * refdef.view.axis[2].x + vLocal.y * refdef.view.axis[2].y + vLocal.z * refdef.view.axis[2].z;
vTrans.z = vLocal.x * refdef.view.axis[0].x + vLocal.y * refdef.view.axis[0].y + vLocal.z * refdef.view.axis[0].z;
if (vTrans.z < 0.01f)
return false;
vOut->x = ((refdef.width / 2) * (1 - (vTrans.x / refdef.view.tanHalfFov.x / vTrans.z)));
vOut->y = ((refdef.height / 2) * (1 - (vTrans.y / refdef.view.tanHalfFov.y / vTrans.z)));
return true;
}