Moderator: GZDoom Developers
double PitchTo(Actor mo)
{
double distxy = max(Distance2D(mo), 1);
double distz = pos.z - mo.pos.z;
return clamp(atan(distz / distxy) - pitch, -90, 90);
}
// Make forw, right, up an orthonormal basis off player's orientation:
forw = ( cos vang * cos ang, cos vang * sin ang, sin vang )
q = ( -sin vang * cos ang, -sin vang * sin ang, cos vang )
r = ( sin ang, -cos ang, 0 )
// This part is now easier thanks to argv's work.
// q and r are non-rolled local up and right vectors. Rolling them is easy since they're orthonormal:
up = cos roll * q + sin roll * r
right = -sin roll * q + cos roll * r
// Checks:
diff = target pos - view pos
-ver fov < atan2(diff dot up, diff dot forw) < ver fov ?
-hor fov < atan2(diff dot right, diff dot forw) < hor fov ?
KeksDose wrote:I think MC requested measuring fov in a rectangular measure.
KeksDose wrote:I wrote player but it works for anything. It's the maths all in all to describe the idea, not implement it. That's up to developers.
I'm very confident this is correct, but Graf's comment does make me wonder, since this kinda seems like a fairly natural idea to try. I could be wrong.
Graf Zahl wrote:Good luck finding someone who can cook up the proper math for it.
Return to Closed Feature Suggestions
Users browsing this forum: DotBot and 1 guest