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

Method SetupTransformsForPicking

trinity/ITr2PickableScene.cpp:177–192  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Sets view and projection transform to be used for picking. Arguments: fx - X offset of the frustum in post-projected space fy - Y offset of the frustum in post-projected space proj - Current projection transform view - Current view transform viewport - Current viewport ------------------------------

Source from the content-addressed store, hash-verified

175// viewport - Current viewport
176// --------------------------------------------------------------------------------------
177void ITr2PickableScene::SetupTransformsForPicking( float fx, float fy, TriProjection* proj, TriView* view, TriViewport* viewport )
178{
179 Tr2Renderer::SetViewTransform( view->GetTransform() );
180 proj->SetProjection();
181 //
182 // Projection is set up to scale the image such that the viewport is covered by one pixel.
183 Vector2 scaling( float( viewport->width ), float( viewport->height ) );
184 // translate the projection so that we center around the pick ray origin,
185 // while remembering to scale this value as well:
186 Vector2 translation;
187 translation.x = -fx * scaling.x;
188 translation.y = -fy * scaling.y;
189 Tr2Renderer::AdjustProjection( scaling, translation );
190
191 // We do NOT set the viewport here. It will get set automatically when SetRenderTarget is called.
192}
193
194// --------------------------------------------------------------------------------------
195// Description:

Callers

nothing calls this directly

Calls 3

SetViewTransformFunction · 0.85
GetTransformMethod · 0.45
SetProjectionMethod · 0.45

Tested by

no test coverage detected