Source upload

This commit is contained in:
SDraw 2022-03-21 12:29:49 +00:00 committed by SDraw
parent 50162481eb
commit 51ad6da4c3
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
51 changed files with 14957 additions and 0 deletions

53
ml_lme_cvr/LeapIK.cs Normal file
View file

@ -0,0 +1,53 @@
using UnityEngine;
namespace ml_lme_cvr
{
[RequireComponent(typeof(Animator))]
[DisallowMultipleComponent]
public class LeapIK : MonoBehaviour
{
bool m_enabled = true;
bool m_fingersOnly = false;
Animator m_animator = null;
Transform m_leftHand = null;
Transform m_rightHand = null;
void Start()
{
m_animator = this.GetComponent<Animator>();
}
void OnAnimatorIK()
{
if(m_enabled && !m_fingersOnly && (m_animator != null))
{
if(m_leftHand != null)
{
m_animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1f);
m_animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1f);
m_animator.SetIKPosition(AvatarIKGoal.LeftHand, m_leftHand.position);
m_animator.SetIKRotation(AvatarIKGoal.LeftHand, m_leftHand.rotation);
}
if(m_rightHand != null)
{
m_animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1f);
m_animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1f);
m_animator.SetIKPosition(AvatarIKGoal.RightHand, m_rightHand.position);
m_animator.SetIKRotation(AvatarIKGoal.RightHand, m_rightHand.rotation);
}
}
}
public void SetEnabled(bool p_state) => m_enabled = p_state;
public void SetFingersOnly(bool p_state) => m_fingersOnly = p_state;
public void SetHands(Transform p_left, Transform p_right)
{
m_leftHand = p_left;
m_rightHand = p_right;
}
}
}