mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-06 03:39:23 +00:00
Removed Upright
Leading hand option Hands extension with `Q`/`E` Joints fix Update to LeapSDK 5.16
This commit is contained in:
parent
b6a200d44c
commit
aebf6c2c4e
22 changed files with 9131 additions and 6719 deletions
63
ml_pam/TPoseHelper.cs
Normal file
63
ml_pam/TPoseHelper.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
|
||||
namespace ml_pam
|
||||
{
|
||||
class TPoseHelper
|
||||
{
|
||||
static readonly float[] ms_tposeMuscles = typeof(BodySystem).GetField("TPoseMuscles", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as float[];
|
||||
|
||||
HumanPoseHandler m_poseHandler = null;
|
||||
HumanPose m_oldPose;
|
||||
HumanPose m_newPose;
|
||||
Vector3 m_hipsLocalPos = Vector3.zero;
|
||||
Transform m_hips = null;
|
||||
|
||||
public void Assign(Animator p_animator)
|
||||
{
|
||||
if(m_poseHandler != null)
|
||||
{
|
||||
m_poseHandler = new HumanPoseHandler(p_animator.avatar, p_animator.transform);
|
||||
m_hips = p_animator.GetBoneTransform(HumanBodyBones.Hips);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unassign()
|
||||
{
|
||||
m_poseHandler?.Dispose();
|
||||
m_poseHandler = null;
|
||||
m_oldPose = new HumanPose();
|
||||
m_newPose = new HumanPose();
|
||||
m_hips = null;
|
||||
m_hipsLocalPos = Vector3.zero;
|
||||
}
|
||||
|
||||
public void Apply()
|
||||
{
|
||||
if(m_hips != null)
|
||||
m_hipsLocalPos = m_hips.localPosition;
|
||||
|
||||
if(m_poseHandler != null)
|
||||
{
|
||||
m_poseHandler.GetHumanPose(ref m_oldPose);
|
||||
m_newPose.bodyPosition = m_oldPose.bodyPosition;
|
||||
m_newPose.bodyRotation = m_oldPose.bodyRotation;
|
||||
m_newPose.muscles = new float[m_oldPose.muscles.Length];
|
||||
for(int i = 0, j = m_newPose.muscles.Length; i < j; i++)
|
||||
m_newPose.muscles[i] = ms_tposeMuscles[i];
|
||||
|
||||
m_poseHandler.SetHumanPose(ref m_newPose);
|
||||
}
|
||||
}
|
||||
|
||||
public void Restore()
|
||||
{
|
||||
if(m_poseHandler != null)
|
||||
m_poseHandler.SetHumanPose(ref m_oldPose);
|
||||
|
||||
if(m_hips != null)
|
||||
m_hips.localPosition = m_hipsLocalPos;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue