Created
June 12, 2023 12:20
-
-
Save S0PEX/d3332c08176febf9c3d60a8ded3b49fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SoldierBones | |
// Bones 48 8B C4 53 48 81 EC ? ? ? ? 44 0F 29 60 | |
static constexpr auto kClientDiceAntAnimatableEntity = 0x1050; | |
static constexpr auto kAntAnimatableEntity = 0x38; | |
static constexpr auto kRenderSkeleton = 0x30; | |
static constexpr auto kSqtArray = 0x38; | |
// RenderSkeleton | |
static constexpr auto kServerBoneHierarchy = 0x48; | |
static constexpr auto kLocalBoneHierarchy = 0x60; | |
class QuatTransformation | |
{ | |
public: | |
DirectX::XMVECTOR scale_; //0x0000 | |
DirectX::FXMVECTOR quat_; //0x0010 | |
DirectX::FXMVECTOR translation_; //0x0020 | |
}; //Size: 0x0030 | |
enum AnimatableBones : int | |
{ | |
Reference = 0, | |
AiTrajectory = 1, | |
CameraBase = 2, | |
CameraJoint = 3, | |
CameraBase3p = 4, | |
Connect = 5, | |
Connect_Offset = 6, | |
Ground = 7, | |
Hips = 8, | |
LeftHipsRoll = 9, | |
LeftUpLeg = 10, | |
LeftKneeUp = 11, | |
LeftKneeRoll = 12, | |
LeftUpLegRoll = 13, | |
LeftLeg = 14, | |
LeftAnkle = 15, | |
LeftFoot = 16, | |
LeftFootAttach = 17, | |
LeftToeBase = 18, | |
LeftToe = 19, | |
LeftKneeLow = 20, | |
RightHipsRoll = 21, | |
RightUpLeg = 22, | |
RightKneeUp = 23, | |
RightKneeRoll = 24, | |
RightUpLegRoll = 25, | |
RightLeg = 26, | |
RightAnkle = 27, | |
RightFoot = 28, | |
RightFootAttach = 29, | |
RightToeBase = 30, | |
RightToe = 31, | |
RightKneeLow = 32, | |
Spine = 33, | |
Spine1 = 34, | |
Spine2 = 35, | |
LeftArmpit = 36, | |
LeftDeltoidBulge = 37, | |
Neck = 38, | |
Neck1 = 39, | |
Head = 40, | |
HeadEnd = 41, | |
HeadGear = 42, | |
Face = 43, | |
JawBase = 44, | |
Jaw = 45, | |
Tongue = 46, | |
Tongue1 = 47, | |
Tongue2 = 48, | |
Tongue3 = 49, | |
LeftTongue3 = 50, | |
RightTongue3 = 51, | |
LeftEye = 52, | |
RightEye = 53, | |
Attachment_C_ChinBottom_01 = 54, | |
Attachment_C_ChinBottom_02 = 55, | |
Attachment_C_ChinBottom_03 = 56, | |
Attachment_C_ChinTip = 57, | |
Attachment_C_Forehead_Upper = 58, | |
Attachment_C_LipLower = 59, | |
Attachment_C_Lip_Upper = 60, | |
Attachment_C_NoseBridge = 61, | |
Attachment_C_NoseColumella = 62, | |
Attachment_C_NoseTip = 63, | |
Attachment_L_Cheek = 64, | |
Attachment_L_Cheek_Upper = 65, | |
Attachment_L_ChinSide = 66, | |
Attachment_L_EarLobe = 67, | |
Attachment_L_EarTop = 68, | |
Attachment_L_EyeLid_Lower_LeftCorner = 69, | |
Attachment_L_EyeLid_Lower_Middle = 70, | |
Attachment_L_EyeLid_Lower_RightCorner = 71, | |
Attachment_L_EyeLid_Upper_LeftCorner = 72, | |
Attachment_L_EyeLid_Upper_Middle = 73, | |
Attachment_L_EyeLid_Upper_RightCorner = 74, | |
Attachment_L_Eyebrow_Inner = 75, | |
Attachment_L_Eyebrow_Middle = 76, | |
Attachment_L_Eyebrow_Outer = 77, | |
Attachment_L_JawSide_01 = 78, | |
Attachment_L_JawSide_02 = 79, | |
Attachment_L_JawSide_03 = 80, | |
Attachment_L_JawSide_04 = 81, | |
Attachment_L_JawSide_05 = 82, | |
Attachment_L_JawSide_06 = 83, | |
Attachment_L_JawSide_07 = 84, | |
Attachment_L_JawSide_08 = 85, | |
Attachment_L_JawSide_09 = 86, | |
Attachment_L_JawSide_10 = 87, | |
Attachment_L_JawSide_11 = 88, | |
Attachment_L_JawSide_12 = 89, | |
Attachment_L_JawSide_13 = 90, | |
Attachment_L_JawSide_14 = 91, | |
Attachment_L_LipCorner_Lower = 92, | |
Attachment_L_LipCorner_Upper = 93, | |
Attachment_L_LipLower_Middle = 94, | |
Attachment_L_LipUpper = 95, | |
Attachment_L_LipUpper_Outer = 96, | |
Attachment_R_Cheek = 97, | |
Attachment_R_Cheek_Upper = 98, | |
Attachment_R_ChinSide = 99, | |
Attachment_R_EarLobe = 100, | |
Attachment_R_EarTop = 101, | |
Attachment_R_EyeLid_Lower_LeftCorner = 102, | |
Attachment_R_EyeLid_Lower_Middle = 103, | |
Attachment_R_EyeLid_Lower_RightCorner = 104, | |
Attachment_R_EyeLid_Upper_LeftCorner = 105, | |
Attachment_R_EyeLid_Upper_Middle = 106, | |
Attachment_R_EyeLid_Upper_RightCorner = 107, | |
Attachment_R_Eyebrow_Inner = 108, | |
Attachment_R_Eyebrow_Middle = 109, | |
Attachment_R_Eyebrow_Outer = 110, | |
Attachment_R_JawSide_01 = 111, | |
Attachment_R_JawSide_02 = 112, | |
Attachment_R_JawSide_03 = 113, | |
Attachment_R_JawSide_04 = 114, | |
Attachment_R_JawSide_05 = 115, | |
Attachment_R_JawSide_06 = 116, | |
Attachment_R_JawSide_07 = 117, | |
Attachment_R_JawSide_08 = 118, | |
Attachment_R_JawSide_09 = 119, | |
Attachment_R_JawSide_10 = 120, | |
Attachment_R_JawSide_11 = 121, | |
Attachment_R_JawSide_12 = 122, | |
Attachment_R_JawSide_13 = 123, | |
Attachment_R_JawSide_14 = 124, | |
Attachment_R_LipCorner_Lower = 125, | |
Attachment_R_LipCorner_Upper = 126, | |
Attachment_R_LipLower_Middle = 127, | |
Attachment_R_LipUpper = 128, | |
Attachment_R_LipUpper_Outer = 129, | |
FACIAL_C_FacialRoot = 130, | |
FACIAL_LOD1_C_Forehead = 131, | |
FACIAL_LOD1_C_Jaw = 132, | |
FACIAL_LOD1_C_Chin = 133, | |
FACIAL_LOD1_L_ChinSide = 134, | |
FACIAL_LOD1_R_ChinSide = 135, | |
FACIAL_LOD1_C_Mouth = 136, | |
FACIAL_LOD1_C_LipLower = 137, | |
FACIAL_LOD1_C_LipLowerInner = 138, | |
FACIAL_LOD1_C_LipUpper = 139, | |
FACIAL_LOD1_C_LipUpperInner = 140, | |
FACIAL_LOD1_L_LipCorner = 141, | |
FACIAL_LOD1_L_LipCornerInner = 142, | |
FACIAL_LOD1_L_LipLower = 143, | |
FACIAL_LOD1_L_LipLowerInner = 144, | |
FACIAL_LOD1_L_LipLowerOuter = 145, | |
FACIAL_LOD1_L_LipLowerOuterInner = 146, | |
FACIAL_LOD1_L_LipUpper = 147, | |
FACIAL_LOD1_L_LipUpperInner = 148, | |
FACIAL_LOD1_L_LipUpperOuter = 149, | |
FACIAL_LOD1_L_LipUpperOuterInner = 150, | |
FACIAL_LOD1_R_LipCorner = 151, | |
FACIAL_LOD1_R_LipCornerInner = 152, | |
FACIAL_LOD1_R_LipLower = 153, | |
FACIAL_LOD1_R_LipLowerInner = 154, | |
FACIAL_LOD1_R_LipLowerOuter = 155, | |
FACIAL_LOD1_R_LipLowerOuterInner = 156, | |
FACIAL_LOD1_R_LipUpper = 157, | |
FACIAL_LOD1_R_LipUpperInner = 158, | |
FACIAL_LOD1_R_LipUpperOuter = 159, | |
FACIAL_LOD1_R_LipUpperOuterInner = 160, | |
FACIAL_LOD1_C_Nose = 161, | |
FACIAL_LOD1_C_NoseLower = 162, | |
FACIAL_LOD1_L_Nostril = 163, | |
FACIAL_LOD1_R_Nostril = 164, | |
FACIAL_LOD1_C_NoseBridge = 165, | |
FACIAL_LOD1_C_UnderChin = 166, | |
FACIAL_LOD1_L_CheekInner = 167, | |
FACIAL_LOD1_L_CheekLower = 168, | |
FACIAL_LOD1_L_CheekOuter = 169, | |
FACIAL_LOD1_L_Ear = 170, | |
FACIAL_LOD1_L_EyelidLower = 171, | |
FACIAL_LOD1_L_EyelidUpper = 172, | |
FACIAL_LOD1_L_EyelidUpperFurrow = 173, | |
FACIAL_LOD1_L_EyesackLower = 174, | |
FACIAL_LOD1_L_EyesackUpper = 175, | |
FACIAL_LOD1_L_ForeheadIn = 176, | |
FACIAL_LOD1_L_ForeheadMid = 177, | |
FACIAL_LOD1_L_ForeheadOut = 178, | |
FACIAL_LOD1_L_Masseter = 179, | |
FACIAL_LOD1_L_NasolabialBulge = 180, | |
FACIAL_LOD1_L_NasolabialFurrow = 181, | |
FACIAL_LOD1_L_UnderChin = 182, | |
FACIAL_LOD1_R_CheekInner = 183, | |
FACIAL_LOD1_R_CheekLower = 184, | |
FACIAL_LOD1_R_CheekOuter = 185, | |
FACIAL_LOD1_R_Ear = 186, | |
FACIAL_LOD1_R_EyelidLower = 187, | |
FACIAL_LOD1_R_EyelidUpper = 188, | |
FACIAL_LOD1_R_EyelidUpperFurrow = 189, | |
FACIAL_LOD1_R_EyesackLower = 190, | |
FACIAL_LOD1_R_EyesackUpper = 191, | |
FACIAL_LOD1_R_ForeheadIn = 192, | |
FACIAL_LOD1_R_ForeheadMid = 193, | |
FACIAL_LOD1_R_ForeheadOut = 194, | |
FACIAL_LOD1_R_Masseter = 195, | |
FACIAL_LOD1_R_NasolabialBulge = 196, | |
FACIAL_LOD1_R_NasolabialFurrow = 197, | |
FACIAL_LOD1_R_UnderChin = 198, | |
HeadRoll = 199, | |
FACIAL_C_Neck2Root = 200, | |
FACIAL_LOD1_C_AdamsApple = 201, | |
RightArmpit = 202, | |
RightDeltoidBulge = 203, | |
SpineX = 204, | |
SpineX_Buffer = 205, | |
LeftShoulder = 206, | |
LeftArm = 207, | |
LeftArmBend = 208, | |
LeftArmRoll = 209, | |
LeftArmRoll1 = 210, | |
LeftElbowRoll = 211, | |
LeftForeArm = 212, | |
LeftForeArmRoll = 213, | |
LeftForeArmRoll1 = 214, | |
LeftForeArmRoll2 = 215, | |
LeftHand = 216, | |
LeftHandAttach = 217, | |
LeftHandIndex0 = 218, | |
LeftHandIndex1 = 219, | |
LeftHandIndex2 = 220, | |
LeftHandIndex3 = 221, | |
LeftHandMiddle0 = 222, | |
LeftHandMiddle1 = 223, | |
LeftHandMiddle2 = 224, | |
LeftHandMiddle3 = 225, | |
LeftHandPinky0 = 226, | |
LeftHandPinky1 = 227, | |
LeftHandPinky2 = 228, | |
LeftHandPinky3 = 229, | |
LeftHandRing0 = 230, | |
LeftHandRing1 = 231, | |
LeftHandRing2 = 232, | |
LeftHandRing3 = 233, | |
LeftHandThumb1 = 234, | |
LeftHandThumb2 = 235, | |
LeftHandThumb3 = 236, | |
LeftHandThumb4 = 237, | |
LeftThumbBend_VPJ = 238, | |
LeftThumbBridge_VPJ = 239, | |
RightShoulder = 240, | |
RightArm = 241, | |
RightArmBend = 242, | |
RightArmRoll = 243, | |
RightArmRoll1 = 244, | |
RightElbowRoll = 245, | |
RightForeArm = 246, | |
RightForeArmRoll = 247, | |
RightForeArmRoll1 = 248, | |
RightForeArmRoll2 = 249, | |
RightHand = 250, | |
RightHandAttach = 251, | |
RightHandIndex0 = 252, | |
RightHandIndex1 = 253, | |
RightHandIndex2 = 254, | |
RightHandIndex3 = 255, | |
RightHandMiddle0 = 256, | |
RightHandMiddle1 = 257, | |
RightHandMiddle2 = 258, | |
RightHandMiddle3 = 259, | |
RightHandPinky0 = 260, | |
RightHandPinky1 = 261, | |
RightHandPinky2 = 262, | |
RightHandPinky3 = 263, | |
RightHandRing0 = 264, | |
RightHandRing1 = 265, | |
RightHandRing2 = 266, | |
RightHandRing3 = 267, | |
RightHandThumb1 = 268, | |
RightHandThumb2 = 269, | |
RightHandThumb3 = 270, | |
RightHandThumb4 = 271, | |
RightThumbBend_VPJ = 272, | |
RightThumbBridge_VPJ = 273, | |
Wep_SpineX = 274, | |
Wep_Root = 275, | |
Wep_Align = 276, | |
Wep_BRL_Attach = 277, | |
Wep_BRL_Barrel = 278, | |
Wep_BRL_FX = 279, | |
Wep_BRL_Muzzle = 280, | |
Wep_Bolt1 = 281, | |
Wep_Bolt2 = 282, | |
Wep_BoltCatch = 283, | |
Wep_Charm = 284, | |
Wep_Charm_Collision = 285, | |
Wep_Extra1 = 286, | |
Wep_Extra2 = 287, | |
Wep_Extra3 = 288, | |
Wep_Extra4 = 289, | |
Wep_GRP_Attach = 290, | |
Wep_GRP_Base = 291, | |
Wep_GRP_Bipod = 292, | |
Wep_GRP_BipodLegLeft1 = 293, | |
Wep_GRP_BipodLegRight1 = 294, | |
Wep_GRP_Extra1 = 295, | |
Wep_GRP_Extra2 = 296, | |
Wep_GRP_Extra3 = 297, | |
Wep_GRP_Extra4 = 298, | |
Wep_GRP_Extra5 = 299, | |
Wep_Hammer = 300, | |
Wep_IK_LeftHand = 301, | |
Wep_IK_RightHand = 302, | |
Wep_MGZ_Attach = 303, | |
Wep_MGZ_Belt1 = 304, | |
Wep_MGZ_Belt2 = 305, | |
Wep_MGZ_Belt3 = 306, | |
Wep_MGZ_Belt4 = 307, | |
Wep_MGZ_Belt5 = 308, | |
Wep_MGZ_Belt6 = 309, | |
Wep_MGZ_Belt7 = 310, | |
Wep_MGZ_Belt8 = 311, | |
Wep_MGZ_Belt9 = 312, | |
Wep_MGZ_Belt10 = 313, | |
Wep_MGZ_Belt11 = 314, | |
Wep_MGZ_Belt12 = 315, | |
Wep_MGZ_BeltOut1 = 316, | |
Wep_MGZ_BeltOut2 = 317, | |
Wep_MGZ_BeltOut3 = 318, | |
Wep_MGZ_BeltOut4 = 319, | |
Wep_MGZ_BeltOut5 = 320, | |
Wep_MGZ_BeltOut6 = 321, | |
Wep_MGZ_BeltOut7 = 322, | |
Wep_MGZ_BeltOut8 = 323, | |
Wep_MGZ_Mag1 = 324, | |
Wep_MGZ_Mag1_Ammo1 = 325, | |
Wep_MGZ_Mag1_Ammo2 = 326, | |
Wep_MGZ_Mag2 = 327, | |
Wep_MagRelease = 328, | |
Wep_Menu = 329, | |
Wep_SCP_Attach = 330, | |
Wep_SCP_Scope = 331, | |
Wep_SCP_Scope_Extra1 = 332, | |
Wep_SelectFireMode = 333, | |
Wep_ShellEject = 334, | |
Wep_Trigger = 335, | |
SpineX_Static = 336, | |
TorsoGear = 337, | |
LeftAnkleEffectorAux = 338, | |
LeftHandIKAux = 339, | |
RightAnkleEffectorAux = 340, | |
RightHandIKAux = 341, | |
Trajectory = 342, | |
FaceOutput = 343 | |
}; | |
const game::QuatTransformation* game::ClientPlayer::GetQuatTransformation(const int index) | |
{ | |
// use cached result if already read | |
if (read_bones_) | |
return &bone_quat_transformations_[index % offsets::kBoneCount]; | |
const auto ant_animatable_entity = drv->ReadMemory<uintptr_t>( | |
player_soldier_entity_ + offsets::kClientDiceAntAnimatableEntity, { | |
0x0, // | |
offsets::kAntAnimatableEntity, // -> m_animatable | |
}); | |
if (!ant_animatable_entity) | |
return nullptr; | |
const auto quat_transforms = drv->ReadMemory<void*>(ant_animatable_entity + offsets::kSqtArray); | |
if (!quat_transforms) | |
return nullptr; | |
const auto local_hierarchy = drv->ReadMemory<void*>(ant_animatable_entity + offsets::kRenderSkeleton, | |
{0x0, 0x0, offsets::kLocalBoneHierarchy}); | |
if (!local_hierarchy) | |
return nullptr; | |
drv->Read(&bone_quat_transformations_, quat_transforms, sizeof bone_quat_transformations_); | |
drv->Read(&bone_hierarchy_, local_hierarchy, sizeof bone_hierarchy_); | |
read_bones_ = true; | |
return &bone_quat_transformations_[index % offsets::kBoneCount]; | |
} | |
int game::ClientPlayer::GetBoneHierarchy(const int bone) | |
{ | |
// Too lazy to put the read hierarchy here as it is already in GetQuatTransformation | |
if (GetQuatTransformation(AiTrajectory)) | |
{ | |
return bone_hierarchy_[bone % offsets::kBoneCount]; | |
} | |
return Reference; | |
} | |
netownage::math::Vec3 game::ClientPlayer::GetBonePosition(const AnimatableBones bone_index) | |
{ | |
if (const auto start_sqt = GetQuatTransformation(bone_index)) | |
{ | |
auto position = start_sqt->translation_; | |
for (auto index = GetBoneHierarchy(bone_index); index >= AiTrajectory; index = GetBoneHierarchy(index)) | |
{ | |
if (const auto parent_sqt = GetQuatTransformation(index % offsets::kBoneCount)) | |
{ | |
// Rotate child into place | |
const auto rotated_position = DirectX::XMVector3Rotate(position, parent_sqt->quat_); | |
// Scale child | |
const auto scaled_rotated_position = DirectX::XMVectorMultiply( | |
rotated_position, parent_sqt->scale_); | |
// Calculate delta from grandparent to child | |
const auto transformed_position = DirectX::XMVectorAdd( | |
scaled_rotated_position, parent_sqt->translation_); | |
position = transformed_position; | |
} | |
} | |
return {position.m128_f32[0], position.m128_f32[1], position.m128_f32[2]}; | |
} | |
return {}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment