示例#1
0
        //Credits: 0x2aff
        public static bool WorldToScreen(Vector3 from, Vector2 to)
        {
            var viewMatrix = new float[16];

            for (int i = 0; i < 16; i++)
            {
                viewMatrix[i] = PinvokeWrapper.ReadAddFloat(ClientBaseAddress + Offsets.dwViewMatrix + (i * 0x4), CsgoHandle);
            }

            float w = 0.0f;

            to.X = viewMatrix[0] * from.X + viewMatrix[1] * from.Y + viewMatrix[2] * from.Z + viewMatrix[3];
            to.Y = viewMatrix[4] * from.X + viewMatrix[5] * from.Y + viewMatrix[6] * from.Z + viewMatrix[7];
            w    = viewMatrix[12] * from.X + viewMatrix[13] * from.Y + viewMatrix[14] * from.Z + viewMatrix[15];

            if (w < 0.01f)
            {
                return(false); //Not in FOV, we return false
            }
            float inverse = 1.0f / w;

            to.X *= inverse;
            to.Y *= inverse;

            float x = ScreenWidth / 2;
            float y = ScreenHeight / 2;

            x += 0.5f * to.X * ScreenWidth + 0.5f;
            y -= 0.5f * to.Y * ScreenHeight + 0.5f;

            to.X = x;
            to.Y = y;

            return(true); //Success
        }
示例#2
0
        public Vector2 GetPosition()
        {
            //Create a new vector to save the 2d player coordinates later
            var player2DPosition = new Vector2();

            //Get X coordinate
            var x = PinvokeWrapper.ReadAddFloat((IntPtr)BaseAddress + Offsets.m_vecOrigin, Utils.CsgoHandle);
            //Get Y coordinate
            var y = PinvokeWrapper.ReadAddFloat((IntPtr)BaseAddress + Offsets.m_vecOrigin + 0x4, Utils.CsgoHandle);
            //Get Z coordinate
            var z = PinvokeWrapper.ReadAddFloat((IntPtr)BaseAddress + Offsets.m_vecOrigin + 0x8, Utils.CsgoHandle);

            //Convert the world coordinates to screen coordinates
            Utils.WorldToScreen(new Vector3(x, y, z), player2DPosition);

            //Return the result
            return(player2DPosition);
        }
示例#3
0
        public Vector2 GetBonePos(int boneId)
        {
            //Create a new vector to save the 2d bone coordinates later
            var player2DPosition = new Vector2();

            //Get the bone matrix
            var boneMatrix = PinvokeWrapper.ReadAddInt((IntPtr)BaseAddress + Offsets.m_dwBoneMatrix, Utils.CsgoHandle);

            //Get the world coordinates of the player's bone
            var playerBoneX = PinvokeWrapper.ReadAddFloat((IntPtr)boneMatrix + 0x30 * boneId + 0x0C, Utils.CsgoHandle);
            var playerBoneY = PinvokeWrapper.ReadAddFloat((IntPtr)boneMatrix + 0x30 * boneId + 0x1C, Utils.CsgoHandle);
            var playerBoneZ = PinvokeWrapper.ReadAddFloat((IntPtr)boneMatrix + 0x30 * boneId + 0x2C, Utils.CsgoHandle);

            //Convert the world coordinates to screen coordinates
            Utils.WorldToScreen(new Vector3(playerBoneX, playerBoneY, playerBoneZ), player2DPosition);

            //Return the result
            return(player2DPosition);
        }