/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * Licensed under the Oculus SDK License Agreement (the "License"); * you may not use the Oculus SDK except in compliance with the License, * which is provided at the time of installation or download, or which * otherwise accompanies this software in either electronic or hard copy form. * * You may obtain a copy of the License at * * https://developer.oculus.com/licenses/oculussdk/ * * Unless required by applicable law or agreed to in writing, the Oculus SDK * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using UnityEngine; namespace Oculus.Interaction.Input { /// /// The data asset used by to pipe /// data through the stack, /// and contains hand state data. /// [Serializable] public class HandDataAsset : ICopyFrom { /// /// Is the data in this asset considered valid. /// public bool IsDataValid; /// /// Is the hand a connected input device to the headset. /// public bool IsConnected; /// /// Is the hand being tracked by the headset. /// public bool IsTracked; /// /// The root pose of the hand, which typically represents the /// wrist position. See /// for information on how this pose was created. /// public Pose Root; /// /// Information about how was created, for example /// whether it is the raw pose from tracking, or whether is has been /// filtered or modified in the stack. /// public PoseOrigin RootPoseOrigin; #if ISDK_OPENXR_HAND /// /// An array containing joint poses of the hand skeleton. /// This array is indexed by the integer values of the enum. /// public Pose[] JointPoses = new Pose[Constants.NUM_HAND_JOINTS]; /// /// An array containing radii for each hand skeleton joint. /// This array is indexed by the integer values of the enum. /// public float[] JointRadii = new float[Constants.NUM_HAND_JOINTS]; [System.Obsolete("Deprecated. Use JointPoses instead.")] #endif /// /// An array containing joint orientations of the hand skeleton. /// This array is indexed by the integer values of the enum. /// public Quaternion[] Joints = new Quaternion[Constants.NUM_HAND_JOINTS]; /// /// True if the tracking system considers the tracking data as high confidence, /// which can be used to determine how accurate the supplied pose data is. /// public bool IsHighConfidence; /// /// An array of booleans representing finger pinch states, where True /// represents a finger that is performing a pinch gesture. /// This array is indexed by the values of the enum. /// public bool[] IsFingerPinching = new bool[Constants.NUM_FINGERS]; /// /// Similar to but per-finger. Represents the /// tracking system's confidence in the accuracy of each finger. /// This array is indexed by the values of the enum. /// public bool[] IsFingerHighConfidence = new bool[Constants.NUM_FINGERS]; /// /// An array of values representing finger pinch states, where the strength value /// represents the strength of the pinch being provided for each finger. /// This array is indexed by the values of the enum. /// public float[] FingerPinchStrength = new float[Constants.NUM_FINGERS]; /// /// The scale of the hand as provided by the system. /// public float HandScale; /// /// The pointer pose for the hand, which is generally used as the /// raycast source pose. See /// for information on how this pose was created. /// public Pose PointerPose; /// /// Information about how was created, for example /// whether it is the raw pose from tracking, or whether is has been /// filtered or modified in the stack. /// public PoseOrigin PointerPoseOrigin; /// /// True if this hand is considered the dominant hand, /// as set by the system handedness. /// public bool IsDominantHand; /// /// This data object contains configuration data that is shuttled /// through the stack. /// public HandDataSourceConfig Config = new HandDataSourceConfig(); /// /// Convenience property which returns true if /// and are both true. /// public bool IsDataValidAndConnected => IsDataValid && IsConnected; /// /// Copies the provided into the caller. /// /// The source to copy from. public void CopyFrom(HandDataAsset source) { IsDataValid = source.IsDataValid; IsConnected = source.IsConnected; IsTracked = source.IsTracked; IsHighConfidence = source.IsHighConfidence; IsDominantHand = source.IsDominantHand; Config = source.Config; CopyPosesFrom(source); } /// /// Copies only pose data from a provided /// into the caller. /// /// The source to copy from. public void CopyPosesFrom(HandDataAsset source) { Root = source.Root; RootPoseOrigin = source.RootPoseOrigin; #if ISDK_OPENXR_HAND Array.Copy(source.JointPoses, JointPoses, Constants.NUM_HAND_JOINTS); Array.Copy(source.JointRadii, JointRadii, source.JointRadii.Length); #endif #pragma warning disable 0618 Array.Copy(source.Joints, Joints, Constants.NUM_HAND_JOINTS); #pragma warning restore 0618 Array.Copy(source.IsFingerPinching, IsFingerPinching, IsFingerPinching.Length); Array.Copy(source.IsFingerHighConfidence, IsFingerHighConfidence, IsFingerHighConfidence.Length); Array.Copy(source.FingerPinchStrength, FingerPinchStrength, FingerPinchStrength.Length); HandScale = source.HandScale; PointerPose = source.PointerPose; PointerPoseOrigin = source.PointerPoseOrigin; Config = source.Config; } } }