// Update is called once per frame protected virtual void Update() { if (m_hdProvider != null) { lock (m_hdProvider) { //Get the valid hands List <HandDetected> validHDs = m_hdProvider.GetHandsNotOnBody(0.15f); if (validHDs.Count > 0) { m_isHandDetected = true; HandDetected hd = m_hdProvider.GetOptimalHand(validHDs); m_handPosition = hd.Position; //Adjust to fingers m_handPosition += PointingFunctions.GetFingerOffset(m_headsetTransform, m_hdProvider.Handedness); m_targetPosition = m_wim.transform.worldToLocalMatrix.MultiplyPoint3x4(m_handPosition); } } } //We do this because it permits to use the same code for both the local user and the remote collaborators embodiement if (m_wim != null) { HandPositionGO.transform.position = m_wim.transform.localToWorldMatrix.MultiplyPoint3x4(m_targetPosition); } if (m_original != null) { OriginalHandPositionGO.transform.position = m_original.transform.localToWorldMatrix.MultiplyPoint3x4(m_targetPosition); } }
void Update() { if (m_hdProvider != null) { lock (m_hdProvider) { List <HandDetected> validHDs = m_hdProvider.GetHandsNotOnBody(0.15f); if (validHDs.Count > 0) { m_isHandDetected = true; HandDetected hd = m_hdProvider.GetOptimalHand(validHDs); RayObject.SetActive(true); //Pointing Vector3 anchorPoint = Camera.main.transform.position + new Vector3(0, -0.15f, 0); Vector3 pointDir = (hd.Position - anchorPoint).normalized; m_pointingDir = pointDir; m_handPosition = hd.Position; //m_handPosition += PointingFunctions.GetFingerOffset(m_headsetTransform, Handedness.RIGHT); float handMagnitude = (anchorPoint - hd.Position).magnitude; Vector3 remotePosition; if (handMagnitude < MIN_MAGNITUDE) { remotePosition = anchorPoint + m_pointingDir * handMagnitude; } else { remotePosition = anchorPoint + m_pointingDir * 13.0f * (handMagnitude - MIN_MAGNITUDE); } m_remotePosition = m_hdProvider.Smoothness * m_remotePosition + (1.0f - m_hdProvider.Smoothness) * remotePosition; m_targetPosition = m_currentSubDataset.transform.worldToLocalMatrix.MultiplyPoint3x4(m_remotePosition); } } } //We do this because it permits to use the same code for both the local user and the remote collaborators embodiement if (m_currentSubDataset) { Vector3 anchorPoint = m_headsetTransform.position + new Vector3(0, -0.15f, 0); Vector3 targetPos = m_currentSubDataset.transform.localToWorldMatrix.MultiplyPoint3x4(m_targetPosition); Vector3 rayVec = targetPos - anchorPoint; rayVec = rayVec.normalized; //Scale about 10% Vector3 scale = RayObject.transform.localScale; scale.y = (targetPos - anchorPoint).magnitude / 2.0f * 1.10f; RayObject.transform.localScale = scale; RayObject.transform.up = rayVec; RayObject.transform.localPosition = anchorPoint + rayVec * RayObject.transform.localScale.y; PosObject.transform.localPosition = targetPos; } }