Results 1 to 2 of 2
  1. #1
    crvs899's Avatar
    Join Date
    Mar 2013
    Gender
    male
    Posts
    11
    Reputation
    10
    Thanks
    4

    Viewmatrix and WorldToScreen

    I am working on my first CSGO hack. Before i get into details, the hack is external and I am using C#. My problem is that when I read the view matrix and try and convert player positions to screen points, I get ridiculously weird numbers. Sometimes the numbers when converted to strings read out "NaN" which I know means undefined. Here is a table of what I'm talking about.

    ViewMatrix:
    1.79498E+21 -1.215803E-11 1.680519E-33 -1.122565E-06
    3.888831E-20 -9735.812 3.186712E+38 -8.520999E+13
    -3.5921E-14 -6.890327E+13 -2.064528E+26 -6.869414E+13
    9.530977E+14 -1.121148E-06 -5.784123E+19 -1.118947E-06

    Some of the bots positions + my position(I'll filter it out later) after converted to screen
    102512.2 Infinity
    61532.27 Infinity
    43722.18 Infinity
    38530.59 Infinity
    79687.25 Infinity

    I don't know if I am reading the view matrix wrong (I have tried multiple different ways) or if I am converting the points wrong.
    Here is my code:

    get Viewmatrix
    Code:
    public static float[] GetMatrixArray(ref ProcessMemory mem)
     {
         float[] flt = new float[16];
         Buffer.BlockCopy(mem.ReadMem(mem.Pointer("client.dll", Offsets.viewMatrix), 64), 0, flt, 0, mem.ReadMem(mem.Pointer("client.dll", Offsets.viewMatrix), 64).Length);
         //byte[] tempBytes = mem.ReadMem(mem.Pointer("client.dll", Offsets.viewMatrix), 64);
                
         //for(int i = 0; i < 16; i++)
         //{
         //    flt[i] = BitConverter.ToSingle(tempBytes, (i * 4));
         //}
         return flt;
     }
    World to Screen Function (Version with floats) I have another version of this function which is the same code but the Viewmatrix is a struct
    Code:
    bool WorldToScreenFloat(ref V3 position, ref Vector2 screenPosition)
    {
    	float[] floatMatrix = MatrixUtils.GetMatrixArray(ref mem);
    	float w = 0.0F;
    	screenPosition.X = floatMatrix[0] * position.x + floatMatrix[1] * position.y + floatMatrix[2] * position.z + floatMatrix[3];
    	screenPosition.Y = floatMatrix[4] * position.x + floatMatrix[5] * position.y + floatMatrix[6] * position.z + floatMatrix[7];
    	w = floatMatrix[12] * position.x + floatMatrix[13] * position.y + floatMatrix[14] * position.z + floatMatrix[15];
    
    	if (w < 0.1F)
    		return false;
    
    	float inv = 1.0F / w;
    	screenPosition.X *= inv;
    	screenPosition.Y *= inv;
    
    	int width = Screen.PrimaryScreen.Bounds.Width;
    	int height = Screen.PrimaryScreen.Bounds.Height;
    
    	float x = width / 2;
    	float y = height / 2;
    
    	x += (float)(0.5F * screenPosition.X * width + 0.5F);
    	y -= (float)(0.5F * screenPosition.Y * height + 0.5F);
    
    	screenPosition.X = x + this.Left;
    	screenPosition.Y = y + this.Top;
    
    	return true;
    }
    I have also attached the image of the information from the tables outputted onto my overlay. Thank you for the help.
    Attached Thumbnails Attached Thumbnails
    2016-05-30.png  


  2. #2
    Hunter's Avatar
    Join Date
    Dec 2013
    Gender
    male
    Location
    Depths Of My Mind.
    Posts
    17,468
    Reputation
    3771
    Thanks
    6,159
    My Mood
    Cheerful
    1 week has passed and no further replies have been made by the OP. Assuming solved.

    /Closed.

Similar Threads

  1. CS 1.6 VAC2 proof hacks AND cheat death hacks
    By Brunogol in forum General Game Hacking
    Replies: 28
    Last Post: 12-18-2006, 08:26 PM
  2. Get Avatars and Sigs!
    By Dave84311 in forum General
    Replies: 25
    Last Post: 05-17-2006, 08:44 PM
  3. Plz I Want Maple Global Hacks And Where Do I Get Game Engine 2 Make The Hacks Work???
    By mattinthehat in forum MapleStory Hacks, Cheats & Trainers
    Replies: 3
    Last Post: 01-15-2006, 06:12 PM
  4. Lineag2 and Ragnarok
    By suppaman in forum General Gaming
    Replies: 12
    Last Post: 01-01-2006, 04:07 PM
  5. i need short icq number pls and hack to wr..
    By BoneXDBreaker in forum WarRock - International Hacks
    Replies: 1
    Last Post: 12-26-2005, 05:08 PM