protected override void Awake() { base.Awake(); controller = GetComponent <EntityController>(); viewDirection = startdirection; ChangeViewDirection(); }
private void ChangeViewDirection() { if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y)) { if (direction.x > 0.0f) { viewDirection = ViewDirection.right; } else if (direction.x < 0.0f) { viewDirection = ViewDirection.left; } } else { if (direction.y > 0.0f) { viewDirection = ViewDirection.up; } else if (direction.y < 0.0f) { viewDirection = ViewDirection.down; } } }
public static void ResolveTangents(Vector2 from, Vector2 to, ViewDirection direction, float curvature, out Vector2 fromTangent, out Vector2 toTangent) { switch (direction) { case ViewDirection.Vertical: var tangentY = Mathf.Abs(from.y - to.y) * curvature; tangentY = Mathf.Max(tangentY, 25); fromTangent = new Vector2(0, tangentY); toTangent = new Vector2(0, -tangentY); break; case ViewDirection.Horizontal: var tangentX = Mathf.Abs(from.x - to.x) * curvature; tangentX = Mathf.Max(tangentX, 25); fromTangent = new Vector2(tangentX, 0); toTangent = new Vector2(-tangentX, 0); break; default: fromTangent = default; toTangent = default; break; } }
public Viewport2D(ViewDirection direction) { Zoom = 1; Position = new Coordinate(0, 0, 0); Direction = direction; CenterScreen = new Coordinate(Width / 2m, Height / 2m, 0); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { int max = Settings.MaxSize; int y = (int)values[4]; int z = (int)values[5]; ViewDirection viewDirection = (ViewDirection)values[6]; bool fullSize = (bool)values[7]; int factor = fullSize ? Settings.LargeFactor : Settings.SmallFactor; bool fromSelection = (bool)values[8]; int selectId = (int)values[9]; bool isDragged = (bool)values[10]; if (fromSelection && !isDragged) { return((double)(max - 2 * selectId + 1) * factor); } switch (viewDirection) { case ViewDirection.TopView: return((double)(factor * y)); case ViewDirection.FrontView: case ViewDirection.BackView: case ViewDirection.LeftView: case ViewDirection.RightView: return((double)(factor * z)); default: return((double)(factor * y)); } }
public Viewport2D(ViewDirection direction, RenderContext context) : base(context) { Zoom = 1; Position = new Coordinate(0, 0, 0); Direction = direction; CenterScreen = new Coordinate(Width / 2m, Height / 2m, 0); }
private void ChangeViewDirection() { if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y)) { if (direction.x > 0.0f) { viewRange.transform.rotation = Quaternion.Euler(0, 0, 270); viewDirection = ViewDirection.right; } else if (direction.x < 0.0f) { viewRange.transform.rotation = Quaternion.Euler(0, 0, 90); viewDirection = ViewDirection.left; } } else { if (direction.y > 0.0f) { viewRange.transform.rotation = Quaternion.Euler(0, 0, 0); viewDirection = ViewDirection.up; } else if (direction.y < 0.0f) { viewRange.transform.rotation = Quaternion.Euler(0, 0, 180); viewDirection = ViewDirection.down; } } }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { Cuboid cuboid = (Cuboid)values[0]; ViewDirection viewDirection = (ViewDirection)values[1]; bool fullSize = (bool)values[2]; int factor = fullSize ? Settings.LargeFactor : Settings.SmallFactor; if (cuboid.FromSelection && !cuboid.IsDragged) { return(fullSize ? Settings.LargeFactor : 0.0); } switch (viewDirection) { case ViewDirection.TopView: case ViewDirection.FrontView: case ViewDirection.BackView: return((double)(factor * cuboid.Width)); case ViewDirection.LeftView: case ViewDirection.RightView: return((double)(factor * cuboid.Depth)); default: return((double)(factor * cuboid.Width)); } }
private void TurnAround() { switch (viewDirection) { case ViewDirection.up: viewRange.transform.rotation = Quaternion.Euler(0, 0, 180); viewDirection = ViewDirection.down; break; case ViewDirection.down: viewRange.transform.rotation = Quaternion.Euler(0, 0, 0); viewDirection = ViewDirection.up; break; case ViewDirection.right: viewRange.transform.rotation = Quaternion.Euler(0, 0, 90); viewDirection = ViewDirection.left; break; case ViewDirection.left: viewRange.transform.rotation = Quaternion.Euler(0, 0, 270); viewDirection = ViewDirection.right; break; default: break; } }
public BarShape11(Drawing drawing, Dimensions dimensions, ViewDirection viewDirection) { Drawing = drawing; Dimensions = dimensions; ViewDirection = viewDirection; Parts = new List <IFigure>(); }
public BarShape13(Drawing drawing, Dimensions dimensions, ViewDirection viewDirection, Point _insertPoint) { Drawing = drawing; Dimensions = dimensions; ViewDirection = viewDirection; Parts = new List <IFigure>(); DependencyPoints = new List <Point>(); }
/// <summary> /// Moves the camera to the midpoint of all the specified occurrences. Used in the wizard to point out the specified occurence. /// </summary> /// <param name="occurrences">The <see cref="ComponentOccurrence"/>s for the <see cref="Camera"/> to focus on</param> /// <param name="viewDistance">The distence from <paramref name="occurrence"/> that the camera will be</param> /// <param name="camera"></param> /// <param name="zoom"></param> /// <param name="viewDirection">The direction of the camera</param> /// <param name="animate">True if you want to animate the camera moving to the new position</param> public static void FocusCameraOnOccurrences(List <ComponentOccurrence> occurrences, double viewDistance, Camera camera, double zoom, ViewDirection viewDirection = ViewDirection.Y, bool animate = false) { if (occurrences.Count < 1) { return; } var translation = GetOccurrencesCenter(occurrences); SetCameraView(translation, viewDistance, camera, zoom, viewDirection, animate); }
private void rotateViewBasedOnVelocityAndUpdateViewDirection(Vector3 velocity) { if (velocity.sqrMagnitude > 0f && animator) { animator.SetBool("isMoving", true); } else if (velocity.sqrMagnitude <= 0f && animator) { animator.SetBool("isMoving", false); } float degreeAngleToDirection = Mathf.Atan2(velocity.y, velocity.x) * 180f / Mathf.PI; viewPivot.rotation = Quaternion.Euler(0, 0, degreeAngleToDirection); //update viewDirection variable if (degreeAngleToDirection < 0f) { degreeAngleToDirection += 360f; } else if (degreeAngleToDirection > 360f) { degreeAngleToDirection -= 360f; } if (degreeAngleToDirection < 45f || degreeAngleToDirection >= 315f) { viewDirection = ViewDirection.Right; } else if (degreeAngleToDirection < 135f && degreeAngleToDirection >= 45f) { viewDirection = ViewDirection.Up; } else if (degreeAngleToDirection < 225f && degreeAngleToDirection >= 135f) { viewDirection = ViewDirection.Left; } else if (degreeAngleToDirection < 315f && degreeAngleToDirection >= 225f) { viewDirection = ViewDirection.Down; } if (animator) { animator.SetInteger("View Direction", (int)viewDirection); } }
private static Coordinate GetUnusedCoordinate(Coordinate c, ViewDirection direction) { switch (direction) { case ViewDirection.Top: return(new Coordinate(0, 0, c.Z)); case ViewDirection.Front: return(new Coordinate(c.X, 0, 0)); case ViewDirection.Side: return(new Coordinate(0, c.Y, 0)); default: throw new ArgumentOutOfRangeException("direction"); } }
private static Matrix4 GetMatrixFor(ViewDirection dir) { switch (dir) { case ViewDirection.Top: return(TopMatrix); case ViewDirection.Front: return(FrontMatrix); case ViewDirection.Side: return(SideMatrix); default: throw new ArgumentOutOfRangeException("dir"); } }
private void View_Checked(object sender, RoutedEventArgs e) { try { if (!_isInitialized) { return; } if (radViewFront.IsChecked.Value) { _viewDirection = ViewDirection.Front; } else if (radViewRight.IsChecked.Value) { _viewDirection = ViewDirection.Right; } else if (radViewLeft.IsChecked.Value) { _viewDirection = ViewDirection.Left; } else if (radViewTop.IsChecked.Value) { _viewDirection = ViewDirection.Top; } else if (radViewBottom.IsChecked.Value) { _viewDirection = ViewDirection.Bottom; } else if (radViewBack.IsChecked.Value) { _viewDirection = ViewDirection.Back; } else { throw new ApplicationException("Unknown view direction"); } SetVelocityViewerCameraPosition(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), this.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
public static void ResetZIndexes(Canvas canvas, ViewDirection viewDirection) { foreach (UIElement child in canvas.Children) { int zIndex = 0; if (child is CuboidControl) { CuboidControl cuboidControl = child as CuboidControl; switch (viewDirection) { case ViewDirection.TopView: zIndex = cuboidControl.Cuboid.Z; break; case ViewDirection.FrontView: zIndex = Settings.MaxSize - cuboidControl.Cuboid.Y; break; case ViewDirection.BackView: zIndex = cuboidControl.Cuboid.Y; break; case ViewDirection.LeftView: zIndex = Settings.MaxSize - cuboidControl.Cuboid.X; break; case ViewDirection.RightView: zIndex = cuboidControl.Cuboid.X; break; } } else { zIndex = Settings.MaxSize + 1; } Canvas.SetZIndex(child, zIndex); } }
private void RotateViewDirection() { if (viewDirection == ViewDirection.Right) { viewDirection = ViewDirection.Up; } else if (viewDirection == ViewDirection.Up) { viewDirection = ViewDirection.Left; } else if (viewDirection == ViewDirection.Left) { viewDirection = ViewDirection.Down; } else //(viewDirection == ViewDirection.Down) { viewDirection = ViewDirection.Right; } if (animator) { animator.SetInteger("View Direction", (int)viewDirection); } }
private void rightRotation_Tapped(object sender, TappedRoutedEventArgs e) { UserViewDirection = (ViewDirection)Mod((int)UserViewDirection + 1, 4); ChangeDirections(); }
// Update is called once per frame void Update() { float hAxis = Input.GetAxis("Horizontal"); float vAxis = Input.GetAxis("Vertical"); if (hAxis != 0) { if (hAxis < -0.1f && viewRef == ViewDirection.right){ viewRef = ViewDirection.left; //enemiesList = new List<GameObject>(); Debug.Log("looking for left side enemies"); //areaTargetRef.localScale = new Vector2(-1f, 1f); actualTarget = GetClosestEnemy(enemiesList); } if (hAxis > 0.1f && viewRef == ViewDirection.left) { viewRef = ViewDirection.right; Debug.Log("looking for right side enemies"); //enemiesList = new List<GameObject>(); //areaTargetRef.localScale = new Vector2(1f, 1f); } actualTarget = GetClosestEnemy(enemiesList); if (actualTarget != null) { targetName = actualTarget.GetComponent<EnemyScript>().eName; } } if (Input.GetButtonDown("Jump")) { FindObjectOfType<PlayerMovement>().spelling_flag = true; } else if (Input.GetButtonUp("Jump")){ FindObjectOfType<PlayerMovement>().spelling_flag = false; } }
private static void DrawField(WriteableBitmap bitmap, FluidField3D field, ViewDirection viewDirection, byte[] colorZFront, byte[] colorZBack) { Int32Rect rect = new Int32Rect(0, 0, field.Size, field.Size); int size = rect.Width * rect.Height * 4; byte[] pixels = new byte[size]; double[] ink = field.Ink; bool[] blocked = field.Blocked; switch (viewDirection) { case ViewDirection.Front: #region Front DrawFieldSprtDoIt(pixels, ink, blocked, field.Size, colorZFront, colorZBack, new AxisFor(Axis.X, 0, field.Size - 1), new AxisFor(Axis.Y, 0, field.Size - 1), new AxisFor(Axis.Z, field.Size - 1, 0)); // pixel z needs to start at the back, because the colors are overlaid #endregion break; case ViewDirection.Right: #region Right DrawFieldSprtDoIt(pixels, ink, blocked, field.Size, colorZFront, colorZBack, new AxisFor(Axis.Z, 0, field.Size - 1), new AxisFor(Axis.Y, 0, field.Size - 1), new AxisFor(Axis.X, 0, field.Size - 1)); #endregion break; case ViewDirection.Left: #region Left DrawFieldSprtDoIt(pixels, ink, blocked, field.Size, colorZFront, colorZBack, new AxisFor(Axis.Z, field.Size - 1, 0), new AxisFor(Axis.Y, 0, field.Size - 1), new AxisFor(Axis.X, field.Size - 1, 0)); #endregion break; case ViewDirection.Top: #region Top DrawFieldSprtDoIt(pixels, ink, blocked, field.Size, colorZFront, colorZBack, new AxisFor(Axis.X, 0, field.Size - 1), new AxisFor(Axis.Z, field.Size - 1, 0), new AxisFor(Axis.Y, field.Size - 1, 0)); #endregion break; case ViewDirection.Bottom: #region Bottom DrawFieldSprtDoIt(pixels, ink, blocked, field.Size, colorZFront, colorZBack, new AxisFor(Axis.X, 0, field.Size - 1), new AxisFor(Axis.Z, 0, field.Size - 1), new AxisFor(Axis.Y, 0, field.Size - 1)); #endregion break; case ViewDirection.Back: #region Back //NOTE: This one is up for interpretation. I will rotate left to right, because I think that is more intuitive. If rotating //top to bottom, it would be upside down from the way I am presenting DrawFieldSprtDoIt(pixels, ink, blocked, field.Size, colorZFront, colorZBack, new AxisFor(Axis.X, field.Size - 1, 0), new AxisFor(Axis.Y, 0, field.Size - 1), new AxisFor(Axis.Z, 0, field.Size - 1)); // The alternate //DrawField_DoIt(pixels, ink, blocked, field.Size, colorZFront, colorZBack, // new AxisFor(Axis.X, 0, field.Size - 1), // new AxisFor(Axis.Y, field.Size - 1, 0), // new AxisFor(Axis.Z, 0, field.Size - 1)); #endregion break; default: throw new ApplicationException("Unknown ViewDirection: " + viewDirection.ToString()); } bitmap.WritePixels(rect, pixels, rect.Width * 4, 0); }
/// <summary> /// Sets the camera view direction. /// </summary> public void SetViewDirection(ViewDirection direction) { lastDirection = direction; GetDirectionVectors(direction, out _center, out _position, out _upVec); RecomputeUpVector(); // _scene.Resize(); _scene.OnDirectionChanged(); }
/// <summary> /// Sets the position and target of the camera. /// </summary> /// <param name="focus">Point that camera should look at.</param> /// <param name="viewDistance">Distance the camera should be from that point</param> /// <param name="camera"></param> /// <param name="zoom"></param> /// <param name="viewDirection">Direction to view the point from.</param> /// <param name="animate">True to animate movement of camera.</param> public static void SetCameraView(Vector focus, double viewDistance, double width, double height, Camera camera, ViewDirection viewDirection = ViewDirection.Y, bool animate = true) { Point focusPoint = RobotExporterAddInServer.Instance.Application.TransientGeometry.CreatePoint(focus.X, focus.Y, focus.Z); camera.SetExtents(width, height); camera.Target = focusPoint; // Flip view for negative direction if ((viewDirection & ViewDirection.Negative) == ViewDirection.Negative) { viewDistance = -viewDistance; } UnitVector up = null; // Find camera position and upwards direction if ((viewDirection & ViewDirection.X) == ViewDirection.X) { focus.X += viewDistance; up = RobotExporterAddInServer.Instance.Application.TransientGeometry.CreateUnitVector(0, 1, 0); } if ((viewDirection & ViewDirection.Y) == ViewDirection.Y) { focus.Y += viewDistance; up = RobotExporterAddInServer.Instance.Application.TransientGeometry.CreateUnitVector(0, 0, 1); } if ((viewDirection & ViewDirection.Z) == ViewDirection.Z) { focus.Z += viewDistance; up = RobotExporterAddInServer.Instance.Application.TransientGeometry.CreateUnitVector(0, 1, 0); } camera.Eye = RobotExporterAddInServer.Instance.Application.TransientGeometry.CreatePoint(focus.X, focus.Y, focus.Z); camera.UpVector = up; // Apply settings if (animate) { camera.Apply(); } else { camera.ApplyWithoutTransition(); } }
private static Coordinate ZeroUnusedCoordinate(Coordinate c, ViewDirection direction) { switch (direction) { case ViewDirection.Top: return new Coordinate(c.X, c.Y, 0); case ViewDirection.Front: return new Coordinate(0, c.Y, c.Z); case ViewDirection.Side: return new Coordinate(c.X, 0, c.Z); default: throw new ArgumentOutOfRangeException("direction"); } }
private static Matrix4 GetMatrixFor(ViewDirection dir) { switch (dir) { case ViewDirection.Top: return TopMatrix; case ViewDirection.Front: return FrontMatrix; case ViewDirection.Side: return SideMatrix; default: throw new ArgumentOutOfRangeException("dir"); } }
// Update is called once per frame void Update() { // /*for debugging fieldOfView // * will delete when testing is done // */ // Vector3 mousePosition = Input.mousePosition; // Vector3 mousePositionInWorld = Camera.main.ScreenToWorldPoint(mousePosition); // Vector3 directionFromPlayerToMouse = mousePositionInWorld - transform.position; // float radiansToMouse = Mathf.Atan2(directionFromPlayerToMouse.y, directionFromPlayerToMouse.x); // float angleToMouse = radiansToMouse * 180f / Mathf.PI; // fieldOfView.setDirection(angleToMouse); // fieldOfView.setOrigin(transform.position); if (animator) { animator.SetBool("isMoving", false); animator.SetInteger("Role", (int)role); animator.SetInteger("View Direction", (int)viewDirection); } //directional movement with a-s-d-w Vector3 deltaVect = new Vector3(0, 0, 0); if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { Vector3 tempVect = new Vector3(-1, 0, 0); deltaVect += tempVect.normalized * SPEED * Time.deltaTime; viewDirection = ViewDirection.Left; if (animator) { animator.SetBool("isMoving", true); animator.SetInteger("View Direction", (int)viewDirection); } } if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) { Vector3 tempVect = new Vector3(1, 0, 0); tempVect = tempVect.normalized * SPEED * Time.deltaTime; deltaVect += tempVect.normalized * SPEED * Time.deltaTime; viewDirection = ViewDirection.Right; if (animator) { animator.SetBool("isMoving", true); animator.SetInteger("View Direction", (int)viewDirection); } } if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) { Vector3 tempVect = new Vector3(0, 1, 0); tempVect = tempVect.normalized * SPEED * Time.deltaTime; deltaVect += tempVect.normalized * SPEED * Time.deltaTime; viewDirection = ViewDirection.Up; if (animator) { animator.SetBool("isMoving", true); animator.SetInteger("View Direction", (int)viewDirection); } } if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) { Vector3 tempVect = new Vector3(0, -1, 0); tempVect = tempVect.normalized * SPEED * Time.deltaTime; deltaVect += tempVect.normalized * SPEED * Time.deltaTime; viewDirection = ViewDirection.Down; if (animator) { animator.SetBool("isMoving", true); animator.SetInteger("View Direction", (int)viewDirection); } } rb.MovePosition(transform.position + deltaVect); if (npcsInRange.Count != 0) { findClosestRole(); } else { closestRole = Role.Player; } //change player sprites to fit colors //can take out some colors or add refresh time if (Input.GetKeyDown(KeyCode.Space)) { //sr.sprite = getSprite(closestRole); if (npcsInRange.Count != 0 && closestRole != role) { updateRoleAndSprite(); canChangeRole = false; ChangeRoleEvent.Invoke(); } } if (GameComplete) { viewDirection = ViewDirection.Down; animator.SetBool("isMoving", false); animator.SetInteger("View Direction", (int)viewDirection); transform.position = Vector3.zero; } }
/// <summary> /// Sets the position and target of the camera. /// </summary> /// <param name="focus">Point that camera should look at.</param> /// <param name="viewDistance">Distance the camera should be from that point</param> /// <param name="camera"></param> /// <param name="zoom"></param> /// <param name="viewDirection">Direction to view the point from.</param> /// <param name="animate">True to animate movement of camera.</param> public static void SetCameraView(Vector focus, double viewDistance, Camera camera, double zoom, ViewDirection viewDirection = ViewDirection.Y, bool animate = true) { camera.Fit(); // TODO: Determine model size properly camera.GetExtents(out var width, out var height); SetCameraView(focus, viewDistance, height * zoom, height * zoom, camera, viewDirection, animate); }
/// <summary> /// Animates to the given view direction. /// </summary> /// <param name="direction"></param> public void AnimateTo(ViewDirection direction) { Vector center, position, upVec; GetDirectionVectors(direction, out center, out position, out upVec); AnimateTo(center, position, upVec); lastDirection = direction; }
/// <summary> /// Gets the view vectors for the given view position. /// </summary> /// <param name="direction"> A <see cref="ViewDirection"/>./ </param> /// <param name="centerOut"> The center. </param> /// <param name="posOut"> The position. </param> /// <param name="upVecOut"> The up vector. </param> public void GetDirectionVectors(ViewDirection direction, out Vector centerOut, out Vector posOut, out Vector upVecOut) { // _scene.RenderList.ResetBounds(); Bounds bounds = _scene.RenderList.Bounds; // determine the distance needed to view all renderables double dist = 0; if (_scene.RenderList.ActorCount > 0 && bounds.IsSet) { dist = bounds.MaxWidth / (fov * 0.5).Tan(); centerOut = bounds.Center; } else { dist = 1 / (fov * 0.5).Tan(); centerOut = new Vector(); } Vector travel; switch (direction) { case ViewDirection.Front: travel = new Vector(0, -1, 0); upVecOut = new Vector(0, 0, 1); break; case ViewDirection.Back: travel = new Vector(0, 1, 0); upVecOut = new Vector(0, 0, 1); break; case ViewDirection.Left: travel = new Vector(-1, 0, 0); upVecOut = new Vector(0, 0, 1); break; case ViewDirection.Right: travel = new Vector(1, 0, 0); upVecOut = new Vector(0, 0, 1); break; case ViewDirection.Top: travel = new Vector(0, 0, 1); upVecOut = new Vector(0, 1, 0); break; case ViewDirection.Bottom: travel = new Vector(0, 0, -1); upVecOut = new Vector(0, 1, 0); break; default: travel = new Vector(1, -1, 0.5); travel.Normalize(); dist = 0.8 * dist; upVecOut = new Vector(0, 0, 1); break; } posOut = (travel * dist) + centerOut; }
/// <summary> /// This takes the click point, and returns a point from 0 to 1 /// </summary> private static Point3D GetScaledPoint(MouseEventArgs e, FrameworkElement relativeTo, double depth, ViewDirection direction) { Point clickPoint = e.GetPosition(relativeTo); double width = relativeTo.ActualWidth; double height = relativeTo.ActualHeight; if (Math1D.IsNearZero(width) || Math1D.IsNearZero(height)) { // The window has no size return new Point3D(0, 0, 0); } Point3D point = new Point3D(clickPoint.X / width, clickPoint.Y / height, depth); switch (direction) { case ViewDirection.Front: return new Point3D(point.X, point.Y, point.Z); case ViewDirection.Right: return new Point3D(1d - point.Z, point.Y, point.X); case ViewDirection.Left: return new Point3D(point.Z, point.Y, 1d - point.X); case ViewDirection.Top: return new Point3D(point.X, point.Z, 1d - point.Y); case ViewDirection.Bottom: return new Point3D(point.X, 1d - point.Z, point.Y); case ViewDirection.Back: return new Point3D(1d - point.X, point.Y, 1d - point.Z); default: throw new ApplicationException("Unknown ViewDirection: " + direction.ToString()); } }
/// <summary> /// This takes the click point, and returns a point from 0 to 1 /// </summary> private static Point3D GetScaledPoint(MouseEventArgs e, FrameworkElement relativeTo, double depth, ViewDirection direction) { Point clickPoint = e.GetPosition(relativeTo); double width = relativeTo.ActualWidth; double height = relativeTo.ActualHeight; if (Math1D.IsNearZero(width) || Math1D.IsNearZero(height)) { // The window has no size return(new Point3D(0, 0, 0)); } Point3D point = new Point3D(clickPoint.X / width, clickPoint.Y / height, depth); switch (direction) { case ViewDirection.Front: return(new Point3D(point.X, point.Y, point.Z)); case ViewDirection.Right: return(new Point3D(1d - point.Z, point.Y, point.X)); case ViewDirection.Left: return(new Point3D(point.Z, point.Y, 1d - point.X)); case ViewDirection.Top: return(new Point3D(point.X, point.Z, 1d - point.Y)); case ViewDirection.Bottom: return(new Point3D(point.X, 1d - point.Z, point.Y)); case ViewDirection.Back: return(new Point3D(1d - point.X, point.Y, 1d - point.Z)); default: throw new ApplicationException("Unknown ViewDirection: " + direction.ToString()); } }
void Update() { if (IngameHandlerBehaviour.Instance.Handler.ActiveTimeLayer != TimeLayer.First) { return; } if (drawDebug) { Debug.DrawLine(new Vector3(cam.transform.position.x - border, transform.position.y + 2, transform.position.z), new Vector3(cam.transform.position.x - border, transform.position.y - 2, transform.position.z)); Debug.DrawLine(new Vector3(cam.transform.position.x + border, transform.position.y + 2, transform.position.z), new Vector3(cam.transform.position.x + border, transform.position.y - 2, transform.position.z)); } if (oldViewDirection != viewDirection) { datRunningVar = 0; viewChanged = true; oldViewDirection = viewDirection; } float lerpedCameraX = 0; if (viewChanged && viewDirection == ViewDirection.LEFT) { datRunningVar += cameraChangeSpeed * Time.deltaTime; lerpedCameraX = Mathf.Lerp(cam.transform.position.x, transform.position.x + border, datRunningVar); if (datRunningVar >= 1) { datRunningVar = 0; viewChanged = false; } } else if (viewChanged && viewDirection == ViewDirection.RIGHT) { datRunningVar += cameraChangeSpeed * Time.deltaTime; lerpedCameraX = Mathf.Lerp(cam.transform.position.x, transform.position.x - border, datRunningVar); if (datRunningVar >= 1) { datRunningVar = 0; viewChanged = false; } } else { if (viewDirection == ViewDirection.LEFT) { lerpedCameraX = transform.position.x + border; } else { lerpedCameraX = transform.position.x - border; } } oldViewDirection = viewDirection; cam.transform.position = new Vector3(lerpedCameraX, transform.position.y, cam.transform.position.z); }