-
Active Member
-
Active Member
oops, i posed a link but that post was removed. so creat new without link
in that case, you might be interested the fishing fun bot from julian, from github go julianperrott/FishingFun
-
Member
I'm trying to implement WorldToScreen.
Who can explain the structure?
And is this offset correct?
Last edited by Hrap; 11-12-2022 at 08:21 PM.
-
Member
Originally Posted by
Hrap
I'm trying to implement WorldToScreen.
Who can explain the structure?
And is this offset correct?
Offset is good, its a view matrix, you can learn about it here
Understanding the View Matrix | 3D Game Engine Programming
View Transform (Direct3D 9) - Win32 apps | Microsoft Learn
Tutorial 3 : Matrices
-
Post Thanks / Like - 1 Thanks
tommingc (1 members gave Thanks to tayl for this useful post)
-
-
Member
Heh...
I suffer the second day with W2S
Found a good code from ChrisIsMe
Code:
Vector2 W2S(Vector3 pos)
{
auto pCameraBase = m.read<uintptr_t>(m.m_base + 0x2535398);
auto pCamera = m.read<uintptr_t>(pCameraBase + 0x3330);
auto cam = m.read<CCamera>(pCamera);
RECT rc = { 0,0,1920,1080 };
Vector3 difference{ pos.x - cam.camPos.x, pos.y - cam.camPos.y, pos.z - cam.camPos.z };
float product =
difference.x * cam.mat._00 +
difference.y * cam.mat._01 +
difference.z * cam.mat._02;
if (product < 0)
return Vector2{ 0,0 };
Matrix inverse = Inverse(cam.mat);
Vector3 view{
inverse._00 * difference.x + inverse._10 * difference.y + inverse._20 * difference.z ,
inverse._01 * difference.x + inverse._11 * difference.y + inverse._21 * difference.z,
inverse._02 * difference.x + inverse._12 * difference.y + inverse._22 * difference.z
};
Vector3 camera{ -view.y, -view.z, view.x };
Vector2 gameScreen{ (rc.right - rc.left) / 2.0f , (rc.bottom - rc.top) / 2.0f };
Vector2 aspect{ gameScreen.x / tan(((cam.fov * 55.0f) / 2.0f) * Deg2Rad) ,gameScreen.y / tan(((cam.fov * 35.0f) / 2.0f) * Deg2Rad) };
Vector2 screenPos{ gameScreen.x + camera.x * aspect.x / camera.z,gameScreen.y + camera.y * aspect.y / camera.z };
if (screenPos.x < 0 || screenPos.y < 0 || screenPos.x > rc.right || screenPos.y > rc.bottom)
return Vector2{ 0,0 };
return screenPos;
}
https://www.ownedcore.com/forums/wor...dtoscreen.html ([Classic] 1.13.2.32089 - WorldToScreen)
Ported to C++
Code:
struct Matrix3x3
{
float M[3][3];
};
Matrix3x3 ObjectManager::invverce(Matrix3x3 m)
{
// computes the inverse of a matrix m
double det = m.M[0][0] * (m.M[1][1] * m.M[2][2] - m.M[2][1] * m.M[1][2]) -
m.M[0][1] * (m.M[1][0] * m.M[2][2] - m.M[1][2] * m.M[2][0]) +
m.M[0][2] * (m.M[1][0] * m.M[2][1] - m.M[1][1] * m.M[2][0]);
double invdet = 1 / det;
Matrix3x3 minv; // inverse of matrix m
minv.M[0][0] = (m.M[1][1] * m.M[2][2] - m.M[2][1] * m.M[1][2]) * invdet;
minv.M[0][1] = (m.M[0][2] * m.M[2][1] - m.M[0][1] * m.M[2][2]) * invdet;
minv.M[0][2] = (m.M[0][1] * m.M[1][2] - m.M[0][2] * m.M[1][1]) * invdet;
minv.M[1][0] = (m.M[1][2] * m.M[2][0] - m.M[1][0] * m.M[2][2]) * invdet;
minv.M[1][1] = (m.M[0][0] * m.M[2][2] - m.M[0][2] * m.M[2][0]) * invdet;
minv.M[1][2] = (m.M[1][0] * m.M[0][2] - m.M[0][0] * m.M[1][2]) * invdet;
minv.M[2][0] = (m.M[1][0] * m.M[2][1] - m.M[2][0] * m.M[1][1]) * invdet;
minv.M[2][1] = (m.M[2][0] * m.M[0][1] - m.M[0][0] * m.M[2][1]) * invdet;
minv.M[2][2] = (m.M[0][0] * m.M[1][1] - m.M[1][0] * m.M[0][1]) * invdet;
return minv;
}
Vector2 ObjectManager::W2S(HWND hwnd, Vector3 pos)
{
DWORD_PTR CameraPtr = RemouteMemory->Read<DWORD_PTR>(RemouteMemory->Read<DWORD_PTR>(RemouteMemory->WowInfo.WowBaseAdrtess + camBase) + camOffset);
curCamera.x = RemouteMemory->Read<float>(CameraPtr + CameraPosition);
curCamera.y = RemouteMemory->Read<float>(CameraPtr + CameraPosition + 4);
curCamera.z = RemouteMemory->Read<float>(CameraPtr + CameraPosition + 8);
curCamera.fov = RemouteMemory->Read<float>(CameraPtr + CameraFOV);
curCamera.matrix = *(Matrix3x3*)RemouteMemory->ReadBytes(CameraPtr + matrix3x3, sizeof Matrix3x3);
RECT rc;
GetWindowRect(hwnd, &rc);;
Vector3 difference{ pos.x - curCamera.x, pos.y - curCamera.y, pos.z - curCamera.z };
float product =
difference.x * curCamera.matrix.M[0][0] +
difference.y * curCamera.matrix.M[0][1] +
difference.z * curCamera.matrix.M[0][2];
if (product < 0)
return Vector2{ 0, 0 };
Matrix3x3 inverse = invverce(curCamera.matrix);
Vector3 view{
inverse.M[0][0] * difference.x + inverse.M[1][0] * difference.y + inverse.M[2][0] * difference.z,
inverse.M[0][1] * difference.x + inverse.M[1][1] * difference.y + inverse.M[2][1] * difference.z,
inverse.M[0][2] * difference.x + inverse.M[1][2] * difference.y + inverse.M[2][2] * difference.z
};
Vector3 camera{ -view.y, -view.z, view.x };
Vector2 gameScreen{ (rc.right - rc.left) / 2.0f, (rc.bottom - rc.top) / 2.0f };
Vector2 aspect{ gameScreen.x / tan(((curCamera.fov * 55.0f) / 2.0f) * (M_PIl / 180.0)), gameScreen.y / tan(((curCamera.fov * 35.0f) / 2.0f) * (M_PIl / 180.0)) };
Vector2 screenPos{ gameScreen.x + camera.x * aspect.x / camera.z, gameScreen.y + camera.y * aspect.y / camera.z };
if (screenPos.x < 0 || screenPos.y < 0 || screenPos.x > rc.right || screenPos.y > rc.bottom)
return Vector2{ 0, 0 };
return screenPos;
}
Everything seems to be clear, but it doesn't work.
I have two doubts
1 Variable Deg2Rad = PI / 180.0?
and it seems to me that I am inverting the matrix incorrectly
Everything else seems to be ok
Last edited by Hrap; 11-13-2022 at 10:56 AM.
-
Member
Originally Posted by
Hrap
Heh...
I suffer the second day with W2S
Found a good code from ChrisIsMe
Code:
Vector2 W2S(Vector3 pos)
{
auto pCameraBase = m.read<uintptr_t>(m.m_base + 0x2535398);
auto pCamera = m.read<uintptr_t>(pCameraBase + 0x3330);
auto cam = m.read<CCamera>(pCamera);
RECT rc = { 0,0,1920,1080 };
Vector3 difference{ pos.x - cam.camPos.x, pos.y - cam.camPos.y, pos.z - cam.camPos.z };
float product =
difference.x * cam.mat._00 +
difference.y * cam.mat._01 +
difference.z * cam.mat._02;
if (product < 0)
return Vector2{ 0,0 };
Matrix inverse = Inverse(cam.mat);
Vector3 view{
inverse._00 * difference.x + inverse._10 * difference.y + inverse._20 * difference.z ,
inverse._01 * difference.x + inverse._11 * difference.y + inverse._21 * difference.z,
inverse._02 * difference.x + inverse._12 * difference.y + inverse._22 * difference.z
};
Vector3 camera{ -view.y, -view.z, view.x };
Vector2 gameScreen{ (rc.right - rc.left) / 2.0f , (rc.bottom - rc.top) / 2.0f };
Vector2 aspect{ gameScreen.x / tan(((cam.fov * 55.0f) / 2.0f) * Deg2Rad) ,gameScreen.y / tan(((cam.fov * 35.0f) / 2.0f) * Deg2Rad) };
Vector2 screenPos{ gameScreen.x + camera.x * aspect.x / camera.z,gameScreen.y + camera.y * aspect.y / camera.z };
if (screenPos.x < 0 || screenPos.y < 0 || screenPos.x > rc.right || screenPos.y > rc.bottom)
return Vector2{ 0,0 };
return screenPos;
}
https://www.ownedcore.com/forums/wor...dtoscreen.html ([Classic] 1.13.2.32089 - WorldToScreen)
Ported to C++
Code:
struct Matrix3x3
{
float M[3][3];
};
Matrix3x3 ObjectManager::invverce(Matrix3x3 m)
{
// computes the inverse of a matrix m
double det = m.M[0][0] * (m.M[1][1] * m.M[2][2] - m.M[2][1] * m.M[1][2]) -
m.M[0][1] * (m.M[1][0] * m.M[2][2] - m.M[1][2] * m.M[2][0]) +
m.M[0][2] * (m.M[1][0] * m.M[2][1] - m.M[1][1] * m.M[2][0]);
double invdet = 1 / det;
Matrix3x3 minv; // inverse of matrix m
minv.M[0][0] = (m.M[1][1] * m.M[2][2] - m.M[2][1] * m.M[1][2]) * invdet;
minv.M[0][1] = (m.M[0][2] * m.M[2][1] - m.M[0][1] * m.M[2][2]) * invdet;
minv.M[0][2] = (m.M[0][1] * m.M[1][2] - m.M[0][2] * m.M[1][1]) * invdet;
minv.M[1][0] = (m.M[1][2] * m.M[2][0] - m.M[1][0] * m.M[2][2]) * invdet;
minv.M[1][1] = (m.M[0][0] * m.M[2][2] - m.M[0][2] * m.M[2][0]) * invdet;
minv.M[1][2] = (m.M[1][0] * m.M[0][2] - m.M[0][0] * m.M[1][2]) * invdet;
minv.M[2][0] = (m.M[1][0] * m.M[2][1] - m.M[2][0] * m.M[1][1]) * invdet;
minv.M[2][1] = (m.M[2][0] * m.M[0][1] - m.M[0][0] * m.M[2][1]) * invdet;
minv.M[2][2] = (m.M[0][0] * m.M[1][1] - m.M[1][0] * m.M[0][1]) * invdet;
return minv;
}
Vector2 ObjectManager::W2S(HWND hwnd, Vector3 pos)
{
DWORD_PTR CameraPtr = RemouteMemory->Read<DWORD_PTR>(RemouteMemory->Read<DWORD_PTR>(RemouteMemory->WowInfo.WowBaseAdrtess + camBase) + camOffset);
curCamera.x = RemouteMemory->Read<float>(CameraPtr + CameraPosition);
curCamera.y = RemouteMemory->Read<float>(CameraPtr + CameraPosition + 4);
curCamera.z = RemouteMemory->Read<float>(CameraPtr + CameraPosition + 8);
curCamera.fov = RemouteMemory->Read<float>(CameraPtr + CameraFOV);
curCamera.matrix = *(Matrix3x3*)RemouteMemory->ReadBytes(CameraPtr + matrix3x3, sizeof Matrix3x3);
RECT rc;
GetWindowRect(hwnd, &rc);;
Vector3 difference{ pos.x - curCamera.x, pos.y - curCamera.y, pos.z - curCamera.z };
float product =
difference.x * curCamera.matrix.M[0][0] +
difference.y * curCamera.matrix.M[0][1] +
difference.z * curCamera.matrix.M[0][2];
if (product < 0)
return Vector2{ 0, 0 };
Matrix3x3 inverse = invverce(curCamera.matrix);
Vector3 view{
inverse.M[0][0] * difference.x + inverse.M[1][0] * difference.y + inverse.M[2][0] * difference.z,
inverse.M[0][1] * difference.x + inverse.M[1][1] * difference.y + inverse.M[2][1] * difference.z,
inverse.M[0][2] * difference.x + inverse.M[1][2] * difference.y + inverse.M[2][2] * difference.z
};
Vector3 camera{ -view.y, -view.z, view.x };
Vector2 gameScreen{ (rc.right - rc.left) / 2.0f, (rc.bottom - rc.top) / 2.0f };
Vector2 aspect{ gameScreen.x / tan(((curCamera.fov * 55.0f) / 2.0f) * (M_PIl / 180.0)), gameScreen.y / tan(((curCamera.fov * 35.0f) / 2.0f) * (M_PIl / 180.0)) };
Vector2 screenPos{ gameScreen.x + camera.x * aspect.x / camera.z, gameScreen.y + camera.y * aspect.y / camera.z };
if (screenPos.x < 0 || screenPos.y < 0 || screenPos.x > rc.right || screenPos.y > rc.bottom)
return Vector2{ 0, 0 };
return screenPos;
}
Everything seems to be clear, but it doesn't work.
I have two doubts
1 Variable Deg2Rad = PI / 180.0?
and it seems to me that I am inverting the matrix incorrectly
Everything else seems to be ok
My advice would be to just use directX for this, there's no reason to reinvent the wheel when library for this already exist and even installed on your computer
-
Member
That's right,
Code:
Vector2 ObjectManager::WorldToScreen(HWND hwnd, Vector3 worldPos, Vector2* output)
{
RECT rect;
GetWindowRect(hwnd, &rect);
float displaySize_x = rect.right - rect.left;
float displaySize_y = rect.bottom - rect.top;
float nearClip = 1.0f;
float farClip = 10000.0f;
//Get Projection Matrix
float fAspect = displaySize_x / displaySize_y;
DirectX::XMMATRIX Proj = DirectX::XMMatrixPerspectiveFovRH(curCamera.fov * 0.6, fAspect, nearClip, farClip);
//Get View Matrix
DirectX::XMFLOAT3 vEyePt(curCamera.x, curCamera.y, curCamera.z);
DirectX::XMFLOAT3 vLookatPt(curCamera.x + curCamera.matrix.M[0][0], curCamera.y + curCamera.matrix.M[0][1], curCamera.z + curCamera.matrix.M[0][2]);
DirectX::XMFLOAT3 vUpVec(0.0f, 0.0f, 1.0f);
DirectX::XMMATRIX View = DirectX::XMMatrixLookAtRH(DirectX::XMLoadFloat3(&vEyePt), DirectX::XMLoadFloat3(&vLookatPt), DirectX::XMLoadFloat3(&vUpVec));
//Project our position
auto inPos = DirectX::XMFLOAT3(worldPos.x, worldPos.y, worldPos.z);
auto outVect = DirectX::XMVector3Project(DirectX::XMLoadFloat3(&inPos), 0, 0, displaySize_x, displaySize_y, nearClip, farClip, Proj, View, DirectX::XMMatrixIdentity());
output->x = DirectX::XMVectorGetX(outVect);
output->y = DirectX::XMVectorGetY(outVect);
return displaySize_x; // used in calculation for alternate screen ratios. The actual x,y is an out param
}
Here's the Directx option,
it seems to work, but not very accurate
-
Member
Originally Posted by
Hrap
That's right,
Code:
Vector2 ObjectManager::WorldToScreen(HWND hwnd, Vector3 worldPos, Vector2* output)
{
RECT rect;
GetWindowRect(hwnd, &rect);
float displaySize_x = rect.right - rect.left;
float displaySize_y = rect.bottom - rect.top;
float nearClip = 1.0f;
float farClip = 10000.0f;
//Get Projection Matrix
float fAspect = displaySize_x / displaySize_y;
DirectX::XMMATRIX Proj = DirectX::XMMatrixPerspectiveFovRH(curCamera.fov * 0.6, fAspect, nearClip, farClip);
//Get View Matrix
DirectX::XMFLOAT3 vEyePt(curCamera.x, curCamera.y, curCamera.z);
DirectX::XMFLOAT3 vLookatPt(curCamera.x + curCamera.matrix.M[0][0], curCamera.y + curCamera.matrix.M[0][1], curCamera.z + curCamera.matrix.M[0][2]);
DirectX::XMFLOAT3 vUpVec(0.0f, 0.0f, 1.0f);
DirectX::XMMATRIX View = DirectX::XMMatrixLookAtRH(DirectX::XMLoadFloat3(&vEyePt), DirectX::XMLoadFloat3(&vLookatPt), DirectX::XMLoadFloat3(&vUpVec));
//Project our position
auto inPos = DirectX::XMFLOAT3(worldPos.x, worldPos.y, worldPos.z);
auto outVect = DirectX::XMVector3Project(DirectX::XMLoadFloat3(&inPos), 0, 0, displaySize_x, displaySize_y, nearClip, farClip, Proj, View, DirectX::XMMatrixIdentity());
output->x = DirectX::XMVectorGetX(outVect);
output->y = DirectX::XMVectorGetY(outVect);
return displaySize_x; // used in calculation for alternate screen ratios. The actual x,y is an out param
}
Here's the Directx option,
it seems to work, but not very accurate
Should be good, what do you mean with not very accurate? Like lower or full miss?
Last edited by tayl; 11-13-2022 at 12:46 PM.
-
Member
returns negative values and values that are larger than the window size, even though the object is right in front of me
-
Member
I try like this
Code:
Vector2 ObjectManager::WorldToScreen(HWND hwnd, Vector3 worldPos)
{
RECT rect;
GetWindowRect(hwnd, &rect);
Vector2 output;
float displaySize_x = rect.right - rect.left;
float displaySize_y = rect.bottom - rect.top;
DWORD_PTR CameraPtr = RemouteMemory->Read<DWORD_PTR>(RemouteMemory->Read<DWORD_PTR>(RemouteMemory->WowInfo.WowBaseAdrtess + camBase) + camOffset);
curCamera.x = RemouteMemory->Read<float>(CameraPtr + CameraPosition);
curCamera.y = RemouteMemory->Read<float>(CameraPtr + CameraPosition + 4);
curCamera.z = RemouteMemory->Read<float>(CameraPtr + CameraPosition + 8);
curCamera.fov = RemouteMemory->Read<float>(CameraPtr + CameraFOV);
curCamera.matrix = new Matrix3x3;
curCamera.matrix->m11 = RemouteMemory->Read<float>(CameraPtr + matrix3x3);
curCamera.matrix->m12 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+4);
curCamera.matrix->m13 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+8);
curCamera.matrix->m21 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+12);
curCamera.matrix->m22 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+16);
curCamera.matrix->m23 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+20);
curCamera.matrix->m31 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+24);
curCamera.matrix->m32 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+28);
curCamera.matrix->m33 = RemouteMemory->Read<float>(CameraPtr + matrix3x3+32);
float nearClip = 1.0f;
float farClip = 10000.0f;
//Get Projection Matrix
float fAspect = displaySize_x / displaySize_y;
DirectX::XMMATRIX Proj = DirectX::XMMatrixPerspectiveFovRH(curCamera.fov * 0.6, fAspect, nearClip, farClip);
//Get View Matrix
DirectX::XMFLOAT3 vEyePt(curCamera.x, curCamera.y, curCamera.z);
DirectX::XMFLOAT3 vLookatPt(curCamera.x + curCamera.matrix->m11, curCamera.y + curCamera.matrix->m12, curCamera.z + curCamera.matrix->m13);
DirectX::XMFLOAT3 vUpVec(0.0f, 0.0f, 1.0f);
DirectX::XMMATRIX View = DirectX::XMMatrixLookAtRH(DirectX::XMLoadFloat3(&vEyePt), DirectX::XMLoadFloat3(&vLookatPt), DirectX::XMLoadFloat3(&vUpVec));
//Project our position
auto inPos = DirectX::XMFLOAT3(worldPos.x, worldPos.y, worldPos.z);
auto outVect = DirectX::XMVector3Project(DirectX::XMLoadFloat3(&inPos), 0, 0, displaySize_x, displaySize_y, nearClip, farClip, Proj, View, DirectX::XMMatrixIdentity());
output.x = DirectX::XMVectorGetX(outVect);
output.y = DirectX::XMVectorGetY(outVect);
return output;
Return random values
I really can't figure out what's wrong
heh
I will probably return to the metaad that Razzue advised
Last edited by Hrap; 11-13-2022 at 03:25 PM.
-
Member
Originally Posted by
Razzue
Why click? Just write a unit/objects guid to your mouse over GUID, then send the key bound to interact with mouse over, ezpz
Razzue I didn’t understand a little what to send after I wrote the desired GUID into memory?
Last edited by Hrap; 11-13-2022 at 05:48 PM.
-
Member
Originally Posted by
Hrap
Razzue I didn’t understand a little what to send after I wrote the desired GUID into memory?
There's an option in wow keybinds to bind interact with mouseover/target to any key
-
Active Member
Good morning!
Does anyone have the FrameScript sig for wowclassic 3.4.0.46368?
I tried hard to find some, but when I execute FrameScriptExecute, it crashes the client with a "DIVIDE BY ZERO" error.
I searched the posts and only found one verified address but I don't have the binary so unsure the signature.
https://www.ownedcore.com/forums/wor...-function.html (Classic Wrath => Build 45327, execute function)
function used:
static inline int64_t Execute(const char* command)
{
//return 0;
return reinterpret_cast<int64_t(__fastcall*)(int64_t, int64_t, int64_t)>(GameBase + Offset_FrameScriptExecute)(int64_t(command), int64_t("compat"), 0);
}
below is the signature I used, it is for the PTR server, and the sig should be the same
//3.4.0.46368T 48 89 5C 24 ? 89 4C 24 08 55 56 57 41 54 41 55 41 56 41 57 48 83 EC 30 48 8B 1D ? ? ? ? 4D 8B F1 48 8B CB 41 8B F0 4C 8B EA E8 ? ? ? ? 4C 8B 3D ? ? ? ? BD ? ? ? ? 2B EE
//search the above function, then click X, find RUNTIME_FUNCTION, click the next function
static inline uintptr_t FrameScriptExecute = 0x5910E0;// WRONG ONE, crash the client by "divide by zero"
EDIT:
So appears I am getting the correct address, by calling this method
Execute("AccountLogin_Login()");
It does react but crashed after that. Why is that?
FrameScriptExecuteError.jpg
Last edited by tommingc; 11-14-2022 at 04:50 AM.
-
Member
Doesn't want to write directly to solder
Most likely the memory is somehow write-protected.
Code:
bool RemoteProcess::WriteBytes(DWORD_PTR adress, BYTE* bytes , DWORD size)
{
HANDLE hprocess = OpenProcess(PROCESS_VM_WRITE, false, WowInfo.WowPid);
if (!WriteProcessMemory(hprocess, (LPVOID)adress, bytes, size, NULL))
{
CloseHandle(hprocess);
return false;
}
else
{
return true;
CloseHandle(hprocess);
}
}
The function returns false when trying to write
Code:
RemouteMemory->WriteBytes(RemouteMemory->WowInfo.WowBaseAdrtess + 0x30701E8, Bytes, 16);
Each new answer raises more questions.
Got it, everything worked
It was necessary to remove VirtualProtect
Searching the forum helped solve the problem.
Thank you all for your help.
It's a pity that it didn't work out with W2S (
Last edited by Hrap; 11-14-2022 at 06:50 AM.