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.
| 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. |
| 37 | static 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 | |
| 67 | void EveProjectBracket::UpdateValue( double time ) |
no test coverage detected