Hands visualization

This commit is contained in:
SDraw 2023-07-03 11:16:26 +03:00
parent 5d2bc0e6b8
commit f645650659
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
10 changed files with 155 additions and 5 deletions

View file

@ -17,6 +17,9 @@ namespace ml_lme
GameObject m_leapElbowLeft = null;
GameObject m_leapElbowRight = null;
GameObject m_leapControllerModel = null;
GameObject m_visualHands = null;
VisualHand m_visualHandLeft = null;
VisualHand m_visualHandRight = null;
float m_scaleRelation = 1f;
@ -58,8 +61,21 @@ namespace ml_lme
m_leapControllerModel.transform.localRotation = Quaternion.identity;
}
m_visualHands = AssetsHandler.GetAsset("assets/models/hands/leaphands.prefab");
if(m_visualHands != null)
{
m_visualHands.name = "VisualHands";
m_visualHands.transform.parent = this.transform;
m_visualHands.transform.localPosition = Vector3.zero;
m_visualHands.transform.localRotation = Quaternion.identity;
m_visualHandLeft = new VisualHand(m_visualHands.transform.Find("HandL"), true);
m_visualHandRight = new VisualHand(m_visualHands.transform.Find("HandR"), false);
}
Settings.DesktopOffsetChange += this.OnDesktopOffsetChange;
Settings.ModelVisibilityChange += this.OnModelVisibilityChange;
Settings.VisualHandsChange += this.OnVisualHandsChange;
Settings.TrackingModeChange += this.OnTrackingModeChange;
Settings.RootAngleChange += this.OnRootAngleChange;
Settings.HeadAttachChange += this.OnHeadAttachChange;
@ -68,6 +84,7 @@ namespace ml_lme
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
OnModelVisibilityChange(Settings.ModelVisibility);
OnVisualHandsChange(Settings.VisualHands);
OnTrackingModeChange(Settings.TrackingMode);
OnRootAngleChange(Settings.RootAngle);
}
@ -102,21 +119,33 @@ namespace ml_lme
if(l_data.m_leftHand.m_present)
{
Utils.LeapToUnity(ref l_data.m_leftHand.m_position, ref l_data.m_leftHand.m_rotation, Settings.TrackingMode);
for(int i = 0; i < 20; i++)
Utils.LeapToUnity(ref l_data.m_leftHand.m_fingerPosition[i], ref l_data.m_leftHand.m_fingerRotation[i], Settings.TrackingMode);
m_leapHandLeft.transform.localPosition = l_data.m_leftHand.m_position;
m_leapHandLeft.transform.localRotation = l_data.m_leftHand.m_rotation;
Utils.LeapToUnity(ref l_data.m_leftHand.m_elbowPosition, ref ms_identityRotation, Settings.TrackingMode);
m_leapElbowLeft.transform.localPosition = l_data.m_leftHand.m_elbowPosition;
if(Settings.VisualHands)
m_visualHandLeft?.Update(l_data.m_leftHand);
}
if(l_data.m_rightHand.m_present)
{
Utils.LeapToUnity(ref l_data.m_rightHand.m_position, ref l_data.m_rightHand.m_rotation, Settings.TrackingMode);
for(int i = 0; i < 20; i++)
Utils.LeapToUnity(ref l_data.m_rightHand.m_fingerPosition[i], ref l_data.m_rightHand.m_fingerRotation[i], Settings.TrackingMode);
m_leapHandRight.transform.localPosition = l_data.m_rightHand.m_position;
m_leapHandRight.transform.localRotation = l_data.m_rightHand.m_rotation;
Utils.LeapToUnity(ref l_data.m_rightHand.m_elbowPosition, ref ms_identityRotation, Settings.TrackingMode);
m_leapElbowRight.transform.localPosition = l_data.m_rightHand.m_elbowPosition;
if(Settings.VisualHands)
m_visualHandRight?.Update(l_data.m_rightHand);
}
}
}
@ -138,6 +167,11 @@ namespace ml_lme
m_leapControllerModel.SetActive(p_state);
}
void OnVisualHandsChange(bool p_state)
{
m_visualHands.SetActive(p_state);
}
void OnTrackingModeChange(Settings.LeapTrackingMode p_mode)
{
switch(p_mode)