Results 1 to 8 of 8
  1. #1
    Arnibold's Avatar
    Join Date
    Jun 2008
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    2

    Wrong World2Screen Calculation

    Hi
    I have the x,y,z coordinates and the pitch/yaw of my player entity. Same with the enemy players. I tried to find out their screen location via World2Screen.

    This is my function
    Code:
    D3DXVECTOR3 *World2Screen(LPDIRECT3DDEVICE9 pDevice, D3DXVECTOR3 &vScreenCoord, D3DXVECTOR3 vEnemy)
    {
    	if( !pDevice ) return NULL;
    
    	D3DXMATRIX matProj;
    	float fAspect = (float)(1280) / 720;
    	D3DXMatrixPerspectiveFovRH(&matProj, (float)(D3DX_PI/180*90), fAspect, 0.1, -1);
    	
    	float *pX = (float*)(*(DWORD*)(Base)+0x60);
    	float *pY = (float*)(*(DWORD*)(Base)+0x68);
    	float *pZ = (float*)(*(DWORD*)(Base)+0x64);
    	float *pitch = (float*)(*(DWORD*)(Base)+0x6C);
    	float *yaw = (float*)(*(DWORD*)(Base)+0x70);
    
    	D3DXVECTOR3 vEye ( *pX, *pY, *pZ);
    	D3DXVECTOR3 vTarget ( *pX + *yaw, *pY + (*pitch * -1), *pZ);
    	D3DXVECTOR3 vUp ( 0, 0, 1 );
    	D3DXMATRIX matView;
    	D3DXMatrixLookAtRH( &matView, &vEye, &vTarget, &vUp);
    
    	D3DVIEWPORT9 viewPort;
    	D3DXMATRIX identity;
    
    	pDevice->GetViewport( &viewPort );
    	D3DXMatrixIdentity( &identity );
    
    	D3DXVec3Project(&vScreenCoord, &vEnemy, &viewPort, &matProj, &matView, &identity );
    
    	if(vScreenCoord.z < 1)
    		return &vScreenCoord;
    
    	return NULL;
    }
    It kind of works but the 2d coordinates are absolutely not correct. I will post some screenshots l8r.

    [img]https://img7.imagebanan*****m/img/z4bk0r00/fu1.png[/img]
    [img]https://img6.imagebanan*****m/img/l03mfttv/fu2.png[/img]
    Last edited by Arnibold; 09-06-2011 at 12:53 AM.

  2. #2
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,858
    Reputation
    3438
    Thanks
    101,669
    My Mood
    Breezy
    Maybe you might want to have a look at the Source SDK? I don't know.
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.7.3
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]

  3. #3
    Nico's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Germany :D
    Posts
    15,918
    Reputation
    1121
    Thanks
    8,617
    Quote Originally Posted by master131 View Post
    Maybe you might want to have a look at the Source SDK? I don't know.
    Yea, i think i saw a func for that somewhere in the SDK.

  4. #4
    .::SCHiM::.'s Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    733
    Reputation
    180
    Thanks
    880
    My Mood
    Twisted
    Seeing CS brings back such good memories. I think imma play it again just this night

    I'm SCHiM

    Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.

    Polymorphic engine
    Interprocess callback class
    SIN
    Infinite-precision arithmetic
    Hooking dynamic linkage
    (sloppy)Kernel mode Disassembler!!!

    Semi debugger




  5. #5
    kibbles18's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    US
    Posts
    860
    Reputation
    5
    Thanks
    127
    @Arnibold I would like to see the whole project source. I can add some hacks if you want also?
    Also, it looks like the 2D - Y is right, but the X is off?
    Last edited by kibbles18; 09-07-2011 at 07:17 PM.

  6. #6
    ISmokeWeedAmICoolNow's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Posts
    54
    Reputation
    10
    Thanks
    19
    My Mood
    Bitchy
    perhaps you need to use the left-handed functions instead of right-handed?
    D3DXMatrixLookAtLH Function (Windows)
    D3DXMatrixPerspectiveFovLH Function (Windows)

  7. #7
    Arnibold's Avatar
    Join Date
    Jun 2008
    Gender
    male
    Posts
    13
    Reputation
    10
    Thanks
    2
    Sorry for the late response,
    I used the engine anyhow.
    Result:
    [img]https://img7.imagebanan*****m/img/6mdvjpg3/asdaaa.jpg[/img]
    (missing HUD and darkish screen is cuz of screenshot hotkey f10)

  8. #8
    Hell_Demon's Avatar
    Join Date
    Mar 2008
    Gender
    male
    Location
    I love causing havoc
    Posts
    3,976
    Reputation
    343
    Thanks
    4,320
    My Mood
    Cheeky
    Try scaling from 800x600 to 1280x720

    New X & Y would become 578, 280, which would be right above the 2nd player from the left.
    Ah we-a blaze the fyah, make it bun dem!

Similar Threads

  1. Can someone tell me wtf I did wrong? =(
    By SadisticGrin in forum C++/C Programming
    Replies: 7
    Last Post: 08-14-2007, 04:37 AM
  2. Whats wrong with my code? =(
    By SadisticGrin in forum C++/C Programming
    Replies: 13
    Last Post: 08-03-2007, 11:39 AM
  3. Hack gone wrong
    By qwerty1029 in forum Suggestions, Requests & General Help
    Replies: 1
    Last Post: 02-07-2007, 04:53 PM
  4. i think i know whats wrong with gourav
    By iverson954360 in forum General
    Replies: 14
    Last Post: 12-19-2006, 10:07 AM
  5. There Is Nothing Wrong With Rose !
    By Severed in forum General Gaming
    Replies: 0
    Last Post: 02-21-2006, 02:41 AM