Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( !point._is_valid() )
- {
- return false;
- }
- VMatrix worldToScreen = valve_games_interfaces::m_pEngine->WorldToScreenMatrix();
- out2D.x = worldToScreen[0][0] * point.x + worldToScreen[0][1] * point.y + worldToScreen[0][2] * point.z + worldToScreen[0][3];
- out2D.y = worldToScreen[1][0] * point.x + worldToScreen[1][1] * point.y + worldToScreen[1][2] * point.z + worldToScreen[1][3];
- out2D.z = worldToScreen[3][0] * point.x + worldToScreen[3][1] * point.y + worldToScreen[3][2] * point.z + worldToScreen[3][3];
- if ( !out2D._is_valid() )
- {
- return false;
- }
- float w = out2D.z;
- out2D.z = 0.0f;
- // bool behind = false;
- if( w < 0.01f )
- {
- return false;
- // behind = true;
- // out2D.x *= 100000;
- // out2D.y *= 100000;
- }
- else
- {
- // behind = false;
- float invw = 1.0f / w;
- out2D.x *= invw;
- out2D.y *= invw;
- if ( !out2D._is_valid() )
- {
- return false;
- }
- }
- float x = float(m_pExport->m_iWidth >> 1);
- float y = float(m_pExport->m_iHeight >> 1);
- x += 0.5 * out2D.x * m_pExport->m_iWidth + 0.5;
- y -= 0.5 * out2D.y * m_pExport->m_iHeight + 0.5;
- //dont render out of screen
- if( x > m_pExport->m_iWidth ||
- x < 0 ||
- y > m_pExport->m_iHeight ||
- y < 0 )
- return false;
- out2D._init(x,y,0);
- if ( !out2D._is_valid() )
- {
- return false;
- }
- return true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement