public Bounds GetWorldBounds(IUsesCameraOffset cameraOffset, float minBound) { var worldPose = cameraOffset.ApplyOffsetToPose(pose); var worldCenter = worldPose.position + worldPose.rotation * center; var size = new Vector3(extents.x * 0.5f, 0, extents.y * 0.5f); k_Corners[0] = size; size.x *= -1; k_Corners[1] = size; var rotation = pose.rotation; var position = pose.position + rotation * center; size = Vector3.zero; foreach (var corner in k_Corners) { // Get corner position in plane space var localVertex = rotation * corner + position; // Get corner position in session space localVertex = cameraOffset.ApplyOffsetToPosition(localVertex) - worldCenter; var val = localVertex.x; var absVal = val > 0 ? val : -val; if (absVal > size.x) { size.x = absVal; } val = localVertex.y; absVal = val > 0 ? val : -val; if (absVal > size.y) { size.y = absVal; } val = localVertex.z; absVal = val > 0 ? val : -val; if (absVal > size.z) { size.z = absVal; } } size *= 2; if (size.x < minBound) { size.x = minBound; } if (size.y < minBound) { size.y = minBound; } if (size.z < minBound) { size.z = minBound; } return(new Bounds(worldCenter, size)); }
public static Vector3 PoseToCameraSpace(this IUsesCameraOffset obj, Pose pose, Vector3 point) { return(obj.ApplyOffsetToPosition(pose.ApplyOffsetTo(point))); }
/// <summary> /// Get the matrix that applies the camera offset transformation /// </summary> /// <returns>The camera offset matrix</returns> public static Matrix4x4 GetCameraOffsetMatrix(this IUsesCameraOffset obj) { return(obj.provider.CameraOffsetMatrix); }
/// <summary> /// Apply the inverse of the camera offset to a pose and return the modified pose /// </summary> /// <param name="pose">The pose to which the offset will be applied</param> /// <returns>The modified pose</returns> public static Pose ApplyInverseOffsetToPose(this IUsesCameraOffset obj, Pose pose) { return(obj.provider.ApplyInverseOffsetToPose(pose)); }
/// <summary> /// Get the camera scale /// </summary> /// <returns>The camera scale</returns> public static float GetCameraScale(this IUsesCameraOffset obj) { return(obj.provider.cameraScale); }
/// <summary> /// Set the camera scale /// </summary> /// <param name="scale">The camera scale</param> public static void SetCameraScale(this IUsesCameraOffset obj, float scale) { obj.provider.cameraScale = scale; }
/// <summary> /// Get the camera yaw offset /// </summary> /// <returns>The camera yaw offset</returns> public static float GetCameraYawOffset(this IUsesCameraOffset obj) { return(obj.provider.cameraYawOffset); }
/// <summary> /// Set the camera yaw offset /// </summary> /// <param name="offset">The yaw offset</param> public static void SetCameraYawOffset(this IUsesCameraOffset obj, float offset) { obj.provider.cameraYawOffset = offset; }
/// <summary> /// Set the camera position offset /// </summary> /// <param name="offset">The camera position offset</param> public static void SetCameraPositionOffset(this IUsesCameraOffset obj, Vector3 offset) { obj.provider.cameraPositionOffset = offset; }
/// <summary> /// Get the camera position offset /// </summary> /// <returns>The camera position offset</returns> public static Vector3 GetCameraPositionOffset(this IUsesCameraOffset obj) { return(obj.provider.cameraPositionOffset); }
/// <summary> /// Apply the inverse of the camera offset to a rotation and return the modified rotation /// </summary> /// <param name="rotation">The rotation to which the offset will be applied</param> /// <returns>The modified rotation</returns> public static Quaternion ApplyInverseOffsetToRotation(this IUsesCameraOffset obj, Quaternion rotation) { return(obj.provider.ApplyInverseOffsetToRotation(rotation)); }
/// <summary> /// Apply the inverse of the camera offset to a direction and return the modified direction. /// This is not affected by scale or position. /// </summary> /// <param name="direction">The direction to which the offset will be applied</param> /// <returns>The modified direction</returns> public static Vector3 ApplyInverseOffsetToDirection(this IUsesCameraOffset obj, Vector3 direction) { return(obj.provider.ApplyInverseOffsetToDirection(direction)); }
/// <summary> /// Apply the camera offset to a position and return the modified position /// </summary> /// <param name="position">The position to which the offset will be applied</param> /// <returns>The modified position</returns> public static Vector3 ApplyOffsetToPosition(this IUsesCameraOffset obj, Vector3 position) { return(obj.provider.ApplyOffsetToPosition(position)); }