public virtual void TwoDevicePartInit(Dictionary <InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
 {
     this.eventDataDic    = eventDataDic;
     this.targetTransform = targetTransform;
     this.moveLogic       = moveLogic;
     this.rotateLogic     = rotateLogic;
     this.scaleLogic      = scaleLogic;
 }
Beispiel #2
0
 public override void TwoDevicePartInit(Dictionary <InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
 {
     base.TwoDevicePartInit(eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);
     //Do nothing
 }
 public override void Init(IDevicePartManipulation devicePartManipulation, Dictionary <InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
 {
     base.Init(devicePartManipulation, eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);
     this.devicePartManipulation.OneDevicePartInit(eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);
 }
Beispiel #4
0
    public override void OneDevicePartInit(Dictionary <InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
    {
        base.OneDevicePartInit(eventDataDic, targetTransform, moveLogic, rotateLogic, scaleLogic);

        this.eventData = this.eventDataDic.Values.ToArray()[0];
        pointerPose    = new SCPose(Vector3.zero, Quaternion.identity);
        Vector3 grabPosition = Vector3.zero;

        pointerPose.position = this.eventData.Position3D;
        pointerPose.rotation = Quaternion.identity;
        grabPosition         = this.eventData.Position3D;

        //Head only need to setup movelogic
        moveLogic.Setup(pointerPose, grabPosition, targetTransform, targetTransform.localScale);
    }
 public virtual void Init(IDevicePartManipulation devicePartManipulation, Dictionary <InputDevicePartType, SCPointEventData> eventDataDic, Transform targetTransform, MoveLogic moveLogic, RotateLogic rotateLogic, ScaleLogic scaleLogic)
 {
     this.devicePartManipulation = devicePartManipulation;
 }
Beispiel #6
0
        public override void OnPointerDown(PointerEventData eventData)
        {
            base.OnPointerDown(eventData);

            if (eventDataDic == null)
            {
                eventDataDic = new Dictionary <InputDevicePartType, SCPointEventData>();
            }

            if (scaleLogic == null)
            {
                scaleLogic = new ScaleLogic();
            }

            if (rotateLogic == null)
            {
                rotateLogic = new RotateLogic();
            }

            if (moveLogic == null)
            {
                moveLogic = new MoveLogic();
            }

            if (eventData is SCPointEventData)
            {
                SCPointEventData scPointEventData = eventData as SCPointEventData;
                eventDataDic[scPointEventData.inputDevicePartBase.PartType] = scPointEventData;
                if (scPointEventData.inputDevicePartBase is InputDeviceHandPart)
                {
                    devicePartManipulation = new HandDevicePartManipulation();
                }
                else if (scPointEventData.inputDevicePartBase is InputDeviceGCPart)
                {
                    devicePartManipulation = new GameControllerDevicePartManipulation();
                }
                else if (scPointEventData.inputDevicePartBase is InputDeviceHeadPart)
                {
                    devicePartManipulation = new HeadDevicePartManipulation();
                }
            }

            //Two DevicePart
            if (eventDataDic.Count > 1)
            {
                devicePartCountManipulation = new TwoDevicePartCountManipulation();
                devicePartCountManipulation.Init(devicePartManipulation, eventDataDic, Target == null ? this.transform : Target.transform, moveLogic, canTwoHandRotate ? rotateLogic : null, canTwoHandScale ? scaleLogic : null);
            }
            //One DevicePart
            else if (eventDataDic.Count == 1)
            {
                devicePartCountManipulation = new OneDevicePartCountManipulation();
                devicePartCountManipulation.Init(devicePartManipulation, eventDataDic, Target == null ? this.transform : Target.transform, moveLogic, canOneHandRotate ? rotateLogic : null, null);
            }

            rigidBody = Target == null?this.GetComponent <Rigidbody>() : Target.GetComponent <Rigidbody>();

            if (rigidBody != null)
            {
                wasKinematic          = rigidBody.isKinematic;
                rigidBody.isKinematic = true;
            }

            AudioSystem.getInstance.PlayAudioOneShot(gameObject, StartAudio);
        }
Beispiel #7
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 (position3DDic == null)
        {
            position3DDic = new Dictionary <InputDevicePartType, Vector3>();
        }
        position3DDic.Clear();

        foreach (var eventData in eventDataDic)
        {
            position3DDic.Add(eventData.Key, eventData.Value.Position3D);
        }

        if (scaleLogic != null)
        {
            scaleLogic.Setup(eventDataDic.Values.Select(item => item.Position3D).ToArray(), targetTransform);
        }

        if (rotateLogic != null)
        {
            rotateLogic.Setup(eventDataDic.Values.Select(item => item.Position3D).ToArray(), targetTransform);
        }

        int count = 0;

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

        moveLogic.Setup(pointerCentroidPose, grabCentroid, targetTransform, targetTransform.localScale);
    }
Beispiel #8
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 #9
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);
    }