private void AssignHandJoint(RigidPose handPose, bool isLeft, JointEnumArray joints, HandJointName jointName, VRBoneTransform_t[] boneTransforms, int steamBoneIndex) { VRBoneTransform_t bone = boneTransforms[steamBoneIndex]; Vector3 position = new Vector3(-bone.position.v0, bone.position.v1, bone.position.v2); Quaternion rotation = new Quaternion(bone.orientation.x, -bone.orientation.y, -bone.orientation.z, bone.orientation.w); if (steamBoneIndex == SteamVR_Skeleton_JointIndexes.wrist) { if (isLeft) { rotation *= s_leftSkeletonWristFixRotation; } else { rotation *= s_rightSkeletonWristFixRotation; } } else { if (isLeft) { rotation *= s_leftSkeletonFixRotation; } else { rotation *= s_rightSkeletonFixRotation; } } joints[jointName] = new JointPose(handPose * new RigidPose(position, rotation)); }
public void CopyFrom(DeviceState state) { m_serialNumber = state.m_serialNumber; m_modelNumber = state.m_modelNumber; m_renderModelName = state.m_renderModelName; m_deviceClass = state.m_deviceClass; m_deviceModel = state.m_deviceModel; m_input2DType = state.m_input2DType; m_isPoseValid = state.m_isPoseValid; m_isConnected = state.m_isConnected; m_isOutOfRange = state.m_isOutOfRange; m_isCalibrating = state.m_isCalibrating; m_isUninitialized = state.m_isUninitialized; m_velocity = state.m_velocity; m_angularVelocity = state.m_angularVelocity; m_position = state.m_position; m_rotation = state.m_rotation; m_buttonPressed = state.m_buttonPressed; m_buttonTouched = state.m_buttonTouched; Array.Copy(state.m_axisValue, m_axisValue, m_axisValue.Length); if (state.m_handJoints == null) { m_handJoints = null; } else { if (m_handJoints == null) { m_handJoints = new JointEnumArray(); } m_handJoints.CopyFrom(state.m_handJoints); } }