1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using System;
- using UnityEngine;
- namespace Leap.Unity
- {
- public class SkeletalHand : HandModel
- {
- public override ModelType HandModelType
- {
- get
- {
- return ModelType.Graphics;
- }
- }
- private void Start()
- {
- Utils.IgnoreCollisions(base.gameObject, base.gameObject, true);
- for (int i = 0; i < this.fingers.Length; i++)
- {
- if (this.fingers[i] != null)
- {
- this.fingers[i].fingerType = (Finger.FingerType)i;
- }
- }
- }
- public override void UpdateHand()
- {
- this.SetPositions();
- }
- protected Vector3 GetPalmCenter()
- {
- Vector3 b = 0.015f * Vector3.Scale(base.GetPalmDirection(), base.transform.lossyScale);
- return base.GetPalmPosition() - b;
- }
- protected void SetPositions()
- {
- Debug.Log("SkeletalHand.SetPositions()");
- for (int i = 0; i < this.fingers.Length; i++)
- {
- if (this.fingers[i] != null)
- {
- this.fingers[i].UpdateFinger();
- }
- }
- if (this.palm != null)
- {
- this.palm.position = this.GetPalmCenter();
- this.palm.rotation = base.GetPalmRotation();
- }
- if (this.wristJoint != null)
- {
- this.wristJoint.position = base.GetWristPosition();
- this.wristJoint.rotation = base.GetPalmRotation();
- }
- if (this.forearm != null)
- {
- this.forearm.position = base.GetArmCenter();
- this.forearm.rotation = base.GetArmRotation();
- }
- }
- protected const float PALM_CENTER_OFFSET = 0.015f;
- }
- }
|