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

Function BicylindricProjection

trinity/Eve/UI/EveProjectBracket.cpp:37–64  ·  view source on GitHub ↗

Cylindric projection. projects all points legally by rotating through the vertical and horizontal camera axii, landing them on a vertical or horizontal plane through the camera's origin. These two points are then projected regularly to get a x and y projected coordinate.

Source from the content-addressed store, hash-verified

35//camera axii, landing them on a vertical or horizontal plane through the camera's origin.
36//These two points are then projected regularly to get a x and y projected coordinate.
37static Vector3 BicylindricProjection( const Vector3& pos, const TriViewport& viewport )
38{
39 bool behind = pos.z >= 0.0f;
40
41 //horizontal rotation to center. We use vector arithmetic for speed, by just projecting
42 //the vector on the vertical view plane, and then correcting the z coordinate to get the
43 //correct vector length.
44 float zSq = pos.z * pos.z;
45 Vector3 v[2] = {
46 //rotate onto vertical plane about the vertical axis
47 Vector3( 0.0f, -pos.y, sqrtf( pos.x * pos.x + zSq ) ),
48 //Same for horizontal
49 Vector3( pos.x, 0.0f, sqrtf( pos.y * pos.y + zSq ) )
50 };
51
52 //now, project both vectors (view already done)
53 for( int i = 0; i < 2; ++i )
54 {
55 v[i] = TransformCoord( v[i], Tr2Renderer::GetProjectionTransform() );
56 Vec3TransformByViewport( v[i], viewport );
57 }
58
59 Vector3 res;
60 res.x = v[1].x;
61 res.y = v[0].y;
62 res.z = ( behind ? -0.5f : 0.5f ) * ( v[0].z + v[1].z );
63 return res;
64}
65
66
67void EveProjectBracket::UpdateValue( double time )

Callers 1

UpdateValueMethod · 0.85

Calls 3

GetProjectionTransformFunction · 0.85
Vec3TransformByViewportFunction · 0.85
Vector3Class · 0.50

Tested by

no test coverage detected