MCPcopy Create free account
hub / github.com/carbonengine/trinity / ProjectWorldToScreen

Method ProjectWorldToScreen

trinity/Tr2Renderer.cpp:490–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488}
489
490Vector3 Tr2Renderer::ProjectWorldToScreen( const Vector3& worldPos, const Tr2Viewport& vp )
491{
492 Vector4 p( worldPos.x, worldPos.y, worldPos.z, 1.0f );
493 p = p * GetViewTransform();
494 p = p * GetProjectionTransform();
495 if( p.w )
496 {
497 p *= 1.0f / p.w;
498 }
499
500 return Vector3( vp.m_x + vp.m_width * ( 0.5f + 0.5f * p.x ),
501 vp.m_y + vp.m_height * ( 0.5f - 0.5f * p.y ),
502 vp.m_minZ + p.z * vp.m_maxZ );
503}
504
505const Matrix& Tr2Renderer::GetInverseProjectionTransform()
506{

Callers

nothing calls this directly

Calls 3

GetViewTransformFunction · 0.85
GetProjectionTransformFunction · 0.85
Vector3Class · 0.70

Tested by

no test coverage detected