-
Автор темы
- #1
Добрый день, хочу получить позицию костей, все перешерстил , оффсеты вроде рабочие,не могу понять в чем дело, есть у кого инфа?
Получение костей:
ICharacterInstance* GetICharacterInstance(int id = 0)
{
uintptr_t pIEntityRenderProxy = GetRenderProxy();
if (!pIEntityRenderProxy)
return 0;
if (uintptr_t pEntityObject = ReadMem<uintptr_t>(ReadMem<uintptr_t>(pIEntityRenderProxy + 0x58)) + (id << 16))
{
return ReadMem<ICharacterInstance>((DWORD64)pEntityObject + 0x78);
}
return 0;
}
uintptr_t GetRenderProxy()
{
return ReadMem<uintptr_t>((uintptr_t)this + 0xB8);
}
ISkeletonPose GetISkeletonPose()
{
return (ISkeletonPose)((DWORD64)this + 0xA80);
}
QuatT GetAbsJointByID(int BoneId)
{
return ReadMem<QuatT>(ReadMem<uintptr_t>((DWORD64)this + 0x1B8) + 0x1C BoneId);
}
ICharacterInstance* pCharacter = pEnt->GetICharacterInstance(0);
if (pCharacter != NULL)
{
ISkeletonPose* pSkeleton = pCharacter->GetISkeletonPose();
if (pSkeleton != NULL)
{
Matrix3x4 SkeletonAbs = pEnt->GetWorldTM() * Matrix3x4(pSkeleton->GetAbsJointByID(BoneId::Bip01_Head));
Vector3 bone = SkeletonAbs.GetTranslation();
ma:
struct Quat
{
public:
Vec3 v;
FLOAT w;
Quat(const Matrix3x3& m)
{
float s, p, tr = m.m00 + m.m11 + m.m22;
w = 1, v.x = 0, v.y = 0, v.z = 0;
if (tr > 0)
s = (float)sqrt(tr + 1.0f), p = 0.5f / s, w = s * 0.5f, v.x = (m.m21 - m.m12) * p, v.y = (m.m02 - m.m20) * p, v.z = (m.m10 - m.m01) * p;
else if ((m.m00 >= m.m11) && (m.m00 >= m.m22))
s = (float)sqrt(m.m00 - m.m11 - m.m22 + 1.0f), p = 0.5f / s, w = (m.m21 - m.m12) * p, v.x = s * 0.5f, v.y = (m.m10 + m.m01) * p, v.z = (m.m20 + m.m02) * p;
else if ((m.m11 >= m.m00) && (m.m11 >= m.m22))
s = (float)sqrt(m.m11 - m.m22 - m.m00 + 1.0f), p = 0.5f / s, w = (m.m02 - m.m20) * p, v.x = (m.m01 + m.m10) * p, v.y = s * 0.5f, v.z = (m.m21 + m.m12) * p;
else if ((m.m22 >= m.m00) && (m.m22 >= m.m11))
s = (float)sqrt(m.m22 - m.m00 - m.m11 + 1.0f), p = 0.5f / s, w = (m.m10 - m.m01) * p, v.x = (m.m02 + m.m20) * p, v.y = (m.m12 + m.m21) * p, v.z = s * 0.5f;
}
Quat() {}
friend float operator | (const Quat& q, const Quat& p) { return (q.v.x * p.v.x + q.v.y * p.v.y + q.v.z * p.v.z + q.w * p.w); }
friend Quat operator - (const Quat& q, const Quat& p)
{
Quat ret;
ret.w = q.w - p.w;
ret.v.x = q.v.x - p.v.x;
ret.v.y = q.v.y - p.v.y;
ret.v.z = q.v.z - p.v.z;
return ret;
}
void SetRotationVDir(const Vec3& vdir)
{
w = (0.70710676908493042f);
v.x = (vdir.z * 0.70710676908493042f);
v.y = (0.0f);
v.z = (0.0f);
float l = sqrt(vdir.x * vdir.x + vdir.y * vdir.y);
if (l > (0.00001))
{
Vec3 hv;
hv.x = vdir.x / l;
hv.y = vdir.y / l + 1.0f;
hv.z = l + 1.0f;
float r = sqrt(hv.x * hv.x + hv.y * hv.y);
float s = sqrt(hv.z * hv.z + vdir.z * vdir.z);
float hacos0 = 0.0;
float hasin0 = -1.0;
if (r > (0.00001)) { hacos0 = hv.y / r; hasin0 = -hv.x / r; }
float hacos1 = hv.z / s;
float hasin1 = vdir.z / s;
w = (hacos0 * hacos1);
v.x = (hacos0 * hasin1);
v.y = (hasin0 * hasin1);
v.z = (hasin0 * hacos1);
}
}
static Quat CreateRotationVDir(const Vec3& vdir)
{
Quat q;
q.SetRotationVDir(vdir);
return q;
}
void Normalize(void)
{
float d = sqrt(w * w + v.x * v.x + v.y * v.y + v.z * v.z);
w *= d;
v.x *= d;
v.y *= d;
v.z *= d;
}
void SetNlerp(const Quat& p, const Quat& tq, float t)
{
Quat q = tq;
assert(p.IsValid());
assert(q.IsValid());
if ((p | q) < 0)
{
float qx = -q.v.x;
float qy = -q.v.y;
float qz = -q.v.z;
q.v.x = qx;
q.v.y = qy;
q.v.z = qz;
}
v.x = p.v.x * (1.0f - t) + q.v.x * t;
v.y = p.v.y * (1.0f - t) + q.v.y * t;
v.z = p.v.z * (1.0f - t) + q.v.z * t;
w = p.w * (1.0f - t) + q.w * t;
Normalize();
}
void SetSlerp(const Quat& tp, const Quat& tq, float t)
{
assert(tp.IsValid());
Quat p, q;
p = tp;
q = tq;
Quat q2;
float cosine = (p | q);
if (cosine < 0.0f)
{
float qx = -q.v.x;
float qy = -q.v.y;
float qz = -q.v.z;
cosine = -cosine;
q.v.x = qx;
q.v.y = qy;
q.v.z = qz;
}
if (cosine > 0.9999f)
{
SetNlerp(p, q, t);
return;
}
q2.w = q.w - p.w * cosine;
q2.v.x = q.v.x - p.v.x * cosine;
q2.v.y = q.v.y - p.v.y * cosine;
q2.v.z = q.v.z - p.v.z * cosine;
float sine = sqrt(q2 | q2);
float s, c;
sincos(atan2(sine, cosine) * t, &s, &c);
w = (p.w * c + q2.w * s / sine);
v.x = (p.v.x * c + q2.v.x * s / sine);
v.y = (p.v.y * c + q2.v.y * s / sine);
v.z = (p.v.z * c + q2.v.z * s / sine);
}
static Quat CreateSlerp(const Quat& p, const Quat& tq, float t)
{
Quat d;
d.SetSlerp(p, tq, t);
return d;
}
};
struct QuatT
{
public:
Quat q;
Vec3 t;
};
ma1:
struct Matrix3x4
{
public:
FLOAT m00, m01, m02, m03;
FLOAT m10, m11, m12, m13;
FLOAT m20, m21, m22, m23;
Vector3 GetTranslation() { Vector3 mf; mf.x = m03; mf.y = m13; mf.z = m23; return mf; }
Vec3 GetTranslation_() { Vec3 mf; mf.x = m03; mf.y = m13; mf.z = m23; return mf; }
inline Vec3 GetTranslationD3D() const { return Vec3(m03, m13, m23); }
inline Vec3 GetColumn0() const { return Vec3(m00, m10, m20); }
inline Vec3 GetColumn1() const { return Vec3(m01, m11, m21); }
BOOL NumberValid(FLOAT& _x)
{
int i = FloatU32(_x);
int expmask = FloatU32ExpMask;
int iexp = i & expmask;
bool invalid = (iexp == expmask);
if (invalid)
{
int i = 0x7F800001;
float fpe = [I](float[/I])(&i);
}
return !invalid;
}
Matrix3x4 SetTranslation(Vec3 NewTranslation) { m03 = NewTranslation.x; m13 = NewTranslation.y; m23 = NewTranslation.z; return *this; }
Matrix3x4() {}
Matrix3x4(const QuatT& q)
{
assert(q.q.IsValid());
Vec3 v2 = { 0, 0, 0 };
v2.x = (q.q.v.x) + (q.q.v.x);
float xx = 1 - v2.x * q.q.v.x; float yy = v2.y * q.q.v.y; float xw = v2.x * q.q.w;
float xy = v2.y * q.q.v.x; float yz = v2.z * q.q.v.y; float yw = v2.y * q.q.w;
float xz = v2.z * q.q.v.x; float zz = v2.z * q.q.v.z; float zw = v2.z * q.q.w;
m00 = float(1 - yy - zz); m01 = float(xy - zw); m02 = float(xz + yw); m03 = float(q.t.x);
m10 = float(xy + zw); m11 = float(xx - zz); m12 = float(yz - xw); m13 = float(q.t.y);
m20 = float(xz - yw); m21 = float(yz + xw); m22 = float(xx - yy); m23 = float(q.t.z);
}
bool IsValid()
{
if (!NumberValid(m00)) return false; if (!NumberValid(m01)) return false; if (!NumberValid(m02)) return false; if (!NumberValid(m03)) return false;
if (!NumberValid(m10)) return false; if (!NumberValid(m11)) return false; if (!NumberValid(m12)) return false; if (!NumberValid(m13)) return false;
if (!NumberValid(m20)) return false; if (!NumberValid(m21)) return false; if (!NumberValid(m22)) return false; if (!NumberValid(m23)) return false;
return true;
}
friend Matrix3x4 operator * (const Matrix3x4& l, const Matrix3x4& r)
{
assert(l.IsValid());
assert(r.IsValid());
Matrix3x4 m = r;
m.m00 = l.m00 * r.m00 + l.m01 * r.m10 + l.m02 * r.m20;
m.m10 = l.m10 * r.m00 + l.m11 * r.m10 + l.m12 * r.m20;
m.m20 = l.m20 * r.m00 + l.m21 * r.m10 + l.m22 * r.m20;
m.m01 = l.m00 * r.m01 + l.m01 * r.m11 + l.m02 * r.m21;
m.m11 = l.m10 * r.m01 + l.m11 * r.m11 + l.m12 * r.m21;
m.m21 = l.m20 * r.m01 + l.m21 * r.m11 + l.m22 * r.m21;
m.m02 = l.m00 * r.m02 + l.m01 * r.m12 + l.m02 * r.m22;
m.m12 = l.m10 * r.m02 + l.m11 * r.m12 + l.m12 * r.m22;
m.m22 = l.m20 * r.m02 + l.m21 * r.m12 + l.m22 * r.m22;
m.m03 = l.m00 * r.m03 + l.m01 * r.m13 + l.m02 * r.m23 + l.m03;
m.m13 = l.m10 * r.m03 + l.m11 * r.m13 + l.m12 * r.m23 + l.m13;
m.m23 = l.m20 * r.m03 + l.m21 * r.m13 + l.m22 * r.m23 + l.m23;
return m;
}