private void UnsubscribeCameraChanges() { if (_subscribedCamera == null) { return; } UnsubscribeViewportSizeChanged(); _subscribedCamera.CameraChanged -= CameraOnCameraChanged; _subscribedCamera = null; }
// When camera or Viewport3D size is changed we need to update the axis private void SubscribeCameraChanges() { if (_subscribedCamera != null) { if (_subscribedCamera == Camera) { return; } UnsubscribeCameraChanges(); } if (Camera != null) { Camera.CameraChanged += CameraOnCameraChanged; _subscribedCamera = Camera; SubscribeViewportSizeChanged(); } }
private Ab3d.Cameras.BaseCamera GetSelectedCamera() { Ab3d.Cameras.BaseCamera selectedCamera = null; if ((SceneCameraRadioButton.IsChecked ?? false) || (SideSceneCameraRadioButton.IsChecked ?? false) || (CannonCameraRadioButton.IsChecked ?? false)) { selectedCamera = Camera1; } else if (FirstPersonCameraRadioButton.IsChecked ?? false) { selectedCamera = FirstPersonCamera1; } else if (ThirdPersonCameraRadioButton.IsChecked ?? false) { selectedCamera = ThirdPersonCameraCamera1; } return(selectedCamera); }
public static SharpDX.Size2 GetPositionsSizeOnScreen(Point3DCollection positions, Transform3D transform, Ab3d.Cameras.BaseCamera camera) { double minX = double.MaxValue; double maxX = double.MinValue; double minY = double.MaxValue; double maxY = double.MinValue; var positionsCount = positions.Count; bool useTransform = transform != null && !transform.Value.IsIdentity; for (int i = 0; i < positionsCount; i++) { var onePoint = positions[i]; if (useTransform) { onePoint = transform.Transform(onePoint); } var pointOnScreen = camera.Point3DTo2D(onePoint); if (pointOnScreen.X < minX) { minX = pointOnScreen.X; } if (pointOnScreen.X > maxX) { maxX = pointOnScreen.X; } if (pointOnScreen.Y < minY) { minY = pointOnScreen.Y; } if (pointOnScreen.Y > maxY) { maxY = pointOnScreen.Y; } } var sizeOnScreen = new SharpDX.Size2((int)(maxX - minX), (int)(maxY - minY)); return(sizeOnScreen); }