public void CalcFrustumPlanes() { Vector3d cN = Position + CenterOfInterest * Znear; Vector3d cF = Position + CenterOfInterest * Zfar; double Hnear = 2.0f * Convert.ToSingle(Math.Tan(Matrix4dExtension.DegreesToRadians(fov / 2.0f)) * Znear); double Wnear = Hnear * aspect_ratio; double Hfar = 2.0f * Convert.ToSingle(Math.Tan(Matrix4dExtension.DegreesToRadians(fov / 2.0f)) * Zfar); double Wfar = Hfar * aspect_ratio; double hHnear = Hnear / 2.0f; double hWnear = Wnear / 2.0f; double hHfar = Hfar / 2.0f; double hWfar = Wfar / 2.0f; farPts[0] = cF + Up * hHfar - right * hWfar; farPts[1] = cF - Up * hHfar - right * hWfar; farPts[2] = cF - Up * hHfar + right * hWfar; farPts[3] = cF + Up * hHfar + right * hWfar; nearPts[0] = cN + Up * hHnear - right * hWnear; nearPts[1] = cN - Up * hHnear - right * hWnear; nearPts[2] = cN - Up * hHnear + right * hWnear; nearPts[3] = cN + Up * hHnear + right * hWnear; planes[0] = CPlane.FromPoints(nearPts[3], nearPts[0], farPts[0]); planes[1] = CPlane.FromPoints(nearPts[1], nearPts[2], farPts[2]); planes[2] = CPlane.FromPoints(nearPts[0], nearPts[1], farPts[1]); planes[3] = CPlane.FromPoints(nearPts[2], nearPts[3], farPts[2]); planes[4] = CPlane.FromPoints(nearPts[0], nearPts[3], nearPts[2]); planes[5] = CPlane.FromPoints(farPts[3], farPts[0], farPts[1]); }
public virtual void Rotate(double y, double p, double r) { yaw = Matrix4dExtension.DegreesToRadians(y); pitch = Matrix4dExtension.DegreesToRadians(p); roll = Matrix4dExtension.DegreesToRadians(r); Matrix4d rNew = yawPitchRoll(yaw, pitch, 0.0f); R = Matrix4d.Mult(R, rNew); Update(); }