/// <summary> Update the Glove wireframe based off a GlovePose </summary> /// <param name="glovePose"></param> public void UpdateGlove(SGCore.SG.SG_GlovePose glovePose) { if (glovePose != null && this.gloveBase.activeInHierarchy) { Quaternion[][] angles = SG.Util.SG_Conversions.ToUnityQuaternions(glovePose.JointRotations); Vector3[][] positions = SG.Util.SG_Conversions.ToUnityPositions(glovePose.JointPositions); if (gloveJoints != null) { for (int f = 0; f < gloveJoints.Length; f++) { if (angles.Length > f) { for (int j = 0; j < gloveJoints[f].Length; j++) { if (angles[f].Length > j) { gloveJoints[f][j].rotation = this.wristTransform.rotation * (angles[f][j]); gloveJoints[f][j].localPosition = positions[f][j]; } } } } } } }
// Update is called once per frame void Update() { //Keybinds if (Input.GetKeyDown(this.toggleGloveKey)) { this.GloveVisible = !GloveVisible; } if (Input.GetKeyDown(this.toggleHandKey)) { this.HandVisible = !HandVisible; } //Automated Updates if (this.glove != null && glove.IsConnected) { if (!setupComplete) { setupComplete = true; this.HandGeometry = SGCore.Kinematics.BasicHandModel.Default(this.glove.IsRight); //Debug.Log("WireFrame; " + this.HandGeometry.ToString()); this.CalibrateWrist(); SG_HandPose idleHand = SG_HandPose.Idle(glove.IsRight); this.UpdateHand(idleHand); if (this.glove.InternalGlove is SGCore.SG.SenseGlove) { // Debug.Log("Generated glove model for " + this.glove.GetInternalObject().GetDeviceID()); SGCore.SG.SG_GloveInfo gloveModel = ((SGCore.SG.SenseGlove) this.glove.InternalGlove).GetGloveModel(); GenerateGlove(gloveModel); SGCore.SG.SG_GlovePose idlePose = SGCore.SG.SG_GlovePose.IdlePose(gloveModel); this.UpdateGlove(idlePose); } } if (this.wristTransform != null && this.foreArmTransform != null) { if (Input.GetKeyDown(this.resetWristKey)) { this.CalibrateWrist(); } Quaternion imu; if (this.glove.GetIMURotation(out imu)) { this.UpdateWrist(imu); } } if (this.gloveBase.activeInHierarchy) { this.UpdateGlove(); } if (this.handBase.activeInHierarchy) { this.UpdateHand(); } } }