private void SaveGloveData(SenseGlove_Object senseGlove) { Vector3[] positions = senseGlove.StartJointPositions; float[][] lengths = senseGlove.FingerLengths; if (true) { try { StreamWriter writer = new StreamWriter(GenerateFileName(senseGlove)); for (int f = 0; f < positions.Length; f++) { string line = ""; line += positions[f].x + "\t" + positions[f].y + "\t" + positions[f].z; line += "\t"; line += lengths[f][0] + "\t" + lengths[f][1] + "\t" + lengths[f][2]; writer.WriteLine(line); } writer.Close(); Debug.Log("Saved Glove Lenghts of " + senseGlove.gameObject.name); } catch (System.Exception Ex) { Debug.Log(Ex.Message); } } }
/// <summary> Link the SenseGlove_Object to a sense glove in DeviceManager Memory. </summary> /// <param name="obj"></param> /// <param name="gloveIndex"></param> /// <remarks> Possible duplicate of the SenseGlove_Object.LinkToGlove, though this one is accessible through a static method. v</remarks> public static void LinkObject(SenseGlove_Object obj, int gloveIndex) { if (obj != null) { obj.LinkToGlove(gloveIndex); } }
// Use this for initialization void Start() { if (this.senseGlove == null) { this.senseGlove = this.gameObject.GetComponent <SenseGlove_Object>(); } }
//----------------------------------------------------------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization protected virtual void Start() { if (senseGlove == null) { senseGlove = this.GetComponent <SenseGlove_Object>(); } if (senseGlove != null) { senseGlove.GloveLoaded += SenseGlove_OnGloveLoaded; senseGlove.CalibrationFinished += SenseGlove_OnCalibrationFinished; } if (this.foreArmTransfrom == null) { this.foreArmTransfrom = this.transform; } this.CollectFingerJoints(); this.CollectCorrections(); this.SetupGrabScript(); this.SetupFeedbackColliders(); if (this.fingerJoints.Count > 0) { this.CollectHandParameters(); } }
//Runs once after Awake protected virtual void Start() { if (this.senseGlove == null) { this.senseGlove = this.GetComponent <SenseGlove_Object>(); } this.Setup(); }
//--------------------------------------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization void Start() { this.senseGlove = this.gameObject.GetComponent <SenseGlove_Object>(); if (this.senseGlove != null) { this.senseGlove.OnCalibrationFinished += SenseGlove_OnCalibrationFinished; } this.grabScript = this.gameObject.GetComponent <SenseGlove_PhysGrab>(); }
//-------------------------------------------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization protected virtual void Start() { instance = this; this.CheckForDeviceManager(); UpdateThread updateThread = new UpdateThread(solver, limitFingers, updateWrist); Thread t = new Thread(new ThreadStart(updateThread.ThreadProc)); t.Start(); }
//--------------------------------------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization void Start() { this.senseGlove = this.gameObject.GetComponent <SenseGlove_Object>(); if (this.senseGlove != null) { this.senseGlove.CalibrationFinished += SenseGlove_OnCalibrationFinished; } this.grabScript = this.gameObject.GetComponent <SenseGlove_GrabScript>(); this.model = this.senseGlove.GetComponent <SenseGlove_HandModel>(); }
// Use this for initialization void Start() { this.LastCalibrationData = ""; this.senseGlove = this.gameObject.GetComponent <SenseGlove_Object>(); if (this.senseGlove != null) //Redundant check, should never happen. { this.senseGlove.GloveLoaded += SenseGlove_GloveLoaded; this.senseGlove.CalibrationFinished += SenseGlove_CalibrationFinished; } }
//-------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization void Start() { UserProfiles.LoadDB(Application.dataPath + UserProfiles.datafolder); this.senseGlove = this.gameObject.GetComponent <SenseGlove_Object>(); if (this.senseGlove != null) { this.senseGlove.OnGloveLoaded += SenseGlove_OnGloveLoaded; this.senseGlove.OnCalibrationFinished += SenseGlove_OnCalibrationFinished; } }
/// <summary> /// Set reference to instances /// </summary> void OnEnable() { if (RightHand) { senseGloveObjectRight = GameObject.FindGameObjectWithTag("SenseGloveRight").transform.GetChild(0).GetComponent <SenseGlove_Object>(); fingersRight = new int[] { 0, 0, 0, 0, 0 }; } if (LeftHand) { senseGloveObjectLeft = GameObject.FindGameObjectWithTag("SenseGloveLeft").transform.GetChild(0).GetComponent <SenseGlove_Object>(); fingersLeft = new int[] { 0, 0, 0, 0, 0 }; } }
//----------------------------------------------------------------------------------------------------------------------------------------- // Monobehaviour //Load Resources before Start() function is called protected virtual void Awake() { if (this.senseGlove == null) { this.senseGlove = this.gameObject.GetComponent <SenseGlove_Object>(); } if (this.handModel == null) { this.handModel = this.gameObject.GetComponent <SenseGlove_HandModel>(); } if (this.grabReference != null) { this.lastPosition = grabReference.transform.position; } }
public void LoadGloveData(SenseGlove_Object senseGlove) { if (saveLengths || saveStartpos) { try { string[] lines = File.ReadAllLines(GenerateFileName(senseGlove)); if (lines.Length >= 5) { Vector3[] positions = new Vector3[5]; float[][] lengths = new float[5][]; for (int f = 0; f < positions.Length; f++) { string[] split = lines[f].Split('\t'); if (split.Length >= 3) { float x = SenseGloveCs.Values.toFloat(split[0]); float y = SenseGloveCs.Values.toFloat(split[1]); float z = SenseGloveCs.Values.toFloat(split[2]); positions[f] = new Vector3(x, y, z); } if (split.Length >= 6) { float PP = SenseGloveCs.Values.toFloat(split[3]); float MP = SenseGloveCs.Values.toFloat(split[4]); float DP = SenseGloveCs.Values.toFloat(split[5]); lengths[f] = new float[] { PP, MP, DP }; } } if (saveLengths && lengths.Length > 0) { senseGlove.FingerLengths = (lengths); } if (saveStartpos && positions.Length > 0) { senseGlove.StartJointPositions = (positions); } } } catch (System.Exception Ex) { Debug.Log(Ex.Message); } } }
protected override void Instance_LoadedSetupChanged(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e) { if (e.currentSetup.handSDKInfo.type == hapticSystemInfo.ConnectedSDKType) { #if VRTK_DEFINE_SDK_SENSE_GLOVE if (isRightHand) { glove = e.currentSetup.handSDK.GetRightHand().GetComponent <SenseGlove_Object>(); } else { glove = e.currentSetup.handSDK.GetLeftHand().GetComponent <SenseGlove_Object>(); } #endif } }
/// <summary> Add a SenseGlove_Object to this Device Manager's watch list, which automatically connects a new Sense Glove if one is detected. </summary> /// <param name="obj"></param> public void AddToWatchList(SenseGlove_Object obj) { if (obj != null) { //todo: check if it exists for (int i = 0; i < this.senseGloves.Count; i++) { if (System.Object.ReferenceEquals(this.senseGloves[i], obj)) { return; //it is already in the list } } //if we go here, it is not in the list. this.senseGloves.Add(obj); } }
// Use this for initialization void Start() { if (senseGlove == null) { senseGlove = this.GetComponent <SenseGlove_Object>(); } if (senseGlove != null) { if (senseGlove.foreArm == null) { senseGlove.foreArm = this.foreArmTransfrom.gameObject; } senseGlove.OnGloveLoaded += SenseGlove_OnGloveLoaded; senseGlove.OnCalibrationFinished += SenseGlove_OnCalibrationFinished; } }
/// <summary> Attempt to link a new glove to one of our assigned SenseGlove_Objects. Fire a GloveDetected event afterwards.? </summary> /// <param name="glove"></param> private void AssignNewGlove(SenseGlove glove) { if (GetGloveIndex(glove.DeviceID()) < 0) //It is a new glove { SenseGlove_DeviceManager.detectedGloves.Add(glove); SenseGlove_DeviceManager.gloveLinked.Add(false); int index = detectedGloves.Count - 1; bool linked = false; bool isRight = glove.IsRight(); //attempt to assign it to existing SenseGlove_Objects? for (int i = 0; i < this.senseGloves.Count; i++) { if (this.senseGloves[i] != null) { if (!this.senseGloves[i].IsLinked && SenseGlove_Object.MatchesConnection(isRight, senseGloves[i].connectionMethod)) { //This Sense Glove is elligible for a connection and is not already connected. bool succesfullLink = this.senseGloves[i].LinkToGlove(index); if (succesfullLink) { //only when it is actually assigned do we break. SenseGlove_DeviceManager.gloveLinked[index] = true; //we linked the glove at Index. linked = true; break; } } } else { //Warn devs when their SenseGlove_Objects have not been assigned. Debug.LogError("NullRefrence exception occured in " + this.name + ". You likely haven't assigned it via the inspector."); } } if (!linked) { this.OnGloveDetected(glove, index); //only fire event if the glove was not assigned. } } else { Debug.LogWarning("GloveDetected event was fired twice for the same device. Most likely you have two instances of DeviceManager running. " + "We reccommend removing duplicate instances."); } }
private void MarkTouching(SenseGlove_Object obj, bool touching) { if (obj != null) { for (int i = 0; i < this.touchedGloves.Count; i++) { if (GameObject.ReferenceEquals(obj, this.touchedGloves[i])) //we've found it! { if (!touching) { this.touchedGloves.RemoveAt(i); } //if we are already touching, just return... return; } } //we've not found it in the list if (touching) { this.touchedGloves.Add(obj); } } }
//----------------------------------------------------------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization void Start() { if (senseGlove == null) { senseGlove = this.GetComponent <SenseGlove_Object>(); } if (senseGlove != null) { if (senseGlove.foreArm == null) { senseGlove.foreArm = this.foreArmTransfrom.gameObject; } senseGlove.OnGloveLoaded += SenseGlove_OnGloveLoaded; senseGlove.OnCalibrationFinished += SenseGlove_OnCalibrationFinished; } this.CollectFingerJoints(); this.CollectCorrections(); this.SetupGrabScript(); this.SetupFeedbackColliders(); }
//---------------------------------------------------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization protected virtual void Start() { if (this.senseGlove != null) { senseGlove_Object = this.GetComponent <SenseGlove_Object>(); this.grabScript = this.senseGlove.gameObject.GetComponent <SenseGlove_GrabScript>(); } CreatePointer(); SetPointer(false); SetHighlights(false); this.coolDownTimer = this.coolDown; //set to equal so we can select right away. allGameObjects = Resources.FindObjectsOfTypeAll(typeof(GameObject)); foreach (GameObject obj in allGameObjects) { if (obj.name == "GUISave") { guiSave = obj; } if (obj.name == "GUILoad") { guiLoad = obj; } } }
//--------------------------------------------------------------------------------------------------------------------- // Monobehaviour #region Monobehaviour // Use this for initialization void Start() { this.senseGlove = this.gameObject.GetComponent <SenseGlove_Object>(); this.grabScript = this.gameObject.GetComponent <SenseGlove_PhysGrab>(); }
private static string GenerateFileName(SenseGlove_Object glove) { return("" + glove.gameObject.name + ".txt"); }
/// <summary> /// Set the reference to the right SenseGlove /// and initialize the array determining the buzz intensity for each finger. /// </summary> void Start() { senseGloveObject = GameObject.FindGameObjectWithTag("SenseGloveRight").GetComponent <SenseGlove_Object>(); fingers = new int[] { 0, 0, 0, 0, 0 }; }