protected virtual void CalculateBoundingBox(CalculateBoundingBoxEventArgs e) { OculusTracking.StartTracking(RhinoDocument.ActiveDoc); Viewports.UpdateEyeViewports(OculusTracking.CamLoc, OculusTracking.CamDir, OculusTracking.CamUp); this._mirrorClosed = Viewports.UpdateMirrorViewport(OculusTracking.CamLoc, OculusTracking.CamDir, OculusTracking.CamUp); base.CalculateBoundingBox(e); }
public static void MiniViewportsActive() { if (UserInput._controller.isConnected) { UserInput._controller.GetStateOfXController(); UserInput.SpeedParameter(); if (UserInput._controller.A_Keydown()) { if (!UserInput._miniViewportsOn) { if (Viewports.RiftViews[2] != null && Viewports.RiftViews[2].Document != null) { Viewports.CreateMiniViewports(); UserInput._target = Viewports.MiniViews[2].MainViewport.CameraTarget; UserInput._location = Viewports.MiniViews[2].MainViewport.CameraLocation; UserInput._cameraX = Viewports.MiniViews[2].MainViewport.CameraX; UserInput._cameraY = Viewports.MiniViews[2].MainViewport.CameraY; UserInput._miniViewportsOn = true; UserInput._controller.SetVibration(true, true, 400); // ISSUE: explicit reference operation UserInput._scaleFactor = Math.PI / 2.0 / ((Point3d)@UserInput._location).DistanceTo(UserInput._target); } else { UserInput._controller.SetVibration(false, true, 1000); } } else { Viewports.CloseMiniViewports(); UserInput._miniViewportsOn = false; UserInput._controller.SetVibration(true, true, 400); } } if (UserInput._miniViewportsOn) { float leftThumbX; if (UserInput._controller.LeftThumbX_Active(out leftThumbX)) { Transform transform = Transform.Rotation((double)leftThumbX * UserInput._norm2 * (double)UserInput._speedX1 * (double)UserInput._speedX2, new Vector3d(0.0, 0.0, 1.0), UserInput._target); (UserInput._location).Transform(transform); (UserInput._cameraX).Transform(transform); (UserInput._cameraY).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); Viewports.MiniViews[2].MainViewport.CameraUp = UserInput._cameraY; } float leftThumbY; if (UserInput._controller.LeftThumbY_Active(out leftThumbY)) { Transform transform = Transform.Rotation((double)leftThumbY * UserInput._norm2 * (double)UserInput._speedX1 * (double)UserInput._speedX2, -(UserInput._cameraX), UserInput._target); (UserInput._location).Transform(transform); (UserInput._cameraX).Transform(transform); (UserInput._cameraY).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); Viewports.MiniViews[2].MainViewport.CameraUp = UserInput._cameraY; } float rightThumbX; if (UserInput._controller.RightThumbX_Active(out rightThumbX)) { Transform transform = Transform.Translation(Vector3d.Multiply(Vector3d.Multiply(Vector3d.Multiply(UserInput._cameraX, (double)rightThumbX), (double)UserInput._speedX1), (double)UserInput._speedX2)); (UserInput._target).Transform(transform); (UserInput._location).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); } float rightThumbY; if (UserInput._controller.RightThumbY_Active(out rightThumbY)) { Transform transform = Transform.Translation(Vector3d.Multiply(Vector3d.Multiply(Vector3d.Multiply(UserInput._cameraY, (double)rightThumbY), (double)UserInput._speedX1), (double)UserInput._speedX2)); (UserInput._target).Transform(transform); (UserInput._location).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); } if (UserInput._controller.DPadUp_KeyOn()) { double a = Math.Atan(UserInput._scaleFactor * (UserInput._location).DistanceTo(UserInput._target)) * 2.0; Transform transform = Transform.Scale(UserInput._target, 1.0 - Math.Sin(a) * UserInput._norm2 * (double)UserInput._speedX1 * (double)UserInput._speedX2); (UserInput._location).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); } if (UserInput._controller.DPadDown_KeyOn()) { double a = Math.Atan(UserInput._scaleFactor * (UserInput._location).DistanceTo(UserInput._target)) * 2.0; Transform transform = Transform.Scale(UserInput._target, Math.Sin(a) * UserInput._norm2 * (double)UserInput._speedX1 * (double)UserInput._speedX2 + 1.0); (UserInput._location).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); } if (UserInput._controller.DPadLeft_KeyOn()) { Transform transform = Transform.Translation(Vector3d.Multiply(Vector3d.Multiply(Vector3d.Multiply(UserInput._cameraX, -0.5), (double)UserInput._speedX1), (double)UserInput._speedX2)); (UserInput._target).Transform(transform); (UserInput._location).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); } if (UserInput._controller.DPadRight_KeyOn()) { Transform transform = Transform.Translation(Vector3d.Multiply(Vector3d.Multiply(Vector3d.Multiply(UserInput._cameraX, 0.5), (double)UserInput._speedX1), (double)UserInput._speedX2)); (UserInput._target).Transform(transform); (UserInput._location).Transform(transform); Viewports.MiniViews[2].MainViewport.SetCameraLocations(UserInput._target, UserInput._location); } } UserInput._controller.Vibration_Active(); } Viewports.UpdateMiniViewports(); }