Beispiel #1
0
    public override void TwoDevicePartInit(Dictionary <InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
    {
        base.TwoDevicePartInit(eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);

        if (handTipTransformDic == null)
        {
            handTipTransformDic = new Dictionary <InputDevicePartType, Transform>();
        }
        handTipTransformDic.Clear();

        if (position3DDic == null)
        {
            position3DDic = new Dictionary <InputDevicePartType, Vector3>();
        }
        position3DDic.Clear();

        foreach (var eventData in eventDataDic)
        {
            InputDeviceHandPart inputDeviceHandPart = eventData.Value.inputDevicePartBase as InputDeviceHandPart;
            ModelHand           modelHand           = inputDeviceHandPart.inputDeviceHandPartUI.modelHand;
            Transform           tipTransform        = modelHand.ActiveHandModel.GetJointTransform(FINGER.forefinger, JOINT.One).transform;
            handTipTransformDic.Add(eventData.Key, tipTransform);
            position3DDic.Add(eventData.Key, eventData.Value.Position3D);
        }

        handTipTransformArray = handTipTransformDic.Values.ToArray();

        if (scaleLogic != null)
        {
            scaleLogic.Setup(handTipTransformArray, targetTransform);
        }

        if (rotateLogic != null)
        {
            rotateLogic.Setup(handTipTransformArray, targetTransform);
        }

        int count = 0;

        foreach (SCPointEventData eventDataItem in eventDataDic.Values)
        {
            position3DPoses[count] = new SCPose(eventDataItem.Position3D, handTipTransformArray[count].rotation);
            count++;
        }
        SCPose  pointerCentroidPose = GetHandTipPointCentroid(position3DPoses);
        Vector3 grabCentroid        = GetRaycastPointCentroid(position3DDic.Values.ToArray());

        moveLogic.Setup(pointerCentroidPose, grabCentroid, targetTransform, targetTransform.localScale);
    }
Beispiel #2
0
    public override void OneDevicePartInit(Dictionary <InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
    {
        base.OneDevicePartInit(eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);
        startRotation        = targetTransform.rotation;
        onHandPointEventData = eventDataDic.Values.ToArray()[0];

        InputDeviceHandPart inputDeviceHandPart = onHandPointEventData.inputDevicePartBase as InputDeviceHandPart;
        ModelHand           modelHand           = inputDeviceHandPart.inputDeviceHandPartUI.modelHand;

        oneHandJointFour    = modelHand.ActiveHandModel.GetJointTransform(FINGER.forefinger, JOINT.Four).transform;
        localRotationInHand = Quaternion.Inverse(oneHandJointFour.rotation) * startRotation;

        handDetector = inputDeviceHandPart.detectorBase as HandDetector;

        oneHandPose.position = onHandPointEventData.Position3D;
        oneHandPose.rotation = startRotation;
        oneHandGrabPosition  = onHandPointEventData.Position3D;

        moveLogic.Setup(oneHandPose, oneHandGrabPosition, targetTransform, targetTransform.localScale);
    }