// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using System;
using UltimateXR.Manipulation.HandPoses;
using UnityEngine;
namespace UltimateXR.Manipulation
{
///
/// Describes how an object is grabbed. It tells the pose that will be used and how it will be snapped to the hand.
/// The key is stored in the object, ideally we would have Dictionary(key, GripPoseInfo) but since Unity does not
/// serialize Dictionaries we use a List(GripPoseInfo) containing the key () as well.
///
[Serializable]
public class UxrGripPoseInfo
{
#region Inspector Properties/Serialized Fields
[SerializeField] private string _avatarPrefabGuid;
[SerializeField] private UxrHandPoseAsset _handPose;
[SerializeField] private float _poseBlendValue;
[SerializeField] private Transform _gripAlignTransformHandLeft;
[SerializeField] private Transform _gripAlignTransformHandRight;
#endregion
#region Public Types & Data
///
/// Gets the GUID of the avatar prefab the grip pose info belongs to.
///
public string AvatarPrefabGuid => _avatarPrefabGuid;
///
/// Gets or sets the left grab pose preview mesh.
///
public Mesh GrabPoseMeshLeft { get; set; }
///
/// Gets or sets the right grab pose preview mesh.
///
public Mesh GrabPoseMeshRight { get; set; }
///
/// Gets or sets the pose that will be used when grabbing.
///
public UxrHandPoseAsset HandPose
{
get => _handPose;
set => _handPose = value;
}
///
/// Gets or sets the pose blend value if the pose has the possibility of blending. Blending is used to blend between
/// open/closed grips or other animations.
///
public float PoseBlendValue
{
get => _poseBlendValue;
set => _poseBlendValue = value;
}
///
/// Gets or sets the that will be used to align the object grab point to the left
/// that grabbed it.
///
public Transform GripAlignTransformHandLeft
{
get => _gripAlignTransformHandLeft;
set => _gripAlignTransformHandLeft = value;
}
///
/// Gets or sets the that will be used to align the object grab point to the right
/// that grabbed it.
///
public Transform GripAlignTransformHandRight
{
get => _gripAlignTransformHandRight;
set => _gripAlignTransformHandRight = value;
}
#endregion
#region Constructors & Finalizer
///
/// Constructor.
///
///
/// Avatar prefab GUID. Using prefabs allows to share poses among instances and also prefab variants to inherit poses
/// from their parent prefabs in the chain
///
public UxrGripPoseInfo(string avatarPrefabGuid)
{
if (!string.IsNullOrEmpty(avatarPrefabGuid))
{
_avatarPrefabGuid = avatarPrefabGuid;
}
}
#endregion
}
}