Results 1 to 3 of 3
  1. #1
    MrKerras's Avatar
    Join Date
    Feb 2014
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0

    ViewMatrix problem

    I found some functions for processing 3D position to a point on a 2D screen.
    But it is not working properly, here's the function:
    Code:
    bool WorldToScreen2(float * from, float * to, float fovY, TWorldToScreenMatrix firstPersonTransform, int ScreenWidth, int ScreenHeight)
    {
        int height = ScreenHeight;
        int width = ScreenWidth;
        float aspect = (float)width /  (float)height;
    
        D3DXVECTOR3 vOrigin = D3DXVECTOR3(firstPersonTransform.flMatrix[3][0],firstPersonTransform.flMatrix[3][1],firstPersonTransform.flMatrix[3][2]);
        D3DXVECTOR3 vLeft    = D3DXVECTOR3(firstPersonTransform.flMatrix[0][0],firstPersonTransform.flMatrix[0][1],firstPersonTransform.flMatrix[0][2]);
        D3DXVECTOR3 vUp        = D3DXVECTOR3(firstPersonTransform.flMatrix[1][0],firstPersonTransform.flMatrix[1][1],firstPersonTransform.flMatrix[1][2]);
        D3DXVECTOR3 vForward = D3DXVECTOR3(firstPersonTransform.flMatrix[2][0],firstPersonTransform.flMatrix[2][1],firstPersonTransform.flMatrix[2][2]);
    
        D3DXMATRIX viewMatrix;
            D3DXMatrixIdentity(&viewMatrix);    
        viewMatrix._11 = vLeft.x; viewMatrix._12 = vUp.x; viewMatrix._13 = vForward.x;
            viewMatrix._21 = vLeft.y; viewMatrix._22 = vUp.y; viewMatrix._23 = vForward.y;
            viewMatrix._31 = vLeft.z; viewMatrix._32 = vUp.z; viewMatrix._33 = vForward.z;
    
            viewMatrix._41 = -D3DXVec3Dot(&vOrigin, &vLeft);
            viewMatrix._42 = -D3DXVec3Dot(&vOrigin, &vUp);
            viewMatrix._43 = -D3DXVec3Dot(&vOrigin, &vForward);
    
        D3DXMATRIXA16 Proj;
        D3DXMatrixPerspectiveFovRH( &Proj, fovY,  aspect , 0.1f,  10000.0f);
        D3DXMATRIXA16 viewProjecti******** = viewMatrix * Proj;
    
        float mX = width * 0.5f ;
        float mY = height * 0.5f ;
    
        float w =
                viewProjecti********(0,3) * from[0] +
                viewProjecti********(1,3) * from[1] +
                viewProjecti********(2,3) * from[2] +
                viewProjecti********(3,3);
    
            if( w < 0.0001f )
            {
                return false;
            }
    
            float x =
                viewProjecti********(0,0) * from[0] +
                viewProjecti********(1,0) * from[1] +
                viewProjecti********(2,0) * from[2] +
                viewProjecti********(3,0);
    
            float y =
                viewProjecti********(0,1) * from[0] +
                viewProjecti********(1,1) * from[1] +
                viewProjecti********(2,1) * from[2] +
                viewProjecti********(3,1);
    
            to[0] = mX + mX * x / w;
            to[1] = mY - mY * y / w;
            
            return true;
    }
    My structure TWorldToScreenMatrix:
    Code:
    typedef struct
    {
        float flMatrix [4][4];
    }TWorldToScreenMatrix;
    Original code:
    Code:
    bool cReader::worldToScreen(fb::Vec3 vWorldLocationVec3,fb::Vec3* vOut)
    {
        int height = getScreenHeight();
        int width = getScreenWidth();
        float aspect = (float)width /  (float)height;
    
        fb::Mat4 firstPersonTransform;FLOAT fovY;    
        DWORD OffsetGameRenderer = 0x02384D78;
        DWORD GameRenderer;
        ReadProcessMemory(pHandle, (void*)(OffsetGameRenderer), &GameRenderer, 4, NULL);
        ReadProcessMemory(pHandle, (void*)(GameRenderer + 0x98), &fovY, sizeof(FLOAT), NULL);    
        ReadProcessMemory(pHandle, (void*)(GameRenderer + 0x50), &firstPersonTransform, sizeof(fb::Mat4), NULL);    
        
        D3DXVECTOR3 vOrigin = D3DXVECTOR3(firstPersonTransform[3][0],firstPersonTransform[3][1],firstPersonTransform[3][2]);
        D3DXVECTOR3 vLeft    = D3DXVECTOR3(firstPersonTransform[0][0],firstPersonTransform[0][1],firstPersonTransform[0][2]);
        D3DXVECTOR3 vUp        = D3DXVECTOR3(firstPersonTransform[1][0],firstPersonTransform[1][1],firstPersonTransform[1][2]);
        D3DXVECTOR3 vForward = D3DXVECTOR3(firstPersonTransform[2][0],firstPersonTransform[2][1],firstPersonTransform[2][2]);
    
        D3DXMATRIX viewMatrix;
            D3DXMatrixIdentity(&viewMatrix);    
        viewMatrix._11 = vLeft.x; viewMatrix._12 = vUp.x; viewMatrix._13 = vForward.x;
            viewMatrix._21 = vLeft.y; viewMatrix._22 = vUp.y; viewMatrix._23 = vForward.y;
            viewMatrix._31 = vLeft.z; viewMatrix._32 = vUp.z; viewMatrix._33 = vForward.z;
    
             viewMatrix._41 = -D3DXVec3Dot(&vOrigin, &vLeft);
             viewMatrix._42 = -D3DXVec3Dot(&vOrigin, &vUp);
             viewMatrix._43 = -D3DXVec3Dot(&vOrigin, &vForward);
    
        D3DXMATRIXA16 Proj;
        D3DXMatrixPerspectiveFovRH( &Proj, fovY,  aspect , 0.1f,  10000.0f);
        D3DXMATRIXA16 viewProjecti******** = viewMatrix * Proj;
    
        float mX = width * 0.5f ;
        float mY = height * 0.5f ;
    
        float w =
                viewProjecti********(0,3) * vWorldLocationVec3.x +
                viewProjecti********(1,3) * vWorldLocationVec3.y +
                viewProjecti********(2,3) * vWorldLocationVec3.z +
                viewProjecti********(3,3);
    
            if( w < 0.0001f )
            {
                vOut->z = w;
    
                return false;
            }
    
            float x =
                viewProjecti********(0,0) * vWorldLocationVec3.x +
                viewProjecti********(1,0) * vWorldLocationVec3.y +
                viewProjecti********(2,0) * vWorldLocationVec3.z +
                viewProjecti********(3,0);
    
            float y =
                viewProjecti********(0,1) * vWorldLocationVec3.x +
                viewProjecti********(1,1) * vWorldLocationVec3.y +
                viewProjecti********(2,1) * vWorldLocationVec3.z +
                viewProjecti********(3,1);
    
            vOut->x = mX + mX * x / w;
            vOut->y = mY - mY * y / w;
            vOut->z = w;
            
            return true;
    }
    Of course, functions ReadProcessMemory and Offset gave earlier in another function, but the data from it are used in my function WorldToScreen2.


    Can anyone help me improve functionality or write a new that will work properly?

    I would like to write the External Hack.
    Last edited by MrKerras; 09-06-2014 at 03:05 AM.

  2. #2
    smallC's Avatar
    Join Date
    Jun 2013
    Gender
    male
    Posts
    49
    Reputation
    10
    Thanks
    1,361
    what is wrong? instead of using TWorldToScreenMatrix , use D3DXMATRIX

    and firstPersonTransform(3)(0) instead of firstPersonTransform[3][0].

    But be sure to have correct witdth and height. I don't know how you get them.

  3. #3
    MrKerras's Avatar
    Join Date
    Feb 2014
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    Could not find match for 'D3DXMATRIX:perator()(int)'

    I have used this firstPersonTransform(3,0)

    Still not working, all the boxes are aligned diagonally and only a little change position but still at an angle.
    Last edited by MrKerras; 09-07-2014 at 12:23 AM.

Similar Threads

  1. To All GunZ Down 02-07-06 PROBLEM
    By WertyRO in forum Gunz General
    Replies: 18
    Last Post: 02-09-2006, 07:41 PM
  2. Problem
    By lambda in forum Gunz General
    Replies: 3
    Last Post: 02-08-2006, 11:36 AM
  3. hacking problems
    By iwillkillyou in forum WarRock - International Hacks
    Replies: 11
    Last Post: 02-04-2006, 04:37 PM
  4. WPE problem...
    By styx23 in forum General Game Hacking
    Replies: 8
    Last Post: 01-18-2006, 07:51 PM
  5. Problem Wit Hacking Programs
    By f5awp in forum General Gaming
    Replies: 5
    Last Post: 01-10-2006, 05:44 AM

Tags for this Thread