private CameraOrientation getOppositeCameraOrientation(CameraOrientation co) { switch (co) { case CameraOrientation.Default: return(CameraOrientation.Lateral); case CameraOrientation.Lateral: return(CameraOrientation.Default); } Debug.Assert(false, "Incorrect camera orientation"); return(CameraOrientation.Default); }
public EventProcessor(IRenderWindow renderWindow, ILogger <EventProcessor> logger, CancellationTokenSource cancellationTokenManager, IAssertionProcessor scene) { _renderWindow = renderWindow; _logger = logger; _cancellationTokenManager = cancellationTokenManager; _scene = scene; _currentCameraOrientation = Constants.DefaultCameraOrientation; _logger.LogInformation("EventProcessor created"); }
public void LoadGlobals() { if (Globals.data.vertical) { orientation = CameraOrientation.Vertical; } else { orientation = CameraOrientation.Horizontal; } if (Globals.data.trackBall) { positioning = CameraPositioning.Ball; } else { positioning = CameraPositioning.Center; } }
void Start() { // Take current position as reference position for targeting // Camera should be pointing at 0, 0 at the start for proper calibration ReferencePosition = transform.position; Orientation = new CameraOrientation(); if (Target == null) { Debug.LogWarning("No target set for camera."); } }
IEnumerator ChangeCameraOrientation(int iterationCount) { float newX = GetNewX(); float newZ = GetNewZ(); currentOrientation = GetNextOrientation(); for (int i = 0; i < iterationCount; i++) { cameraOffset = cameraOffset + new Vector3(newX, 0, newZ); yield return(new WaitForSeconds(0.01f)); } }
public void AutosizeCamera(Camera cam, CameraOrientation orientation) { switch (orientation) { case CameraOrientation.DOWN: cam.transform.position = new Vector3(worldBounds.center.x, worldBounds.max.y + 1f, worldBounds.center.z); cam.orthographicSize = (worldBounds.extents.x > worldBounds.extents.z) ? worldBounds.extents.x : worldBounds.extents.z; break; case CameraOrientation.FORWARD: cam.transform.position = new Vector3(worldBounds.center.x, worldBounds.center.y, worldBounds.min.z - 1f); cam.orthographicSize = (worldBounds.extents.x > worldBounds.extents.y) ? worldBounds.extents.x : worldBounds.extents.y; break; } }
public void AutosizeCamera(Camera cam, CameraOrientation orientation) { switch(orientation) { case CameraOrientation.DOWN: cam.transform.position = new Vector3(worldBounds.center.x, worldBounds.max.y + 1f, worldBounds.center.z); cam.orthographicSize = (worldBounds.extents.x > worldBounds.extents.z) ? worldBounds.extents.x : worldBounds.extents.z; break; case CameraOrientation.FORWARD: cam.transform.position = new Vector3(worldBounds.center.x, worldBounds.center.y, worldBounds.min.z - 1f); cam.orthographicSize = (worldBounds.extents.x > worldBounds.extents.y) ? worldBounds.extents.x : worldBounds.extents.y; break; } }
/// <summary> /// Starts the camera /// </summary> /// <param name="selectedCamera">The selected camera, default: Back</param> public void Start(CameraSelection selectedCamera = CameraSelection.Back) { _cameraOrientation = Abstractions.CameraOrientation.Automatic; if (_selectedCamera == CameraSelection.None) { _selectedCamera = selectedCamera; } _isCameraStarted = true; if (_surface != null) { OpenCamera(_selectedCamera); } }
private void setCameraOrientation(CameraOrientation co) { switch (co) { case CameraOrientation.Default: { _cameraMovementScript.setDefaultCamera(); break; } case CameraOrientation.Lateral: { _cameraMovementScript.setLateralCamera(); break; } } }
public static AVCaptureVideoOrientation ToAVCaptureVideoOrientation(this CameraOrientation cameraOrientation) { switch (cameraOrientation) { case CameraOrientation.Rotation0: return(AVCaptureVideoOrientation.Portrait); case CameraOrientation.Rotation90: return(AVCaptureVideoOrientation.LandscapeRight); case CameraOrientation.Rotation180: return(AVCaptureVideoOrientation.PortraitUpsideDown); case CameraOrientation.Rotation270: return(AVCaptureVideoOrientation.LandscapeLeft); default: return(AVCaptureVideoOrientation.Portrait); } }
public void ResetCamera(CameraOrientation orientation) { Vector3 viewDirection; switch (orientation) { case CameraOrientation.Front: viewDirection = Vector3.UnitZ; break; case CameraOrientation.Back: viewDirection = -Vector3.UnitZ; break; case CameraOrientation.Top: viewDirection = -Vector3.UnitY; break; case CameraOrientation.Bottom: viewDirection = Vector3.UnitY; break; case CameraOrientation.Left: viewDirection = Vector3.UnitX; break; case CameraOrientation.Right: viewDirection = -Vector3.UnitX; break; default: throw new ArgumentOutOfRangeException(nameof(orientation)); } ResetCamera(viewDirection); }
private async Task ProcessUserEvent(UserInputStateEvent userInputEvent) { if (userInputEvent.MouseState.IsButtonDown(MouseButton.Button1) && !pickingInfoRequested) { await _scene.AssertionUpdatesChannel.Writer.WriteAsync(new AssertionBatch { Assertions = new IAssertion[] { new GetPickingInfo((int)userInputEvent.MouseState.X, (int)userInputEvent.MouseState.Y) } }); pickingInfoRequested = true; } // Escape = quit if (userInputEvent.KeyboardState.WasKeyDown(Keys.Escape)) { if (!exitCalled) { exitCalled = true; _renderWindow.Close(); } } // Take screenshot if (userInputEvent.KeyboardState.WasKeyDown(Keys.S)) { if (!screenshotEnqueued) { await _scene.AssertionUpdatesChannel.Writer.WriteAsync(new AssertionBatch { Assertions = new IAssertion[] { new GrabScreenshot() } }); screenshotEnqueued = true; } } // Move left & right bool hasLeft = userInputEvent.KeyboardState.IsKeyDown(Keys.Left); bool hasRight = userInputEvent.KeyboardState.IsKeyDown(Keys.Right); bool hasForward = userInputEvent.KeyboardState.IsKeyDown(Keys.Up); bool hasBackward = userInputEvent.KeyboardState.IsKeyDown(Keys.Down); // TODO: Cleanup if (hasLeft || hasRight || hasForward || hasBackward) { var dX = (hasLeft, hasRight) switch { (true, false) => 1.0f, (false, true) => - 1.0f, _ => 0.0f }; var dZ = (hasForward, hasBackward) switch { (true, false) => 1.0f, (false, true) => - 1.0f, _ => 0.0f }; // Left/Right dX *= (float)userInputEvent.TimeSinceLastEventSeconds; Vector3 moveVecLeftRight = new (-1, 0, 0); // we are looking in the negative z direction, therefore "right" is -1 moveVecLeftRight *= dX; // Forward/Backward dZ *= (float)userInputEvent.TimeSinceLastEventSeconds; Vector3 moveVecForwardBackward = new(0, 0, -1); // forward = -z moveVecForwardBackward *= dZ; Vector3 newLocation = _currentCameraOrientation.CameraLocation.ToOpenTkVec3() + moveVecLeftRight + moveVecForwardBackward; _currentCameraOrientation = _currentCameraOrientation with { CameraLocation = new (newLocation.X, newLocation.Y, newLocation.Z) }; await _scene.AssertionUpdatesChannel.Writer.WriteAsync(new AssertionBatch { Assertions = new IAssertion[] { _currentCameraOrientation } }); } }
public void OnGUI() { if (cam == null) { CreateCamera(); } GUILayout.Label("Heatmap Text Asset", EditorStyles.boldLabel); heatmapTextAsset = (TextAsset)EditorGUILayout.ObjectField(heatmapTextAsset, typeof(TextAsset), true); GUILayout.Space(2); GUILayout.Label("Camera Orientation", EditorStyles.boldLabel); cameraOrientation = (CameraOrientation)EditorGUILayout.EnumPopup(cameraOrientation); if (previousOrientation != cameraOrientation) { AutosizeCamera(cam, cameraOrientation); previousOrientation = cameraOrientation; } // Camera Utility if (cameraOrientation == CameraOrientation.MANUAL) { cam = (Camera)EditorGUILayout.ObjectField(cam, typeof(Camera), true); } else { if (cameraOrientation == CameraOrientation.FORWARD) { cam.transform.rotation = Quaternion.Euler(Vector3.zero); } if (cameraOrientation == CameraOrientation.DOWN) { cam.transform.rotation = Quaternion.Euler(new Vector3(90f, 0f, 0f)); } if (GUI.Button(new Rect(0, Screen.height - 22, Screen.width, 20), "Force Update World Bounds")) { worldBounds = GetWorldBounds(); } } pointRadius = EditorGUILayout.IntField("Point Radius", pointRadius); GUILayout.Label("cam - " + cam.name + ": " + cam.pixelWidth + ", " + cam.pixelHeight + "\nscreen: " + Screen.width + ", " + Screen.height); // Heatmap tools! if (GUILayout.Button("Refresh Heatmap")) { if (heatmapTextAsset == null) { Debug.LogWarning("No Heatmap log selected!"); return; } EditorApplication.ExecuteMenuItem("Window/Game"); heatmapOverlay = Heatmap.CreateHeatmap(StringUtility.Vector3ArrayWithFile(heatmapTextAsset), cam, pointRadius); } if (GUILayout.Button("Screenshot")) { Heatmap.Screenshot("Assets/ImAHeatmap.png", cam); } if (heatmapOverlay) { GUILayout.Label(heatmapOverlay); } }
// on first frame call public override void Start() { base.Start(); this.cameraOrientation = FindObjectOfType <CameraOrientation>(); this.flashPanel = FindObjectOfType <FlashPanel>(); }
/// <summary> /// Used to set a new camera orientation (Usefull if the map changes its rotation) /// Orientations can be NORT_WEST (used in the first demo) , SOUTH_WEST, SOUTH_EST, NORTH_EST /// </summary> /// <param name="newOrientation"></param> public void setCameraOrientation(CameraOrientation newOrientation) { float baseVerticalRotation = 45f; float verticalRotationOffset = 90f; float numOffsets = 0; switch (newOrientation) { case CameraOrientation.NORTH_WEST: cameraOffset = new Vector3(-141.554f, 140f, -141.554f) ; baseVerticalRotation = 45f; numOffsets = 0; break; case CameraOrientation.SOUTH_WEST: cameraOffset = new Vector3(-141.554f, 140f, +141.554f) ; numOffsets = 1; break; case CameraOrientation.SOUTH_EST: cameraOffset = new Vector3(+141.554f, 140f, +141.554f) ; numOffsets = 2; break; case CameraOrientation.NORTH_EST: cameraOffset = new Vector3(+141.554f, 140f, -141.554f) ; numOffsets = 3; break; default: break; } cameraContainer.transform.rotation = Quaternion.Euler(cameraContainer.transform.localRotation.eulerAngles.x, baseVerticalRotation + verticalRotationOffset * numOffsets, cameraContainer.transform.localEulerAngles.z); _camera_orientation = newOrientation; }
public void UpdateOrientation(CameraOrientation newOriewntation) { orientation = newOriewntation; }
public void OnGUI() { if(cam == null) CreateCamera(); GUILayout.Label("Heatmap Text Asset", EditorStyles.boldLabel); heatmapTextAsset = (TextAsset)EditorGUILayout.ObjectField(heatmapTextAsset, typeof(TextAsset), true); GUILayout.Space(2); GUILayout.Label("Camera Orientation", EditorStyles.boldLabel); cameraOrientation = (CameraOrientation)EditorGUILayout.EnumPopup(cameraOrientation); if(previousOrientation != cameraOrientation) { AutosizeCamera(cam, cameraOrientation); previousOrientation = cameraOrientation; } // Camera Utility if(cameraOrientation == CameraOrientation.MANUAL) { cam = (Camera)EditorGUILayout.ObjectField(cam, typeof(Camera), true); } else { if( cameraOrientation == CameraOrientation.FORWARD) cam.transform.rotation = Quaternion.Euler( Vector3.zero ); if( cameraOrientation == CameraOrientation.DOWN ) cam.transform.rotation = Quaternion.Euler( new Vector3(90f, 0f, 0f) ); if(GUI.Button(new Rect(0, Screen.height - 22, Screen.width, 20), "Force Update World Bounds")) worldBounds = GetWorldBounds(); } pointRadius = EditorGUILayout.IntField("Point Radius", pointRadius); GUILayout.Label("cam - " + cam.name + ": " + cam.pixelWidth + ", " + cam.pixelHeight + "\nscreen: " + Screen.width + ", " + Screen.height); // Heatmap tools! if(GUILayout.Button("Refresh Heatmap")) { if(heatmapTextAsset == null) { Debug.LogWarning("No Heatmap log selected!"); return; } EditorApplication.ExecuteMenuItem("Window/Game"); heatmapOverlay = Heatmap.CreateHeatmap(StringUtility.Vector3ArrayWithFile(heatmapTextAsset), cam, pointRadius); } if(GUILayout.Button("Screenshot")) Heatmap.Screenshot("Assets/ImAHeatmap.png", cam); if(heatmapOverlay) GUILayout.Label(heatmapOverlay); }
void IEditorGameCameraViewModelService.ResetCameraOrientation(CameraOrientation orientation) { Controller.InvokeAsync(() => ResetCamera(orientation)); }
public void OnEnable() { CreateCamera(); previousOrientation = cameraOrientation; worldBounds = GetWorldBounds(); AutosizeCamera(cam, cameraOrientation); }