|
CSGO: Viewmatrix Worldtoscreen trouble
Hi, I’ve been working on my C# external cheat but have run into several issues in regards to the viewmatrix worldtoscreen, I will go into detail into what I’m doing to attempt to read the viewmatrix and the strange results I am getting The way i am going about the viewmatrix is taking the viewmatrix values from memory, putting them into a float array of size 16, then running the worldtoscreen method on the 3 coordinates of each player. First of all I am populating the float array I use for the viewmatrix using this method I iterate through each address and set the address read to the current
I'm then using my float array inside my worldtoscreen method, (I had to look how to do this one beforehand as I have no previous experience with a transformation matrix).
returncoords[0] = viewmatrixarray[0] * posx + viewmatrixarray[1] * posy + viewmatrixarray[2] * posz + viewmatrixarray[3]; if (w < 0.01f) return null; float invw = 1.0f / w; returncoords[0] *= invw; returncoords[1] *= invw; // Change these asap. int width = 1920; int height = 1080; float x = width / 2; float y = height / 2; x += 0.5f * returncoords[0] * width + 0.5f; y -= 0.5f * returncoords[1] * height + 0.5f; returncoords[0] = x; returncoords[1] = y; return returncoords; } I then run my worldtoscreen method through each of the players. Before putting the coords through the function I call the readviewmatrix method to ensure it's updated. One thing it isn't is the coordinates, I have checked that I am getting the player coordinates correctly and I am they are the right positions,, the X Y and Z are correct as input but the output I am getting is completely bogus and is totally outside the values of the screen. Example output It seems to change between extremely high/invalid values and then stuck on 960 and 539.5 as I rotate my view around. The biggest culprit I am assuming is the worldtoscreen function itself although it could be the way I am reading it I am not totally sure. Any help would be grateful, Thank you. |
|