Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1.  
  2.   if ( !point._is_valid() )
  3.   {
  4.     return false;
  5.   }
  6.  
  7.   VMatrix   worldToScreen = valve_games_interfaces::m_pEngine->WorldToScreenMatrix();
  8.   out2D.x = worldToScreen[0][0] * point.x + worldToScreen[0][1] * point.y + worldToScreen[0][2] * point.z + worldToScreen[0][3];
  9.   out2D.y = worldToScreen[1][0] * point.x + worldToScreen[1][1] * point.y + worldToScreen[1][2] * point.z + worldToScreen[1][3];
  10.   out2D.z = worldToScreen[3][0] * point.x + worldToScreen[3][1] * point.y + worldToScreen[3][2] * point.z + worldToScreen[3][3];
  11.   if ( !out2D._is_valid() )
  12.   {
  13.     return false;
  14.   }
  15.  
  16.   float w = out2D.z;
  17.   out2D.z = 0.0f;
  18.  
  19. //   bool behind = false;
  20.  
  21.   if( w < 0.01f )
  22.   {
  23.     return false;
  24. //     behind = true;
  25. //     out2D.x *= 100000;
  26. //     out2D.y *= 100000;
  27.   }
  28.   else
  29.   {
  30. //     behind = false;
  31.     float invw = 1.0f / w;
  32.     out2D.x *= invw;
  33.     out2D.y *= invw;
  34.  
  35.     if ( !out2D._is_valid() )
  36.     {
  37.       return false;
  38.     }
  39.   }
  40.  
  41.   float x = float(m_pExport->m_iWidth  >> 1);
  42.   float y = float(m_pExport->m_iHeight >> 1);
  43.  
  44.   x += 0.5 * out2D.x * m_pExport->m_iWidth  + 0.5;
  45.   y -= 0.5 * out2D.y * m_pExport->m_iHeight + 0.5;
  46.  
  47.   //dont render out of screen
  48.   if( x > m_pExport->m_iWidth  ||
  49.     x < 0 ||
  50.     y > m_pExport->m_iHeight ||
  51.     y < 0 )
  52.     return false;
  53.  
  54.   out2D._init(x,y,0);
  55.  
  56.   if ( !out2D._is_valid() )
  57.   {
  58.     return false;
  59.   }
  60.  
  61.   return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement