Advertisement
Guest User

QTS no. 10 - World to screen

a guest
Jul 9th, 2010
1,352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. /*
  2. -----------------------------------------
  3. * Game hacking QTS ( Quickie Tip Series )
  4. * no. 10 - World to screen
  5. -----------------------------------------
  6. * Author: SEGnosis  - GHAnon.net
  7. * Thanks to:
  8. * bitterbanana      - No known site
  9. * Drunken Cheetah   - No known site
  10. * fatboy88      - No known site
  11. * Geek4Ever         - No known site
  12. * learn_more        - www.uc-forum.com
  13. * Novocaine         - http://ilsken.net/blog/?page_id=64
  14. * Philly0494        - No known site
  15. * Roverturbo        - www.uc-forum.com
  16. * SilentKarma       - www.halocoders.com - offline
  17. * Strife        - www.uc-forum.com
  18. * Wieter20      - No known site
  19. */
  20.  
  21. #define IsW2SValid(a)( ( a.x == -1000 && a.y == -1000 ) ? false : true )
  22.  
  23.  
  24. struct FVect3
  25. {
  26.     float x,y,z;
  27. };
  28.  
  29.  
  30. //----------------------------------//
  31. POINT World2Screen( FVect3 vPos )
  32. {
  33.     POINT ptRet = { -1000, -1000 };
  34.    
  35.     D3DXVECTOR3 vScreen,
  36.                 vWorld( vPos.x, vPos.y, vPos.z );
  37.            
  38.     static D3DXMATRIX   m_mxProjection,
  39.                         m_mxView,
  40.                         m_mxWorld;
  41.                            
  42.     pDevice->GetTransform( D3DTS_VIEW, &m_mxView );
  43.    
  44.     pDevice->GetTransform( D3DTS_PROJECTION, &m_mxProjection );
  45.    
  46.     pDevice->GetTransform( D3DTS_WORLD, &m_mxWorld );
  47.    
  48.     pDevice->GetViewport( &m_ViewPort );
  49.    
  50.     D3DXVec3Project( &vScreen, &vWorld, &m_ViewPort, &m_mxProjection, &m_mxView, &m_mxWorld );
  51.                
  52.     if( vScreen.z <= 1 )
  53.     {
  54.         ptRet.x = vScreen.x;
  55.         ptRet.y = vScreen.y;
  56.     }
  57.    
  58.     return ptRet;
  59. }
  60. //----------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement