void ChangeEyeOffset(EyePosition pos) { Vector2 offset = Vector2.zero; switch (pos) { case EyePosition.normal: offset = new Vector2(0, 0); break; case EyePosition.happy: offset = new Vector2(.33f, 0); break; case EyePosition.angry: offset = new Vector2(.66f, 0); break; case EyePosition.dead: offset = new Vector2(.33f, .66f); break; default: break; } for (int i = 0; i < characterMaterials.Length; i++) { if (characterMaterials[i].transform.CompareTag("PlayerEyes")) { characterMaterials[i].material.SetVector("_EyeOffset", offset); } } }
/// <summary> Pan to and zoom to target, time = 0 immediate, else time to slew in seconds</summary> public void PanZoomTo(Vector3 target, float zoom, float timeslewsec = 0) { Vector2 camera = EyePosition.AzEl(target, true); Pan(camera, timeslewsec); GoToZoom(zoom, timeslewsec); }
private void UpdateEyeData(string eyeName, EyePosition eyePosition, System.Windows.Shapes.Ellipse ellipse, StringBuilder sb) { // 0,0 is at the center of the screen // need to convert X & Y Eye positions from mm to pixels double eyePositionPixelX = (screenSize.Width / 2) + (eyePosition.X * conversionFactorX); double eyePositionPixelY = (screenSize.Height / 2) + verticalOffset - (eyePosition.Y * conversionFactorY); if (eyePosition.Z > 600.0 && eyePosition.Z < 700.00) { ellipse.Opacity = 1.0; } else if (eyePosition.Z > 500 && eyePosition.Z < 800.00) { ellipse.Opacity = 0.4; } else if (eyePosition.Z > 400 && eyePosition.Z < 900.00) { ellipse.Opacity = 0.2; } else { ellipse.Opacity = 0.1; } if (eyePosition.IsValid) { Canvas.SetLeft(ellipse, eyePositionPixelX); Canvas.SetTop(ellipse, eyePositionPixelY); ellipse.Visibility = Visibility.Visible; } else { ellipse.Visibility = Visibility.Collapsed; } sb.AppendLine($"{eyeName,7}EyePos ({eyePosition.X,6:F1}mm, {eyePosition.Y,6:F1}mm, {eyePosition.Z,6:F1}mm) - ({eyePositionPixelX,6:F1}, {eyePositionPixelY,6:F1})"); }
public void Update(Vector3 pos, Quaternion rot) { this.Rotation = Quaternion.Lerp(this.Rotation, rot, 0.1f); Vector3 campos = new Vector3(0, 0, -1f); campos = Vector3.Transform(campos, Matrix.CreateFromQuaternion(this.Rotation)); campos += pos; Vector3 camup = new Vector3(0, 1, 0); camup = Vector3.Transform(camup, Matrix.CreateFromQuaternion(this.Rotation)); this.Position = campos; this.UpDirection = camup; EyePosition = Vector3.Transform(pos - this.Position, Matrix.CreateRotationY(0)); EyePosition.Normalize(); this.ViewMatrix = Matrix.CreateLookAt(this.Position, pos, this.UpDirection); this.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4, this.AspectRatio, this.nearPlaneDistance, this.farPlaneDistance); }
void RandomFunc() { for (int i = 0; i < count; ++i) { // 算出每个粒子距离中心的半径,同时我们希望每个粒子集中在平均半径附近 float midRadius = (maxRadius + minRadius) / 2; float minRate = UnityEngine.Random.Range(1.0f, midRadius / minRadius); float maxRate = UnityEngine.Random.Range(midRadius / maxRadius, 1.0f); float radius = UnityEngine.Random.Range(minRadius * minRate, maxRadius * maxRate); //随机每个粒子的角度 float angle = UnityEngine.Random.Range(0.0f, 180.0f); float theta = angle / 180 * Mathf.PI; //随机每个粒子的游离起始时间 float time = UnityEngine.Random.Range(0.0f, 180.0f); circle[i] = new EyePosition(radius, angle, time); particleArr[i].position = new Vector3(circle[i].radius * Mathf.Cos(theta), 0f, circle[i].radius * Mathf.Sin(theta)); } particleSys.SetParticles(particleArr, particleArr.Length); }
public void receiveEyePosition(EyePosition leftEye, EyePosition rightEye) { if (!leftEye.IsValid && rightEye.IsValid) // LEFT BLINK { leftOpenCounter = 0; leftCloseCounter++; rightOpenCounter++; rightCloseCounter = 0; doubleOpenCounter = 0; doubleCloseCounter = 0; } else if (leftEye.IsValid && !rightEye.IsValid) // RIGHT BLINK { leftOpenCounter++; leftCloseCounter = 0; rightOpenCounter = 0; rightCloseCounter++; doubleOpenCounter = 0; doubleCloseCounter = 0; } else if (!leftEye.IsValid && !rightEye.IsValid) // DOUBLE BLINK { leftOpenCounter = 0; leftCloseCounter = 0; rightOpenCounter = 0; rightCloseCounter = 0; doubleOpenCounter = 0; doubleCloseCounter++; } else if (leftEye.IsValid && rightEye.IsValid) { leftOpenCounter++; leftCloseCounter = 0; rightOpenCounter++; rightCloseCounter = 0; doubleOpenCounter++; doubleCloseCounter = 0; } foreach (IBlinkerListener listener in Listeners) { if (listener != null) { if (leftOpenCounter == leftThreshold) { listener.receive_leftOpen(); } if (leftCloseCounter == leftThreshold) { listener.receive_leftClose(); } if (rightOpenCounter == rightThreshold) { listener.receive_rightOpen(); } if (rightCloseCounter == rightThreshold) { listener.receive_rightClose(); } if (doubleOpenCounter == doubleThreshold) { listener.receive_doubleOpen(); } if (doubleCloseCounter == doubleThreshold) { listener.receive_doubleClose(); } } } }
/// <summary> Pan to target, time = 0 immediate, else time to slew</summary> public void PanTo(Vector3d target, double timeslewsec = 0) { Vector2d camera = EyePosition.AzEl(target, true); Pan(camera, timeslewsec); }
public CommandEyePosition(EyePosition value) { _Value = value; }