public Transform cursor; // 3d obj that works as a cursor, usualy a sphere private void FixedUpdate() { RaycastHit hit; // Raycast from the front of the camera var fwd = transform.TransformDirection(Vector3.forward); if (Physics.Raycast(transform.position, fwd, out hit, maxDistance)) { if (hit.transform.tag == "Gaze") // If the obj hit have a tag gaze { if (lastTarget == null) // this is for minimizing the use of GetComponent { lastTarget = hit.collider.gameObject.transform.GetComponent <GazeTarget>(); } lastTarget.gazing = true; // then its gazing } else // so if the raycast still hits and obj but the tag is not gaze, clear the last target { lastTarget.gazing = false; lastTarget = null; } cursor.position = hit.point; //ajust position of the cursor } else { if (lastTarget != null) //Clear last target when ray does not hit anything { lastTarget.gazing = false; lastTarget = null; } cursor.position = transform.position + fwd * (maxDistance / 2); //when not tracking anything, set the cursor at had the max distance } }
public TargetInfo(GazeTarget gazeTarget) { this.GazeTarget = gazeTarget; this.TargetName = gazeTarget.ToString().ToLower(); this.Coordinates = Vector2D.Zero; Linked = false; }
void UpdateGaze() { currentRay = cardboardHead.Gaze; Debug.DrawRay(currentRay.origin, 10 * currentRay.direction, Color.red); target = null; targetCollider = null; RaycastHit hit; if (Physics.Raycast(currentRay, out hit, raycastLength, layerMask)) { //Debug.Lo hit.transform.SendMessage(message, this, SendMessageOptions.DontRequireReceiver); targetCollider = hit.collider; reticle.SetTarget(hit.point); } else { reticle.SetDistance(100f); } ///We're using a spherecast instead of a ray so this doesn't jump around too much //if (Physics.SphereCast(currentRay, 0.1f,out hit, raycastLength, layerMask)){ // reticle.SetTarget(hit.point); //} // else{ //} }
public static EditTimeVisualizerModel Create(GazeTarget target) { var model = new EditTimeVisualizerModel(); //model.ID = target.Start + "_" + target.Length; model.Name = ((ISymbol)target.DataModel).Name; model.Value = AttemptGetDebuggerValue(model.Name); return(model); }
private void ConfigureHelpers() { Transform head = transform.Find("body/body_renderPart_0/root_JNT/body_JNT/chest_JNT/neckBase_JNT/neck_JNT/head_JNT"); if (head == null) { AvatarLogger.LogError("Avatar helper config failed. Cannot find head transform. All helpers spawning on root avatar transform"); head = transform; } if (MouthAnchor == null) { MouthAnchor = CreateHelperObject(head, MOUTH_HEAD_OFFSET, MOUTH_HELPER_NAME); } if (GetComponent <OvrAvatarRemoteDriver>() != null) { GazeTarget headTarget = head.gameObject.AddComponent <GazeTarget>(); headTarget.Type = ovrAvatarGazeTargetType.AvatarHead; AvatarLogger.Log("Added head as gaze target"); Transform hand = transform.Find("hand_left"); if (hand == null) { AvatarLogger.LogWarning("Gaze target helper config failed: Cannot find left hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent <GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added left hand as gaze target"); } hand = transform.Find("hand_right"); if (hand == null) { AvatarLogger.Log("Gaze target helper config failed: Cannot find right hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent <GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added right hand as gaze target"); } } }
internal void SetTarget(string targetName, GazeTarget target) { lock (Targets) { Targets[targetName.ToLower()] = new TargetInfo(targetName, target); } NotifyTargetsChanged(); }
internal void SetTarget(GazeTarget target) { lock (Targets) { Targets[target.ToString().ToLower()] = new TargetInfo(target); } NotifyTargetsChanged(); }
void Start() { meshRenderer = GetComponent <MeshRenderer>(); gazer = GetComponent <GazeTarget>(); }
public TargetInfo(Vector2D coordinates, string targetName = "", GazeTarget targetType = EmoteCommonMessages.GazeTarget.ScreenPoint) { this.GazeTarget = targetType; this.Coordinates = coordinates; this.TargetName = targetName; Linked = false; }
public TargetInfo(string targetName, GazeTarget gazeTarget) { this.GazeTarget = gazeTarget; this.TargetName = targetName; this.Coordinates = Vector2D.Zero; Linked = false; }
private void GenerateGaze(GazeTarget target, Vector2D coordinates, double speed) { Vector2D randomVector = Vector2D.Random(currentRandomAmplitude.X, currentRandomAmplitude.Y); if (lastGazeTarget == target) { if ((target == GazeTarget.Random && coordinates == lastGazeCoordinates) || (target != GazeTarget.Random && coordinates == randomVector)) return; } gazeId = "BehaviorManagerGaze" + gazeCounts++; string thisGazeId = gazeId; switch (target) { case GazeTarget.Person: case GazeTarget.Person2: lastPerson = target; SkeneClient.Debug("Gaze {2}: {0} @ {1}", gazeId, coordinates, target); SkeneClient.SkPublisher.Gaze(thisGazeId, coordinates.X, coordinates.Y+10, speed, true); break; case GazeTarget.Angle: SkeneClient.Debug("Gaze Angle: {0} @ {1}", gazeId, coordinates); SkeneClient.SkPublisher.Gaze(thisGazeId, coordinates.X, coordinates.Y, speed); break; case GazeTarget.Clicks: SkeneClient.Debug("Gaze Clicks: {0} @ {1}", gazeId, coordinates); if (!ignoreClick) GenerateGazeToScreen(thisGazeId, coordinates.X, coordinates.Y, speed); break; case GazeTarget.ScreenPoint: SkeneClient.Debug ("Gaze ScreenPoint: {0} @ {1}", gazeId, coordinates); SkeneClient.QueueTarget (gazeId, (() => SkeneClient.SkPublisher.Highlight (coordinates.X, coordinates.Y)), ""); GenerateGazeToScreen(thisGazeId, coordinates.X, coordinates.Y, speed); break; case GazeTarget.ThroughMap: SkeneClient.Debug("Gaze ThroughMap: {0} @ {1}", gazeId, randomVector); double w = SkeneClient.ActiveSpaceSetup._screenSetup._resolution.X; double h = SkeneClient.ActiveSpaceSetup._screenSetup._resolution.Y; randomVector = new Vector2D(w/2, h/2)-Vector2D.Random(w/4,h/4); GenerateGazeToScreen(thisGazeId, randomVector.X, randomVector.Y, speed); break; case GazeTarget.AcrossRoom: case GazeTarget.None: case GazeTarget.Random: default: SkeneClient.Debug("Gaze Random: {0} @ {1}", gazeId, randomVector); SkeneClient.SkPublisher.Gaze(thisGazeId, randomVector.X, Math.Abs(randomVector.Y), speed/2); break; } lastGazeTarget = target; if (GazeState == GazeTarget.Random) lastGazeCoordinates = randomVector; else lastGazeCoordinates = coordinates; SetGazeTime(currentGazeInterval); }
void UpdateGaze() { currentRay = cardboardHead.Gaze; Debug.DrawRay(currentRay.origin, 10*currentRay.direction,Color.red); target = null; targetCollider = null; RaycastHit hit; if (Physics.Raycast(currentRay,out hit, raycastLength, layerMask)){ //Debug.Lo hit.transform.SendMessage(message,this, SendMessageOptions.DontRequireReceiver); targetCollider = hit.collider; reticle.SetTarget(hit.point); } else{ reticle.SetDistance(100f); } ///We're using a spherecast instead of a ray so this doesn't jump around too much //if (Physics.SphereCast(currentRay, 0.1f,out hit, raycastLength, layerMask)){ // reticle.SetTarget(hit.point); //} // else{ //} }
private void ConfigureHelpers() { Transform head = transform.Find("body/body_renderPart_0/root_JNT/body_JNT/chest_JNT/neckBase_JNT/neck_JNT/head_JNT"); if (head == null) { AvatarLogger.LogError("Avatar helper config failed. Cannot find head transform. All helpers spawning on root avatar transform"); head = transform; } if (MouthAnchor == null) { MouthAnchor = CreateHelperObject(head, MOUTH_HEAD_OFFSET, MOUTH_HELPER_NAME); } if (GetComponent <OvrAvatarLocalDriver>() != null) { if (audioSource == null) { audioSource = MouthAnchor.gameObject.AddComponent <AudioSource>(); } spatializedSource = MouthAnchor.GetComponent <ONSPAudioSource>(); if (spatializedSource == null) { spatializedSource = MouthAnchor.gameObject.AddComponent <ONSPAudioSource>(); } spatializedSource.UseInvSqr = true; spatializedSource.EnableRfl = false; spatializedSource.EnableSpatialization = true; spatializedSource.Far = 100f; spatializedSource.Near = 0.1f; StartCoroutine(WaitForMouthAudioSource()); } if (GetComponent <OvrAvatarRemoteDriver>() != null) { GazeTarget headTarget = head.gameObject.AddComponent <GazeTarget>(); headTarget.Type = ovrAvatarGazeTargetType.AvatarHead; AvatarLogger.Log("Added head as gaze target"); Transform hand = transform.Find("hand_left"); if (hand == null) { AvatarLogger.LogWarning("Gaze target helper config failed: Cannot find left hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent <GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added left hand as gaze target"); } hand = transform.Find("hand_right"); if (hand == null) { AvatarLogger.Log("Gaze target helper config failed: Cannot find right hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent <GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added right hand as gaze target"); } } }
private void Glance(GazeTarget gazeTarget) { if (!started || !((GazeState == GazeTarget.Person || GazeState == GazeTarget.Person2) && gazeTarget != GazeTarget.Person && gazeTarget != GazeTarget.Person2)) return; currentGazeInterval = GlanceInterval; currentRandomAmplitude = GlanceRandomAmplitude; if (gazeTarget == GazeTarget.ThroughMap) glanceThroughMapToDo = GlanceThroughMapCount - 1; if (gazeTarget == GazeTarget.AcrossRoom) { currentRandomAmplitude = GazeRandomAmplitude; glanceAcrossRoomToDo = GlanceAcrossRoomCount - 1; } GlanceToTarget(gazeTarget); }
internal void Gaze(GazeTarget GazeTarget, bool dontPerform = false) { if (!started) return; ignoreClick = true; currentGazeInterval = GazeInterval; currentRandomAmplitude = GazeRandomAmplitude; SwitchGazeTarget(GazeTarget, dontPerform); }
internal void GlanceToTarget(GazeTarget target) { SetGazeTime(GlanceInterval); backFromGlance = true; GenerateGaze(target, GazeCoordinates(target), DefaultGazeSpeed / 2); }
internal void SwitchGazeTarget(GazeTarget target, bool dontPerform = false) { if (!started) return; NotifyGazeTargetChanged(target); GazeState = target; if (!dontPerform) GenerateGaze(); }
private void NotifyGazeTargetChanged(GazeTarget gazeTarget) { if (GazeTargetChanged != null) GazeTargetChanged(gazeTarget); }
private void ConfigureHelpers() { Transform head = transform.Find("body/body_renderPart_0/root_JNT/body_JNT/chest_JNT/neckBase_JNT/neck_JNT/head_JNT"); if (head == null) { AvatarLogger.LogError("Avatar helper config failed. Cannot find head transform. All helpers spawning on root avatar transform"); head = transform; } if (MouthAnchor == null) { MouthAnchor = CreateHelperObject(head, MOUTH_HEAD_OFFSET, MOUTH_HELPER_NAME); } if (GetComponent <OvrAvatarLocalDriver>() != null) { if (audioSource == null) { audioSource = MouthAnchor.gameObject.AddComponent <AudioSource>(); } spatializedSource = MouthAnchor.GetComponent <ONSPAudioSource>(); if (spatializedSource == null) { spatializedSource = MouthAnchor.gameObject.AddComponent <ONSPAudioSource>(); } spatializedSource.UseInvSqr = true; spatializedSource.EnableRfl = false; spatializedSource.EnableSpatialization = true; spatializedSource.Far = 100f; spatializedSource.Near = 0.1f; // Add phoneme context to the mouth anchor lipsyncContext = MouthAnchor.GetComponent <OVRLipSyncContext>(); if (lipsyncContext == null) { lipsyncContext = MouthAnchor.gameObject.AddComponent <OVRLipSyncContext>(); } lipsyncContext.provider = EnableLaughter ? OVRLipSync.ContextProviders.Enhanced_with_Laughter : OVRLipSync.ContextProviders.Enhanced; // Ignore audio callback if microphone is owned by VoIP lipsyncContext.skipAudioSource = !CanOwnMicrophone; StartCoroutine(WaitForMouthAudioSource()); } if (GetComponent <OvrAvatarRemoteDriver>() != null) { GazeTarget headTarget = head.gameObject.AddComponent <GazeTarget>(); headTarget.Type = ovrAvatarGazeTargetType.AvatarHead; AvatarLogger.Log("Added head as gaze target"); Transform hand = transform.Find("hand_left"); if (hand == null) { AvatarLogger.LogWarning("Gaze target helper config failed: Cannot find left hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent <GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added left hand as gaze target"); } hand = transform.Find("hand_right"); if (hand == null) { AvatarLogger.Log("Gaze target helper config failed: Cannot find right hand transform"); } else { GazeTarget handTarget = hand.gameObject.AddComponent <GazeTarget>(); handTarget.Type = ovrAvatarGazeTargetType.AvatarHand; AvatarLogger.Log("Added right hand as gaze target"); } } }
private Vector2D GazeCoordinates(GazeTarget target) { switch (target) { case GazeTarget.Person: if (SkeneClient.PersonLocation.ContainsKey(0)) return SkeneClient.PersonLocation[0]; else return Vector2D.Zero; case GazeTarget.Person2: if (SkeneClient.PersonLocation.ContainsKey(1)) return SkeneClient.PersonLocation[1]; else return Vector2D.Zero; case GazeTarget.Angle: return currentGazeAnglePoint; case GazeTarget.Clicks: return SkeneClient.LastTouchOnScreenCoords; case GazeTarget.ScreenPoint: return currentScreenPoint; case GazeTarget.None: case GazeTarget.ThroughMap: case GazeTarget.AcrossRoom: case GazeTarget.Random: default: return Vector2D.Zero; } }