@@ -101,16 +101,11 @@ public class RiggedHandVisualizer : BaseHandVisualizer
101101 /// </summary>
102102 public SkinnedMeshRenderer HandRenderer => handRenderer ;
103103
104- /// <summary>
105- /// Caching the hand material from CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.RiggedHandMeshMaterial
106- /// </summary>
107- private Material handMaterial = null ;
108-
109104 /// <summary>
110105 /// Hand material to use for hand tracking hand mesh.
111106 /// </summary>
112107 [ Obsolete ( "Use the CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.RiggedHandMeshMaterial instead" ) ]
113- public Material HandMaterial => handMaterial ;
108+ public Material HandMaterial { get ; private set ; }
114109
115110 /// <summary>
116111 /// Property name for modifying the mesh's appearance based on pinch strength
@@ -125,23 +120,23 @@ public class RiggedHandVisualizer : BaseHandVisualizer
125120 /// <summary>
126121 /// Precalculated values for LeapMotion testhand fingertip lengths
127122 /// </summary>
128- private const float thumbFingerTipLength = 0.02167f ;
129- private const float indexingerTipLength = 0.01582f ;
130- private const float middleFingerTipLength = 0.0174f ;
131- private const float ringFingerTipLength = 0.0173f ;
132- private const float pinkyFingerTipLength = 0.01596f ;
123+ private const float ThumbFingerTipLength = 0.02167f ;
124+ private const float IndexFingerTipLength = 0.01582f ;
125+ private const float MiddleFingerTipLength = 0.0174f ;
126+ private const float RingFingerTipLength = 0.0173f ;
127+ private const float PinkyFingerTipLength = 0.01596f ;
133128
134129 /// <summary>
135130 /// Precalculated fingertip lengths used for scaling the fingertips of the skinnedmesh
136131 /// to match with tracked hand fingertip size
137132 /// </summary>
138133 private Dictionary < TrackedHandJoint , float > fingerTipLengths = new Dictionary < TrackedHandJoint , float > ( )
139134 {
140- { TrackedHandJoint . ThumbTip , thumbFingerTipLength } ,
141- { TrackedHandJoint . IndexTip , indexingerTipLength } ,
142- { TrackedHandJoint . MiddleTip , middleFingerTipLength } ,
143- { TrackedHandJoint . RingTip , ringFingerTipLength } ,
144- { TrackedHandJoint . PinkyTip , pinkyFingerTipLength }
135+ { TrackedHandJoint . ThumbTip , ThumbFingerTipLength } ,
136+ { TrackedHandJoint . IndexTip , IndexFingerTipLength } ,
137+ { TrackedHandJoint . MiddleTip , MiddleFingerTipLength } ,
138+ { TrackedHandJoint . RingTip , RingFingerTipLength } ,
139+ { TrackedHandJoint . PinkyTip , PinkyFingerTipLength }
145140 } ;
146141
147142 /// <summary>
@@ -163,7 +158,7 @@ private Quaternion UserBoneRotation
163158 protected readonly Transform [ ] riggedVisualJointsArray = new Transform [ ArticulatedHandPose . JointCount ] ;
164159
165160 /// <summary>
166- /// flag checking that the handRenderer was initialized with its own material
161+ /// Flag checking that the handRenderer was initialized with its own material
167162 /// </summary>
168163 private bool handRendererInitialized = false ;
169164
@@ -268,10 +263,13 @@ protected override void Start()
268263
269264 // Give the hand mesh its own material to avoid modifying both hand materials when making property changes
270265 MixedRealityHandTrackingProfile handTrackingProfile = CoreServices . InputSystem ? . InputSystemProfile . HandTrackingProfile ;
271-
272- handMaterial = handTrackingProfile . RiggedHandMeshMaterial ;
273- Material handMaterialInstance = new Material ( handMaterial ) ;
274- handRenderer . sharedMaterial = handMaterialInstance ;
266+ if ( handTrackingProfile != null && handTrackingProfile . RiggedHandMeshMaterial != null )
267+ {
268+ #pragma warning disable CS0618 // Type or member is obsolete
269+ HandMaterial = handTrackingProfile . RiggedHandMeshMaterial ;
270+ #pragma warning restore CS0618 // Type or member is obsolete
271+ handRenderer . sharedMaterial = new Material ( handTrackingProfile . RiggedHandMeshMaterial ) ;
272+ }
275273 handRendererInitialized = true ;
276274 }
277275
@@ -294,8 +292,10 @@ protected override bool UpdateHandJoints()
294292 // The base class takes care of updating all of the joint data
295293 _ = base . UpdateHandJoints ( ) ;
296294
297- // Exit early and disable the rigged hand model if we've gotten a hand mesh from the underlying platform
298- if ( ReceivingPlatformHandMesh || MixedRealityHand . IsNull ( ) )
295+ // Exit early and disable the rigged hand model if we've gotten a hand mesh from the underlying platform or the display is transparent
296+ if ( ReceivingPlatformHandMesh
297+ || MixedRealityHand . IsNull ( )
298+ || ( ! XRSubsystemHelpers . DisplaySubsystem ? . displayOpaque ?? false ) )
299299 {
300300 HandRenderer . enabled = false ;
301301 return false ;
@@ -304,8 +304,10 @@ protected override bool UpdateHandJoints()
304304 IMixedRealityInputSystem inputSystem = CoreServices . InputSystem ;
305305 MixedRealityHandTrackingProfile handTrackingProfile = inputSystem ? . InputSystemProfile != null ? inputSystem . InputSystemProfile . HandTrackingProfile : null ;
306306
307- // Only runs if render hand mesh is true
308- bool renderHandmesh = handTrackingProfile != null && handTrackingProfile . EnableHandMeshVisualization && MixedRealityHand . TryGetJoint ( TrackedHandJoint . Palm , out _ ) ;
307+ // Only render the hand mesh if visualization is enabled and the hand joints are tracked
308+ bool renderHandmesh = handTrackingProfile != null
309+ && handTrackingProfile . EnableHandMeshVisualization
310+ && MixedRealityHand . TryGetJoint ( TrackedHandJoint . Palm , out _ ) ;
309311 HandRenderer . enabled = renderHandmesh ;
310312 if ( renderHandmesh )
311313 {
@@ -376,10 +378,10 @@ protected override bool UpdateHandJoints()
376378 float ringFingerCurl = HandPoseUtils . RingFingerCurl ( Controller . ControllerHandedness ) ;
377379 float pinkyFingerCurl = HandPoseUtils . PinkyFingerCurl ( Controller . ControllerHandedness ) ;
378380
379- if ( handMaterial != null && handRendererInitialized )
381+ if ( handTrackingProfile . RiggedHandMeshMaterial != null && handRendererInitialized )
380382 {
381383 float gripStrength = indexFingerCurl + middleFingerCurl + ringFingerCurl + pinkyFingerCurl ;
382- gripStrength /= 4.0f ;
384+ gripStrength *= 0.25f ;
383385 gripStrength = gripStrength > 0.8f ? 1.0f : gripStrength ;
384386
385387 pinchStrength = Mathf . Pow ( Mathf . Max ( pinchStrength , gripStrength ) , 2.0f ) ;
@@ -391,7 +393,7 @@ protected override bool UpdateHandJoints()
391393 // Only show this warning once
392394 else if ( ! displayedMaterialPropertyWarning )
393395 {
394- Debug . LogWarning ( String . Format ( "The property {0} for reacting to pinch strength was not found. A material with this property is required to visualize pinch strength." , pinchStrengthMaterialProperty ) ) ;
396+ Debug . LogWarning ( string . Format ( "The property {0} for reacting to pinch strength was not found. A material with this property is required to visualize pinch strength." , pinchStrengthMaterialProperty ) ) ;
395397 displayedMaterialPropertyWarning = true ;
396398 }
397399 }
0 commit comments