Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CVector CVector::ToScreen(const CVector& CamPos, const CAngle& CamAngle, double FOV, unsigned int ScreenWidth, unsigned int ScreenHeight) const
- {
- CVector up = CamAngle.Up();
- CVector right = CamAngle.Right();
- CVector forward = CamAngle.Forward();
- CVector dir = CamPos - *this;
- double fdp = forward.Dot(dir);
- if(fdp == 0)
- return CVector(0, 0);
- double d = 4.0 * ScreenHeight / (6.0 * tan(rads(0.5 * FOV)));
- CVector proj = dir * (d / fdp);
- double x = 0.5 * ScreenWidth + right.Dot(proj);
- double y = 0.5 * ScreenHeight - up.Dot(proj);
- return CVector(x, y, 0.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement