Vector3 Camera::ScreenToWorldPoint(const Vector3& screenPos) const { Ray ray = GetScreenRay(screenPos.x_, screenPos.y_); Vector3 viewSpaceDir = (GetView() * Vector4(ray.direction_, 0.0f)); float rayDistance = (Max(screenPos.z_ - GetNearClip(), 0.0f) / viewSpaceDir.z_); return ray.origin_ + ray.direction_ * rayDistance; }
Vector3 Camera::ScreenToWorldPoint(const Vector3& screenPos) const { Ray ray = GetScreenRay(screenPos.x_, screenPos.y_); return ray.origin_ + ray.direction_ * screenPos.z_; }