pastebin

Paste Search Dynamic
Recent pastes
worltoscreen
  1. static bool screen_transform(const Vector& in, Vector& out)
  2.     {
  3.         static auto& w2sMatrix = g_EngineClient->WorldToScreenMatrix();
  4.  
  5.         out.x = w2sMatrix.m[0][0] * in.x + w2sMatrix.m[0][1] * in.y + w2sMatrix.m[0][2] * in.z + w2sMatrix.m[0][3];
  6.         out.y = w2sMatrix.m[1][0] * in.x + w2sMatrix.m[1][1] * in.y + w2sMatrix.m[1][2] * in.z + w2sMatrix.m[1][3];
  7.         out.z = 0.0f;
  8.  
  9.         float w = w2sMatrix.m[3][0] * in.x + w2sMatrix.m[3][1] * in.y + w2sMatrix.m[3][2] * in.z + w2sMatrix.m[3][3];
  10.  
  11.         if(w < 0.001f) {
  12.             out.x *= 100000;
  13.             out.y *= 100000;
  14.             return false;
  15.         }
  16.  
  17.         out.x /= w;
  18.         out.y /= w;
  19.  
  20.         return true;
  21.     }
  22.     //--------------------------------------------------------------------------------
  23.     bool WorldToScreen(const Vector& in, Vector& out)
  24.     {
  25.         if(screen_transform(in, out)) {
  26.             int w, h;
  27.             g_EngineClient->GetScreenSize(w, h);
  28.  
  29.             out.x = (w / 2.0f) + (out.x * w) / 2.0f;
  30.             out.y = (h / 2.0f) - (out.y * h) / 2.0f;
  31.  
  32.             return true;
  33.         }
  34.         return false;
  35.     }
Parsed in 0.007 seconds