@@ -101,16 +101,11 @@ public class RiggedHandVisualizer : BaseHandVisualizer
101
101
/// </summary>
102
102
public SkinnedMeshRenderer HandRenderer => handRenderer ;
103
103
104
- /// <summary>
105
- /// Caching the hand material from CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.RiggedHandMeshMaterial
106
- /// </summary>
107
- private Material handMaterial = null ;
108
-
109
104
/// <summary>
110
105
/// Hand material to use for hand tracking hand mesh.
111
106
/// </summary>
112
107
[ Obsolete ( "Use the CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.RiggedHandMeshMaterial instead" ) ]
113
- public Material HandMaterial => handMaterial ;
108
+ public Material HandMaterial { get ; private set ; }
114
109
115
110
/// <summary>
116
111
/// Property name for modifying the mesh's appearance based on pinch strength
@@ -125,23 +120,23 @@ public class RiggedHandVisualizer : BaseHandVisualizer
125
120
/// <summary>
126
121
/// Precalculated values for LeapMotion testhand fingertip lengths
127
122
/// </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 ;
133
128
134
129
/// <summary>
135
130
/// Precalculated fingertip lengths used for scaling the fingertips of the skinnedmesh
136
131
/// to match with tracked hand fingertip size
137
132
/// </summary>
138
133
private Dictionary < TrackedHandJoint , float > fingerTipLengths = new Dictionary < TrackedHandJoint , float > ( )
139
134
{
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 }
145
140
} ;
146
141
147
142
/// <summary>
@@ -163,7 +158,7 @@ private Quaternion UserBoneRotation
163
158
protected readonly Transform [ ] riggedVisualJointsArray = new Transform [ ArticulatedHandPose . JointCount ] ;
164
159
165
160
/// <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
167
162
/// </summary>
168
163
private bool handRendererInitialized = false ;
169
164
@@ -268,10 +263,13 @@ protected override void Start()
268
263
269
264
// Give the hand mesh its own material to avoid modifying both hand materials when making property changes
270
265
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
+ }
275
273
handRendererInitialized = true ;
276
274
}
277
275
@@ -294,8 +292,10 @@ protected override bool UpdateHandJoints()
294
292
// The base class takes care of updating all of the joint data
295
293
_ = base . UpdateHandJoints ( ) ;
296
294
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 ) )
299
299
{
300
300
HandRenderer . enabled = false ;
301
301
return false ;
@@ -304,8 +304,10 @@ protected override bool UpdateHandJoints()
304
304
IMixedRealityInputSystem inputSystem = CoreServices . InputSystem ;
305
305
MixedRealityHandTrackingProfile handTrackingProfile = inputSystem ? . InputSystemProfile != null ? inputSystem . InputSystemProfile . HandTrackingProfile : null ;
306
306
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 _ ) ;
309
311
HandRenderer . enabled = renderHandmesh ;
310
312
if ( renderHandmesh )
311
313
{
@@ -376,10 +378,10 @@ protected override bool UpdateHandJoints()
376
378
float ringFingerCurl = HandPoseUtils . RingFingerCurl ( Controller . ControllerHandedness ) ;
377
379
float pinkyFingerCurl = HandPoseUtils . PinkyFingerCurl ( Controller . ControllerHandedness ) ;
378
380
379
- if ( handMaterial != null && handRendererInitialized )
381
+ if ( handTrackingProfile . RiggedHandMeshMaterial != null && handRendererInitialized )
380
382
{
381
383
float gripStrength = indexFingerCurl + middleFingerCurl + ringFingerCurl + pinkyFingerCurl ;
382
- gripStrength /= 4.0f ;
384
+ gripStrength *= 0.25f ;
383
385
gripStrength = gripStrength > 0.8f ? 1.0f : gripStrength ;
384
386
385
387
pinchStrength = Mathf . Pow ( Mathf . Max ( pinchStrength , gripStrength ) , 2.0f ) ;
@@ -391,7 +393,7 @@ protected override bool UpdateHandJoints()
391
393
// Only show this warning once
392
394
else if ( ! displayedMaterialPropertyWarning )
393
395
{
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 ) ) ;
395
397
displayedMaterialPropertyWarning = true ;
396
398
}
397
399
}
0 commit comments