void Start() { _t = transform; crt = (Creature)_t.parent.parent.gameObject.GetComponent("Creature"); eye = crt.eye.GetComponent<Eye>(); lr = (LineRenderer)gameObject.AddComponent<LineRenderer>(); lr.material.color = Color.green; lr.material.shader = Shader.Find("Sprites/Default"); lr.SetWidth(line_width, line_width); lr.SetVertexCount(2); lr.GetComponent<Renderer>().enabled = true; }
// Update is called once per frame void Update() { float horizontal = Input.GetAxis(m_Horizontal); float vertical = Input.GetAxis(m_Vertical); bool trigger = (Input.GetAxis(m_Trigger) > 0.1f || Input.GetButton(m_AltTrigger)); //Check if the player is idle if (vertical != 0 || trigger) { m_IdleTimeoutRemaining = m_IdleTimeout; } else { m_IdleTimeoutRemaining -= Time.deltaTime; } if(!m_TargetEye && m_IdleTimeoutRemaining > 0.0f) { // OPEN The player is not idle, find an eye to use m_TargetEye = m_PlayerManager.GetEye(); m_TargetEye.transform.parent = transform; m_TargetEye.SetColor(m_Colour); m_TargetEye.Open(); } else if (m_TargetEye && !m_TargetEye.isClosing && m_IdleTimeoutRemaining <= 0) { // START CLOSING The player is idle, close and release the eye m_TargetEye.Close(); } else if (m_TargetEye && m_TargetEye.isClosing && m_IdleTimeoutRemaining > 0.0f) { // INTERRUPT CLOSING if the eye is closing and the player provides input, cancel the close m_TargetEye.Open(); } else if (m_TargetEye && m_TargetEye.isClosed) { // REMOVE EYE if the eye is finished closing, clean it up m_PlayerManager.ReturnEye( m_TargetEye ); m_TargetEye = null; } if (m_TargetEye) { m_TargetEye.SetInput(horizontal, vertical); if (trigger) { m_TargetEye.Fire(); } } }
public void CanDoBothRotateAndScale() { var leftEye = new Eye { X = 2, Y = 2 }; var rightEye = new Eye { X = (float)(2 + 4 * Math.Cos(Math.PI / 6)), Y = (float)(2 + 4 * Math.Sin(Math.PI / 6)) }; var transformation = Transformation.Construct(leftEye: leftEye, rightEye: rightEye, width: 10); Expect.FloatEquals(Math.PI / 6, transformation.Angle); Expect.FloatEquals(2.5, transformation.Scale); Assert.AreEqual(new PointF(2, 2), transformation.Center); }
void Awake() { activator = GetComponentInChildren<Activator>(); eye = GetComponentInChildren<Eye>(); inventory = GetComponentInChildren<Inventory>(); lastPositionKeeper = GetComponentInChildren<LastPositionKeeper>(); head = GetComponentInChildren<Head>(); cameraPlace = GetComponentInChildren<CameraPlace>(); undo = GetComponentInChildren<Undo>(); characterController = GetComponentInChildren<CharacterController>(); rewind = GetComponentInChildren<Rewind>(); slowmo = GetComponentInChildren<Slowmo>(); gravity = GetComponentInChildren<Gravity>(); all.Add(this); }
private void Setup(OverlaySide overlaySide) { eyecamera = GetComponent <Camera>(); eyecamera.aspect = 1.0f; eyecamera.rect = new Rect(0, 0, 1, 1); if (overlaySide != OverlaySide.OverlayBoth) { Eye eyeParam = (overlaySide == OverlaySide.OverlayLeft ? Eye.LeftEye : Eye.RightEye); transform.localPosition = Pvr_UnitySDKManager.SDK.EyeOffset(eyeParam); #if UNITY_EDITOR eyecamera.rect = Pvr_UnitySDKManager.SDK.EyeRect(eyeParam); #endif } }
public void StartBossPhase() { start = true; GetComponentInChildren <BossSecondPhaseWeakpoint>().EnableShooting(); initialPos = transform.parent.transform.position; foreach (WeakPointSecondStageScript wps in GetComponentsInChildren <WeakPointSecondStageScript>()) { wps.DisableInvul(); } Eye.GetComponent <EnemyLookAt>().enabled = true; foreach (GameObject t in Turrets) { t.GetComponentInChildren <BossTurretScript>().enabled = true; } }
public void setEyes(Eye eye, EyeStatus status) { switch (eye) { case Eye.Left: this.setEye(this.leftEyePictureBox, status); break; case Eye.Right: this.setEye(this.rightEyePictureBox, status); break; default: this.setEye(this.leftEyePictureBox, EyeStatus.Closed); this.setEye(this.rightEyePictureBox, EyeStatus.Closed); break; } }
private void InstantiateEyes(string currentKey) { Eye eye = eyeDictionary[currentKey]; _eyeInstance = Instantiate(_eyePrefab, eye.EyePosition, Quaternion.identity); _eyeInstanceKey = currentKey; _eyeInstance.name = _eyeInstanceKey; _eyeInstance.GetComponent <SpriteRenderer>().sprite = eye.EyeSprite; currentKey = GenerateLeftEyeKey(eye.EyeObjectColor, eye.EyeType); eye = leftEyeDictionary[currentKey]; _leftEyeInstance = Instantiate(_eyePrefab, eye.EyePosition, Quaternion.identity); _leftEyeInstance.name = currentKey; _leftEyeInstance.GetComponent <SpriteRenderer>().sprite = eye.EyeSprite; }
private void SetEyesVulnerable(bool yes) { for (int i = 0; i < mEyes.Length; i++) { if (mEyeParents[i].gameObject.active) { Eye e = mEyes[i]; e.gameObject.layer = yes ? Main.layerItem : Main.layerEnemyNoPlayerProjectile; } } if (!yes) { Main.instance.reticleManager.DeactivateAll(); } }
void Look() { transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * RotateSpeed); Eye.Rotate(Vector3.left * Input.GetAxis("Mouse Y") * RotateSpeed); RaycastHit hit; if (Physics.Raycast(Eye.position, Eye.forward, out hit, 10f)) { if (!(lookingObject == hit.collider.gameObject)) { ClearLookingObject(); lookingObject = hit.collider.gameObject; var mesh = lookingObject.GetComponent <MeshRenderer>(); if (mesh != null) { var block = new MaterialPropertyBlock(); block.SetColor("_Color", new Color(0.4f, 0.4f, 0.4f, 1)); mesh.SetPropertyBlock(block); } } if (Input.GetButtonDown("Punch")) { Chunk.SetBlock("unicraft:air", LookingBlock.Location); } if (Input.GetButtonDown("Interact")) { BlockBase bl; if ((bl = BlockRegister.Instance[LookingBlock.BlockId]) is IInteractable) { (bl as IInteractable).OnInteract(LookingBlock.Location, this); } else { var candidate = Vector3Int.CeilToInt(LookingBlock.Location + hit.normal); Chunk.SetBlock(UniCraft.BlockIdInHand, candidate); } } } else { ClearLookingObject(); } }
private void InsertData(ITestDataContext db) { var eye = new Eye { Id = 1, Xy = "Hallo" }; var dog = new Dog { Id = 1, Discriminator = "Dog", EyeId = 1, Name = "FirstDog", DogName = new Name { First = "a", Second = "b" }, AnimalType = AnimalType.Big, AnimalType2 = AnimalType2.Big }; var test = new Test { Id = 1, TestAnimalId = null }; var test2 = new Test { Id = 2, TestAnimalId = 1 }; using (new DisableLogging()) { db.CreateLocalTable <Animal>(); db.CreateLocalTable <Animal>(); db.CreateLocalTable <Eye>(); db.CreateLocalTable <Test>(); db.Insert(eye); db.Insert(dog); db.Insert(test); db.Insert(test2); } }
/// <summary> /// Position this interface to one eye or the other. If a value other than left/right is sent /// in it resets the position to zero for you. This is here for internal use, but it's public /// because you may come up with a reason to need this. /// </summary> /// <param name="which">The eye you'd like the interface's position to match</param> public void PositionToEye(Eye which) { var targetPosition = Vector3.zero; if (which == Eye.Left || which == Eye.Right) { var eyeData = _stereoData[(int)which - 1]; targetPosition = _poseData.position + _poseData.orientation * eyeData.position; } transform.localPosition = targetPosition; transform.localRotation = _poseData.orientation; //var actual = transform.position; //var delta = Vector3.right * 0.01f; //Debug.DrawLine(actual - delta, actual + delta, Color.black); }
/// <summary> /// Calculates distance between pupil centers based on previously /// recorded min and max values /// </summary> /// <param name="leftEye"></param> /// <param name="rightEye"></param> /// <returns>a normalized value [0..1]</returns> public static double GetEyesDistanceNormalized(Eye leftEye, Eye rightEye) { double dist = Math.Abs(GetDistancePoint2D(leftEye.PupilCenterCoordinates, rightEye.PupilCenterCoordinates)); if (dist < _MinimumEyesDistance) { _MinimumEyesDistance = dist; } if (dist > _MaximumEyesDistance) { _MaximumEyesDistance = dist; } //return normalized return(dist / (_MaximumEyesDistance - _MinimumEyesDistance)); }
private Vector2D PupilCornerDistance(Eye gaze, Pose headPose) { var leftPupilCornerVector = gaze.PupilPosition.Left.ToMathNetPoint3D() - gaze.InnerEyeCornerPosition.Left.ToMathNetPoint3D(); var headAngel = headPose.Angle; var headPitch = Angle.FromRadians(headAngel.X); var headYaw = Angle.FromRadians(headAngel.Y); var headRoll = Angle.FromRadians(headAngel.Z); var realigned = CoordinateSystem.Rotation(headYaw, headPitch, headRoll); leftPupilCornerVector = leftPupilCornerVector.TransformBy(realigned); var xDistance = leftPupilCornerVector.X; var yDistance = leftPupilCornerVector.Y; return(new Vector2D(xDistance, yDistance)); }
private EyeInfo LookFor(int layer, float sieghtDistance) { foreach (Eye item in mFuctionParts[typeof(Eye)]) { item.Look(layer, sieghtDistance); } IEnumerable <Eye> food = from eye in mFuctionParts[typeof(Eye)] where (eye as Eye).Food orderby(eye as Eye).DistanceFood descending select eye as Eye; IEnumerable <Eye> wall = from eye in mFuctionParts[typeof(Eye)] where (eye as Eye).Wall orderby(eye as Eye).DistanceWall descending select eye as Eye; IEnumerable <Eye> bug = from eye in mFuctionParts[typeof(Eye)] where (eye as Eye).Bug orderby(eye as Eye).DistanceBug descending select eye as Eye; Eye aFood = default(Eye); Eye aWall = default(Eye); Eye aBug = default(Eye); foreach (Eye item in food) { aFood = item; break; } foreach (Eye item in wall) { aWall = item; break; } foreach (Eye item in bug) { aBug = item; break; } return(new EyeInfo(aFood != default(Eye) ? aFood.ClosestFood : Vector3.zero, aWall != default(Eye) ? aWall.ClosestWall : Vector3.zero, aBug != default(Eye) ? aBug.ClosestBug : Vector3.zero, aFood != default(Eye) ? aFood.DistanceFood : 0, aWall != default(Eye) ? aWall.DistanceWall : 0, aBug != default(Eye) ? aBug.DistanceBug : 0, aFood != default(Eye), aWall != default(Eye), aBug != default(Eye))); }
private void RenderPreviewDefaultForEye(Eye eye, Matrix4x4 localToWorldMatrix) { if (_currentCamera == null) { return; } // Set the camera's target texture. switch (eye) { case Eye.Left: _currentCamera.targetTexture = _leftPreviewRenderTexture; break; case Eye.Right: _currentCamera.targetTexture = _rightPreviewRenderTexture; break; default: break; } // Set the camera's transform based on it's original // local-to-world matrix and the frustum's view matrix. // // NOTE: Since we no longer internally flip the handedness // of the view matrices from right to left (in order // to support Unity's new Camera.SetStereoViewMatrix() // API call), we need to explicity flip from right to // left here. Matrix4x4 viewMatrix = this.FlipHandedness(this.GetFrustumViewMatrix(eye)); Matrix4x4 cameraMatrix = localToWorldMatrix * viewMatrix.inverse; _currentCamera.transform.position = cameraMatrix.GetColumn(3); _currentCamera.transform.rotation = Quaternion.LookRotation( cameraMatrix.GetColumn(2), cameraMatrix.GetColumn(1)); // Set the camera's projection matrix. _currentCamera.projectionMatrix = this.GetFrustumProjectionMatrix(eye); // Render the frame. _currentCamera.Render(); }
private void InsertData(ITestDataContext db) { var eye = new Eye { Id = 1, Xy = "Hallo" }; var dog = new Dog { Id = 1, Discriminator = "Dog", EyeId = 1, Name = "FirstDog", DogName = new Name { First = "a", Second = "b" }, AnimalType = AnimalType.Big, AnimalType2 = AnimalType2.Big }; var test = new Test { Id = 1, TestAnimalId = null }; var test2 = new Test { Id = 2, TestAnimalId = 1 }; db.DropTable <Animal>(throwExceptionIfNotExists: false); db.DropTable <Eye>(throwExceptionIfNotExists: false); db.DropTable <Test>(throwExceptionIfNotExists: false); db.CreateTable <Animal>(); db.CreateTable <Eye>(); db.CreateTable <Test>(); db.Insert(eye); db.Insert(dog); db.Insert(test); db.Insert(test2); }
internal virtual float CalculateEyeOutput(Eye eye) { //calculates the output for a specific eye //by default eye output is calculated for the entire eye ColorInformation eyeInfo = eye.GetEntireEyeInformation(); switch (this.eyeMode) { case EyeMode.Maximum: return(eyeInfo.maxBrightness); case EyeMode.Minimum: return(eyeInfo.minBrightness); default: return(eyeInfo.averageBrightness); } }
//** AddEye ** //Add eye record public int AddEye(string name) { int toReturn = 1; if (eyesList.Count > 0) { toReturn = eyesList.OrderBy(x => x.ID).Last().ID + 1; } Eye toAd = new Eye(); toAd.ID = toReturn; toAd.Name = name; eyesList.Add(toAd); return(toReturn); }
public void setEyes(Eye eye, EyeStatus status) { switch (eye) { case Eye.Left: this.setEye(this.leftEyePictureBox, status); break; case Eye.Right: this.setEye(this.rightEyePictureBox, status); break; default: this.setEye(this.leftEyePictureBox, EyeStatus.Closed); this.setEye(this.rightEyePictureBox, EyeStatus.Closed); break; } }
private void Setup() { mFirstLand = false; //once landed, enable tentacles gameObject.layer = Main.layerEnemyNoPlayerProjectile; mStatus = Status.Active; //tentacles if (mTentacles == null) { mTentacles = GetComponentsInChildren <Tentacle>(true); mTentacleParents = new Transform[mTentacles.Length]; } for (int i = 0; i < mTentacles.Length; i++) { Tentacle t = mTentacles[i]; //t.gameObject.SetActiveRecursively(true); t.gameObject.layer = Main.layerEnemyNoPlayerProjectile; t.boss = this; mTentacleParents[i] = t.transform.parent; } mNumActiveTentacles = mTentacles.Length; //eyes if (mEyes == null) { mEyes = GetComponentsInChildren <Eye>(true); mEyeParents = new Transform[mEyes.Length]; } for (int i = 0; i < mEyes.Length; i++) { Eye e = mEyes[i]; //e.gameObject.SetActiveRecursively(true); e.gameObject.layer = Main.layerEnemyNoPlayerProjectile; e.boss = this; mEyeParents[i] = e.transform.parent; } mNumActiveEyes = mEyes.Length; }
public ObjectivelyViewModel() { SelectedDescription = new EyeDescriptionMethod("Оба сразу", true, "0"); EyeDescriptionMethods = new List <EyeDescriptionMethod>() { SelectedDescription, new EyeDescriptionMethod("По отдельности", false, "2*") }; using (MedicineContext db = new MedicineContext()) { db.EyeSides.Load(); EyeSides = db.EyeSides.Local.ToBindingList(); } EyeSide ODSide = EyeSides.FirstOrDefault(x => x.Side == "OD"); EyeSide OSSide = EyeSides.FirstOrDefault(x => x.Side == "OS"); if (SingletonVMP.VMP.Eyes == null) { ODEye = new Eye(ODSide); OSEye = new Eye(OSSide); Eyes = new List <Eye>(); Eyes.Add(ODEye); Eyes.Add(OSEye); SingletonVMP.VMP.Eyes = Eyes; } else { Eyes = SingletonVMP.VMP.Eyes; ODEye = Eyes.FirstOrDefault(s => s.EyeSideId == ODSide.Id); OSEye = Eyes.FirstOrDefault(s => s.EyeSideId == OSSide.Id); if (ODEye.CompareTo(OSEye) == -1) { EyeDescriptionMethods.Clear(); SelectedDescription = new EyeDescriptionMethod("По отдельности", false, "2*"); EyeDescriptionMethods = new List <EyeDescriptionMethod>() { new EyeDescriptionMethod("Оба сразу", true, "0"), SelectedDescription }; } } }
/// <summary> /// Render the specified eye onto the texture provided. This is used internally and likely /// won't be needed for the vast majority of applications. If you use Neither or Both, it /// returns immediately. /// </summary> /// <param name="which">The eye you want to render to the provided texture</param> /// <param name="targetTexture">The target texture to use for rendering the specified eye.</param> internal protected virtual void RenderEye(Eye which, RenderTexture targetTexture) { if (!ShouldRenderEye(which)) { return; } var origCullMask = _cam.cullingMask; var eyeCullMask = which == Eye.Left ? cullMaskLeft : cullMaskRight; _cam.cullingMask = origCullMask & ~eyeCullMask; var eyeData = _stereoData[(int)which - 1]; var eyePosOffset = eyeData.position; // move the camera to the eye position transform.localPosition = _poseData.position + _poseData.orientation * eyePosOffset; transform.localRotation = _poseData.orientation; // move camera children inversly to keep the stereo projection effect foreach (Transform child in transform) { child.localPosition -= eyePosOffset; } _cam.projectionMatrix = eyeData.projection; _cam.targetTexture = targetTexture; _cam.Render(); _cam.cullingMask = origCullMask; _cam.targetTexture = null; _cam.ResetProjectionMatrix(); // reset camera position transform.localPosition = _poseData.position; transform.localRotation = _poseData.orientation; // reset camera children position foreach (Transform child in transform) { child.localPosition += eyePosOffset; } }
public static void AddDoc(ManipulationConfig config, Func <tblDocumentCommon[]> DocFactory) { Eye xEye = config.Eye; Debug.Assert(xEye != Eye.No); tblManipulation xManipulation; Eye[] xEyes = (xEye == Eye.OU) ? new Eye[] { Eye.OS, Eye.OD } : new Eye[] { xEye }; foreach (Eye item in xEyes) { config.Eye = item; xManipulation = CreateManipulation(config); tblDocumentCommon[] xNewDocs = DocFactory(); foreach (tblDocumentCommon xNewDoc in xNewDocs) { ViewDataContext.PrepareDoc(xNewDoc, xManipulation); xManipulation.tblDocumentCommonsObs.Add(xNewDoc); Instance.Documents.Add(xNewDoc); } } }
Mesh GetStencilMesh(Eye eyeSide) { int vertexCount = 0; int triangleCount = 0; IntPtr vertexDataPtr = IntPtr.Zero; IntPtr triangleDataPtr = IntPtr.Zero; Pvr_UnitySDKAPI.Render.UPvr_GetStencilMesh((int)eyeSide, ref vertexCount, ref triangleCount, ref vertexDataPtr, ref triangleDataPtr); if (vertexCount <= 0 || triangleCount <= 0 || vertexDataPtr == IntPtr.Zero || triangleDataPtr == IntPtr.Zero) { return(null); } Vector3[] VerticesUnity = new Vector3[vertexCount]; int[] IndicesUnity = new int[triangleCount * 3]; float[] vertexData = new float[vertexCount * 3]; int[] indexData = new int[triangleCount * 3]; // right hand coordinate? Marshal.Copy(vertexDataPtr, vertexData, 0, vertexCount * 3); Marshal.Copy(triangleDataPtr, indexData, 0, triangleCount * 3); for (int i = 0; i < vertexCount; i++) { VerticesUnity[i] = new Vector3(vertexData[3 * i], vertexData[3 * i + 1], zDir); } for (int i = 0; i < triangleCount; i++) { IndicesUnity[3 * i] = indexData[3 * i + 2]; IndicesUnity[3 * i + 1] = indexData[3 * i + 1]; IndicesUnity[3 * i + 2] = indexData[3 * i]; } Mesh mesh = new Mesh(); mesh.name = "EyeMaskMesh"; mesh.vertices = VerticesUnity; mesh.SetIndices(IndicesUnity, MeshTopology.Triangles, 0); return(mesh); }
private void InstantiateEyes(string currentKey, out bool isLarge, out int eyeColor) { Eye eye = eyeDictionary[currentKey]; _eyeInstance = Instantiate(_eyePrefab, eye.EyePosition, Quaternion.identity); _eyeInstanceKey = currentKey; _eyeInstance.name = _eyeInstanceKey; _eyeInstance.GetComponent <SpriteRenderer>().sprite = eye.EyeSprite; currentKey = GenerateLeftEyeKey(eye.EyeObjectColor, eye.EyeType); eye = leftEyeDictionary[currentKey]; _leftEyeInstance = Instantiate(_eyePrefab, eye.EyePosition, Quaternion.identity); _leftEyeInstance.name = currentKey; _leftEyeInstance.GetComponent <SpriteRenderer>().sprite = eye.EyeSprite; isLarge = eye.EyeType == "Large" ? true : false; eyeColor = (int)eye.EyeObjectColor; }
public void HaveSimpleOperations() { var left = new Eye { X = 100, Y = 50 }; var right = new Eye { X = 150, Y = 60 }; var eyeVector = right - left; Assert.AreEqual(150 - 100, eyeVector.X); Assert.AreEqual(60 - 50, eyeVector.Y); var eyeSum = left + right; Assert.AreEqual(100 + 150, eyeSum.X); Assert.AreEqual(50 + 60, eyeSum.Y); }
// Start is called before the first frame update void Start() { constraint = GetComponentInChildren <BoxCameraConstraint>(); Target = constraint.followObject; claw = GetComponentInChildren <EyeBossClawScript>(true); sprite = GetComponent <SpriteRenderer>(); Eyes = new List <BossEyeScript>(); GetComponentsInChildren <BossEyeScript>(true, Eyes); damager = GetComponent <Damager>(); EyeHealths = new List <Damageable>(); foreach (BossEyeScript Eye in Eyes) { Damageable EyeHealth = Eye.GetComponent <Damageable>(); maxHealth += EyeHealth.MaxHealth; EyeHealths.Add(EyeHealth); Eye.ViewCamera = constraint.clampedCamera.AttachedCamera; } }
/// <summary> /// Render the specified eye onto the texture provided. This is used internally and likely /// won't be needed for the vast majority of applications. If you use Neither or Both, it /// returns immediately. /// </summary> /// <param name="which">The eye you want to render to the provided texture</param> /// <param name="targetTexture">The target texture to use for rendering the specified eye.</param> internal protected virtual void RenderEye(Eye which, RenderTexture targetTexture) { if (!ShouldRenderEye(which)) { return; } var origCullMask = cam.cullingMask; var eyeCullMask = which == Eye.Left ? cullMaskLeft : cullMaskRight; cam.cullingMask = origCullMask & ~eyeCullMask; var eyePosOffset = eyeOffsets[which]; // move the camera to the eye position transform.localPosition = hmdPosition + hmdOrientation * eyePosOffset; transform.localRotation = hmdOrientation; // move camera children inversely to keep the stereo projection effect foreach (Transform child in transform) { child.localPosition -= eyePosOffset; } cam.projectionMatrix = projectionMatrices[which]; cam.targetTexture = targetTexture; cam.Render(); cam.cullingMask = origCullMask; cam.targetTexture = null; cam.ResetProjectionMatrix(); // reset camera position transform.localPosition = hmdPosition; transform.localRotation = hmdOrientation; // reset camera children position foreach (Transform child in transform) { child.localPosition += eyePosOffset; } }
public void doShoot(CameraMode projection) { // Set Viewport ApplyViewPort(); // Set perspective if (projection == CameraMode.PERSPECTIVE) { Glut.Glut.Perspective(computeFieldOfView(RenderingSphereRadius * 2, Eye.distance(Target)), (StretchToFill ? _screenWidth / _screenHeight : 1), Near, Far); } else if (projection == CameraMode.ORTHOGONAL) { GL.Ortho(-RenderingSphereRadius, +RenderingSphereRadius, -RenderingSphereRadius, +RenderingSphereRadius, Near, Far); } else { throw new Exception("Camera.shoot() : unsupported projection mode '" + projection + "'"); } // Set camera position Glut.Glut.LookAt(Eye.x, Eye.y, Eye.z, Target.x, Target.y, Target.z, Up.x, Up.y, Up.z); }
internal override void Start() { base.Start(); if (this.leftEye == null) { foreach (Eye e in GetComponents <Eye>()) { if (e.EyeTag == "LeftEye") { this.leftEye = e; } } } else { //check the tag of the eye this.CheckEyeTag(this.leftEye, "LeftEye"); } if (this.rightEye == null) { foreach (Eye e in GetComponents <Eye>()) { if (e.EyeTag == "RightEye") { this.rightEye = e; } } } else { //check the tag of the eye this.CheckEyeTag(this.rightEye, "RightEye"); } this.eyes.Add(leftEye); this.eyes.Add(rightEye); this.eyeCollection.Add(this.leftEye.EyeTag, this.leftEyeOutput); this.eyeCollection.Add(this.rightEye.EyeTag, this.rightEyeOutput); //render both of the eyes to ensure that data can be displayed in the eye UI this.leftEye.Execute(); this.rightEye.Execute(); }
#pragma warning restore 0414 void Start () { settings = Settings.getInstance(); _t = transform; gameObject.tag = "Genital"; crt = (Creature)_t.parent.parent.gameObject.GetComponent("Creature"); lg = Logger.getInstance(); co = CollisionMediator.getInstance(); eye = crt.eye.gameObject.GetComponent<Eye>(); _t = transform; lr = (LineRenderer)gameObject.AddComponent<LineRenderer>(); lr.material.color = Color.white; lr.material.shader = Shader.Find("Sprites/Default"); lr.SetWidth(line_width, line_width); lr.SetVertexCount(2); lr.GetComponent<Renderer>().enabled = true; timeCreated = Time.time; line_length = float.Parse( settings.contents["genitalia"]["line_length"].ToString() ); }
public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hashCode = 41; if(Up != null) hashCode = hashCode * 59 + Up.GetHashCode(); if(Center != null) hashCode = hashCode * 59 + Center.GetHashCode(); if(Eye != null) hashCode = hashCode * 59 + Eye.GetHashCode(); if(Projection != null) hashCode = hashCode * 59 + Projection.GetHashCode(); return hashCode; } }
private static void UpdateHmdData() { _sLastPose = GetLastPose(); m_sHeadPosition = _sLastPose.position.ToVector3() * m_worldScale; m_sStandingPosition = _sLastPose.standingPosition.ToVector3() * m_worldScale; m_sHeadRotation = _sLastPose.orientation.ToQuaternion(); { GazeVector lGaze, rGaze; Fove.GazeConvergenceData conv; var errVector = Instance.m_headset.GetGazeVectors(out lGaze, out rGaze); var errConv = Instance.m_headset.GetGazeConvergence(out conv); if (errVector == ErrorCode.None && errConv == ErrorCode.None) { var convRay = conv.ray.ToRay(); m_sEyeVecLeft = lGaze.vector.ToVector3(); m_sEyeVecRight = rGaze.vector.ToVector3(); m_sConvergenceData.distance = m_worldScale * conv.distance; m_sConvergenceData.ray = new Ray(m_worldScale * convRay.origin, convRay.direction); m_sPupilDilation = conv.pupilDilation; m_sGazeFixated = conv.attention; } } Matrix44 lEyeMx, rEyeMx; Instance.m_headset.GetEyeToHeadMatrices(out lEyeMx, out rEyeMx); GetEyeOffsetVector(ref lEyeMx, out m_sLeftEyeOffset); GetEyeOffsetVector(ref rEyeMx, out m_sRightEyeOffset); m_sEyeClosed = CheckEyesClosed(true); if (AddInUpdate != null) { AddInUpdate(); } }
//only used by eye public void EyeEaten(Eye e) { bool eaten = false; for(int i = 0; i < mEyes.Length; i++) { if(mEyes[i] == e) { e.transform.parent = mEyeParents[i]; e.transform.localPosition = Vector3.zero; e.transform.localRotation = Quaternion.identity; e.transform.localScale = Vector3.one; mEyeParents[i].gameObject.SetActiveRecursively(false); mNumActiveEyes--; eaten = true; break; } } if(eaten) { stats.ApplyDamage(1); DoHurt(); } }
void Awake() { //get a reference to the vehicle vehicle = this.GetComponentInParent <Vehicle> (); //get a reference to the vehicle spotlight GameObject lightObj = vehicle.gameObject.GetChildObjectByName("Vehicle Spotlight"); //get a reference to the light component of the vehicle spotlight this.vehicleSpotLight = lightObj.GetComponent <Light> (); //get a reference to the main directional light directionalLight = GameObject.FindGameObjectWithTag(TagManager.DirectionalLight).GetComponent <Light>(); //get a reference to the GrayScaleEffect component grayScaleEffect = GetComponent <GrayscaleEffect>(); //get a reference to the camera component _camera = GetComponent <Camera> (); //get a reference to the eye that contains the retina. if (this.eyeType == null) { Debug.LogError("Null reference for retina eye type."); return; } foreach (Eye e in this.GetComponentsInParent <Eye>(true)) { if (e.eyeType == this.eyeType) { this.eye = e; break; } } //log error if eye with the appropriate type cannot be found if (this.eye == null) { Debug.LogError("Could not find eye for retina. Are you missing an EyeType reference?"); } this.ambientLighting = RenderSettings.ambientLight; this.vehicleSpotLightOriginalSetting = this.vehicle.vehicleSpotlight; complexRetinaMaterial = new Material(Shader.Find("Custom/ComplexEye")); simpleRetinaMaterial = new Material(Shader.Find("Custom/AverageBrightness")); }
public Matrix4x4 EyeView(Eye eye) { return EyePose(eye).Matrix; }
/// The transformation from head to eye. public Pose3D EyePose(Eye eye) { return device.GetEyePose(eye); }
public Rect EyeRect(Eye eye) { return Viewport(eye, Distortion.Distorted); }
/// <summary> /// Get the view matrix for a specified eye. /// </summary> /// <param name="eye">The eye: left, right, or center.</param> /// <returns>The view matrix in Matrix4x4 format.</returns> public Matrix4x4 GetViewMatrix(Eye eye) { return _viewMatrices[(int)eye]; }
//------------------------------------------------------------------------------------- // ***** Graphics Setup /// <summary> /// Calculates the recommended texture size for rendering a given eye within the HMD /// with a given FOV cone. Higher FOV will generally require larger textures to /// maintain quality. /// - pixelsPerDisplayPixel specifies the ratio of the number of render target pixels /// to display pixels at the center of distortion. 1.0 is the default value. Lower /// values can improve performance. /// </summary> public Sizei GetFovTextureSize(Eye eye, FovPort fov, float pixelsPerDisplayPixel = 1.0f) { return ovrHmd_GetFovTextureSize(HmdPtr, eye, fov, pixelsPerDisplayPixel); }
/// The screen space viewport that the camera for the specified eye should render into. /// In the _Distorted_ case, this will be either the left or right half of the `StereoScreen` /// render texture. In the _Undistorted_ case, it refers to the actual rectangle on the /// screen that the eye can see. public Rect Viewport(Eye eye, Distortion distortion = Distortion.Distorted) { return device.GetViewport(eye, distortion); }
/// <summary> /// Get the frustum bounds for a specified eye. /// </summary> /// <param name="eye">The eye: left, right, or center.</param> /// <param name="bounds">The frustum bounds corresponding to a specified eye laid out as follows:\n\n /// [left, right, bottom, top, nearClip, farClip]</param> public void GetFrustumBounds(Eye eye, float[/*6*/] bounds) { zsup_getFrustumBounds((int)eye, bounds); }
private static extern Posef ovrHmd_GetHmdPosePerEye( IntPtr hmd, Eye eye);
private static extern EyeRenderDesc ovrHmd_GetRenderDesc(IntPtr hmd, Eye eye, FovPort fov);
/// <summary> /// Computes timewarp matrices used by distortion mesh shader, these are used to adjust /// for head orientation change since the last call to ovrHmd_GetEyePoses /// when rendering this eye. The ovrDistortionVertex::TimeWarpFactor is used to blend between the /// matrices, usually representing two different sides of the screen. /// Must be called on the same thread as ovrHmd_BeginFrameTiming. /// </summary> public Matrix4f[] GetEyeTimewarpMatrices(Eye eye, Posef renderPose) { Matrix4f_Raw[] rawMats = {new Matrix4f_Raw(), new Matrix4f_Raw()}; ovrHmd_GetEyeTimewarpMatrices(HmdPtr, eye, renderPose, rawMats); Matrix4f[] mats = {new Matrix4f(rawMats[0]), new Matrix4f(rawMats[1])}; return mats; }
private static extern Sizei ovrHmd_GetFovTextureSize( IntPtr hmd, Eye eye, FovPort fov, float pixelsPerDisplayPixel);
/// <summary> /// Generate distortion mesh per eye. /// Distortion capabilities will depend on 'distortionCaps' flags. Users should /// render using the appropriate shaders based on their settings. /// Distortion mesh data will be allocated and written into the ovrDistortionMesh data structure, /// which should be explicitly freed with ovrHmd_DestroyDistortionMesh. /// Users should call ovrHmd_GetRenderScaleAndOffset to get uvScale and Offset values for rendering. /// The function shouldn't fail unless theres is a configuration or memory error, in which case /// ovrDistortionMesh values will be set to null. /// This is the only function in the SDK reliant on eye relief, currently imported from profiles, /// or overridden here. /// </summary> public DistortionMesh? CreateDistortionMesh(Eye eye, FovPort fov, uint distortionCaps) { DistortionMesh_Raw rawMesh = new DistortionMesh_Raw(); bool result = ovrHmd_CreateDistortionMesh(HmdPtr, eye, fov, distortionCaps, out rawMesh) != 0; if (!result) { return null; } DistortionMesh mesh = new DistortionMesh(rawMesh); ovrHmd_DestroyDistortionMesh(ref rawMesh); return mesh; }
//------------------------------------------------------------------------------------- // ***** Client Distortion Rendering Functions // These functions provide the distortion data and render timing support necessary to allow // client rendering of distortion. Client-side rendering involves the following steps: // // 1. Setup ovrEyeDesc based on the desired texture size and FOV. // Call ovrHmd_GetRenderDesc to get the necessary rendering parameters for each eye. // // 2. Use ovrHmd_CreateDistortionMesh to generate the distortion mesh. // // 3. Use ovrHmd_BeginFrameTiming, ovrHmd_GetEyePoses, and ovrHmd_BeginFrameTiming in // the rendering loop to obtain timing and predicted head orientation when rendering each eye. // - When using timewarp, use ovr_WaitTillTime after the rendering and gpu flush, followed // by ovrHmd_GetEyeTimewarpMatrices to obtain the timewarp matrices used // by the distortion pixel shader. This will minimize latency. // /// <summary> /// Computes the distortion viewport, view adjust, and other rendering parameters for /// the specified eye. This can be used instead of ovrHmd_ConfigureRendering to do /// setup for client rendered distortion. /// </summary> public EyeRenderDesc GetRenderDesc(Eye eyeType, FovPort fov) { return ovrHmd_GetRenderDesc(HmdPtr, eyeType, fov); }
/// <summary> /// DEPRECATED: Prefer using ovrHmd_GetEyePoses instead /// Function was previously called ovrHmd_GetEyePose /// Returns the predicted head pose to use when rendering the specified eye. /// - Important: Caller must apply HmdToEyeViewOffset before using ovrPosef for rendering /// - Must be called between ovrHmd_BeginFrameTiming and ovrHmd_EndFrameTiming. /// - If the pose is used for rendering the eye, it should be passed to ovrHmd_EndFrame. /// - Parameter 'eye' is used for prediction timing only /// </summary> public Posef GetHmdPosePerEye(Eye eye) { return ovrHmd_GetHmdPosePerEye(HmdPtr, eye); }
/// The projection matrix for a given eye. /// This matrix is an off-axis perspective projection with near and far /// clipping planes of 1m and 1000m, respectively. The CardboardEye script /// takes care of adjusting the matrix for its particular camera. public Matrix4x4 Projection(Eye eye, Distortion distortion = Distortion.Distorted) { return device.GetProjection(eye, distortion); }
private static extern sbyte ovrHmd_CreateDistortionMesh( IntPtr hmd, Eye eye, FovPort fov, uint distortionCaps, [Out] out DistortionMesh_Raw meshData);
public Matrix4x4 UndistortedProjection(Eye eye) { return Projection(eye, Distortion.Undistorted); }
private static extern void ovrHmd_GetEyeTimewarpMatrices( IntPtr hmd, Eye eye, Posef renderPose, [MarshalAs(UnmanagedType.LPArray, SizeConst = 2)] [Out] Matrix4f_Raw[] twnOut);
/// <summary> /// Get the position of a specified eye. /// </summary> /// <param name="eye">The eye: left, right, or center.</param> /// <returns>The position of the eye in Vector3 format.</returns> public Vector3 GetEyePosition(Eye eye) { float[] positionData = new float[3]; zsup_getEyePosition((int)eye, positionData); return this.ConvertToVector3(positionData); }
public static extern Posef ovrp_GetEyePose(Eye eyeId);
/// <summary> /// Get the projection matrix for a specified eye. /// </summary> /// <param name="eye">The eye: left, right, or center.</param> /// <returns>The projection matrix in Matrix4x4 format.</returns> public Matrix4x4 GetProjectionMatrix(Eye eye) { return _projectionMatrices[(int)eye]; }
public Vector3 EyeOffset(Eye eye) { return EyePose(eye).Position; }
public static extern Sizei ovrp_GetEyeTextureSize(Eye eyeId);
public static extern Frustumf ovrp_GetEyeFrustum(Eye eyeId);