Example #1
0
        protected virtual void Update()
        {
            if (KeywordGestureTimeCounter < 0)
            {
                if (GestureStarted)
                {
                    KeywordGestureTimeCounter = KeywordGestureTime;
                    return;
                }

                GestureInteractive.GestureManipulationState state = GestureInteractive.GestureManipulationState.Update;
                KeywordGestureTimeCounter += Time.deltaTime;
                if (KeywordGestureTimeCounter > KeywordGestureTime)
                {
                    KeywordGestureTimeCounter = KeywordGestureTime;
                    state = GestureInteractive.GestureManipulationState.None;
                }

                CurrentGesturePosition = KeywordGestureVector * MaxGestureDistance * (KeywordGestureTimeCounter / KeywordGestureTime);

                ManipulationUpdate(StartGesturePosition, Vector3.up, StartHeadPosition, StartHeadRay, state);
            }
        }
Example #2
0
 // set the default gesture state
 virtual protected void Awake()
 {
     GestureState = GestureInteractive.GestureManipulationState.None;
 }
Example #3
0
        /// <summary>
        /// Gesture updates called by GestureInteractive
        /// </summary>
        /// <param name="startGesturePosition">The gesture origin position</param>
        /// <param name="currentGesturePosition">the current gesture position</param>
        /// <param name="startHeadOrigin">the origin of the camera when the gesture started</param>
        /// <param name="startHeadRay">the camera forward when the gesture started</param>
        /// <param name="gestureState">current gesture state</param>
        public virtual void ManipulationUpdate(Vector3 startGesturePosition, Vector3 currentGesturePosition, Vector3 startHeadOrigin, Vector3 startHeadRay, GestureInteractive.GestureManipulationState gestureState)
        {
            if (gestureState == GestureInteractive.GestureManipulationState.Start || (!GestureStarted && gestureState != GestureInteractive.GestureManipulationState.Start))
            {
                CameraMatrix           = GetCameraMatrix();
                StartGesturePosition   = startGesturePosition;
                CurrentGesturePosition = startGesturePosition;
                StartHeadPosition      = startHeadOrigin;
                StartHeadRay           = startHeadRay;
                GestureStarted         = true;
            }
            else
            {
                CurrentGesturePosition = currentGesturePosition;
            }

            UpdateGesture();

            if (gestureState == GestureInteractive.GestureManipulationState.None)
            {
                GestureStarted = false;
            }
        }
        public override void ManipulationUpdate(Vector3 startGesturePosition, Vector3 currentGesturePosition, Vector3 startHeadOrigin, Vector3 startHeadRay, GestureInteractive.GestureManipulationState gestureState)
        {
            base.ManipulationUpdate(startGesturePosition, currentGesturePosition, startHeadOrigin, startHeadRay, gestureState);

            // get gesture data for gesturing along the horizontal axis
            GestureInteractiveData gestureData = GetGestureData(new Vector3(1, 0, 0), MaxGestureDistance, FlipDirectionOnCameraForward);

            for (int i = 0; i < mCycleList.Count; ++i)
            {
                CycleData data = mCycleList[i];
                // get the length of ICycle values to loop through
                float length    = data.Controller.GetLastIndex() + 1;
                float incrament = MaxGestureDistance / length;

                // get the delta of the current gesture
                int offset = Mathf.RoundToInt(gestureData.Distance / incrament);
                if (gestureState == GestureInteractive.GestureManipulationState.Start)
                {
                    // set the starting index so we can add the delta to it
                    data.Index = data.Controller.Index;

                    mCycleList[i] = data;
                }

                // update the ICycle component
                data.Controller.SetIndex(Mathf.Clamp(offset + data.Index, 0, data.Controller.GetLastIndex()));
            }
        }
        public override void ManipulationUpdate(Vector3 startGesturePosition, Vector3 currentGesturePosition, Vector3 startHeadOrigin, Vector3 startHeadRay, GestureInteractive.GestureManipulationState gestureState)
        {
            if (AlignmentVector != SliderBar.transform.right)
            {
                mSliderVector   = SliderBar.transform.InverseTransformPoint(mStartCenter + SliderBar.transform.right * mSliderMagnitude / 2) - SliderBar.transform.InverseTransformPoint(mStartCenter - SliderBar.transform.right * mSliderMagnitude / 2);
                AlignmentVector = SliderBar.transform.right;

                mCachedRotation = SliderBar.transform.rotation;
            }

            base.ManipulationUpdate(startGesturePosition, currentGesturePosition, startHeadOrigin, startHeadRay, gestureState);

            // get the current delta
            float delta = (CurrentDistance > 0) ? CurrentPercentage : -CurrentPercentage;

            //print(delta);

            // combine the delta with the current slider position so the slider does not start over every time
            mDeltaValue = Mathf.Clamp01(delta + mCachedValue);

            if (!Centered)
            {
                SliderValue = mDeltaValue * mValueSpan;
            }
            else
            {
                SliderValue = mDeltaValue * mValueSpan * 2 - mValueSpan;
            }

            UpdateVisuals();

            if (gestureState == GestureInteractive.GestureManipulationState.None)
            {
                // gesture ended - cache the current delta
                mCachedValue = mDeltaValue;
            }
        }
Example #6
0
    public override void ManipulationUpdate(Vector3 startGesturePosition, Vector3 currentGesturePosition,
                                            Vector3 startHeadOrigin, Vector3 startHeadRay, GestureInteractive.GestureManipulationState gestureState)
    {
        GestureInteractiveData gestureData =
            GetGestureData(new Vector3(1, 0, 0), MaxGestureDistance, FlipDirectionOnCameraForward);

        vertData.Direction = gestureData.Direction;
        //HandPosition2D.x = vertData.Direction.x * 300/(1+CurrentPercentage*CurrentPercentage*CurrentPercentage*12);
        //HandPosition2D.y = vertData.Direction.y * 300/(1+CurrentPercentage*CurrentPercentage*CurrentPercentage*10);

        // Debug.Log("CurrentPercentage=" + CurrentPercentage);
        // Debug.Log("CurrentPercentage=" + CurrentPercentage);
        HandPosition2D.x = DirectionVector.x * 200;
        HandPosition2D.y = DirectionVector.y * 200;
        base.ManipulationUpdate(startGesturePosition, currentGesturePosition, startHeadOrigin, startHeadRay,
                                gestureState);
    }
Example #7
0
        // updates slider according to gesture !
        public override void ManipulationUpdate(Vector3 startGesturePosition, Vector3 currentGesturePosition, Vector3 startHeadOrigin, Vector3 startHeadRay, GestureInteractive.GestureManipulationState gestureState)
        {
            // sync alignment vectors: base.AlignmentVector, this.mSliderVector, this.mCachedRotation
            // unclear where these are used?
            if (AlignmentVector != SliderBar.transform.right)
            {
                // vector in direction of slider
                mSliderVector   = SliderBar.transform.InverseTransformPoint(mStartCenter + SliderBar.transform.right * mSliderMagnitude / 2) - SliderBar.transform.InverseTransformPoint(mStartCenter - SliderBar.transform.right * mSliderMagnitude / 2);
                AlignmentVector = SliderBar.transform.right;

                mCachedRotation = SliderBar.transform.rotation;
            }

            // run base method
            // what does this do?
            base.ManipulationUpdate(startGesturePosition, currentGesturePosition, startHeadOrigin, startHeadRay, gestureState);

            // get the current delta
            // CurrentDistance: from base, distance of current gesture
            float delta = (CurrentDistance > 0) ? CurrentPercentage : -CurrentPercentage;

            // combine the delta with the current slider position so the slider does not start over every time
            // mDeltaValue: the new slider position
            mDeltaValue = Mathf.Clamp01(delta + mCachedValue);

            // set slider value appropriately
            if (!Centered)
            {
                SliderValue = mDeltaValue * mValueSpan + MinSliderValue;
            }
            else
            {
                SliderValue = mDeltaValue * mValueSpan * 2 - mValueSpan;
            }

            // update visual gameobjects accordingly
            UpdateVisuals();

            // cache value if gesture ended
            if (gestureState == GestureInteractive.GestureManipulationState.None)
            {
                // gesture ended - cache the current delta
                mCachedValue = mDeltaValue;
            }
        }
Example #8
0
        /// <summary>
        /// provide visual feedback based on state and update element position
        /// </summary>
        /// <param name="startVector"></param>
        /// <param name="currentVector"></param>
        /// <param name="startOrigin"></param>
        /// <param name="startRay"></param>
        /// <param name="gestureState"></param>
        public override void ManipulationUpdate(Vector3 startVector, Vector3 currentVector, Vector3 startOrigin, Vector3 startRay, GestureInteractive.GestureManipulationState gestureState)
        {
            base.ManipulationUpdate(startVector, currentVector, startOrigin, startRay, gestureState);

            Vector3 mDirection = DirectionVector.normalized;

            if (gestureState == GestureInteractive.GestureManipulationState.Start)
            {
                mTickerCount = mTickerTime;

                mEffectRenderer.material.color = EffectColors[1];
            }

            if (gestureState == GestureInteractive.GestureManipulationState.None)
            {
                mTickerCount = 0;

                mEffectRenderer.material.color = EffectColors[0];
            }

            EffectDot.transform.localPosition = mDirection * FeebackVisualDistance * CurrentPercentage;
        }
Example #9
0
    /// <summary>
    /// provide visual feedback based on state and update element position
    /// </summary>
    /// <param name="startVector"></param>
    /// <param name="currentVector"></param>
    /// <param name="startOrigin"></param>
    /// <param name="startRay"></param>
    /// <param name="gestureState"></param>
    public override void ManipulationUpdate(Vector3 startVector, Vector3 currentVector, Vector3 startOrigin, Vector3 startRay, GestureInteractive.GestureManipulationState gestureState)
    {
        if (IsActive)
        {
            //Debug.Log("StartVec: " + startVector + " CurrVec: " + currentVector + " StartOrigin: " + startOrigin);
            base.ManipulationUpdate(startVector, currentVector, startOrigin, startRay, gestureState);

            //Vector3 mDirection = DirectionVector.normalized;

            /*if (isDragging)
             * {
             * } else
             * {
             *
             * }*/
            Vector3 mCurrPos = DirectionVector.normalized;
            if (mCurrPos == Vector3.zero && latestObjectPosition != null)
            {
                mCurrPos = latestObjectPosition;
                Debug.LogError("Latest CURRPOS: " + mCurrPos);
            }
            Debug.Log("Direction vec: " + mCurrPos);
            Object.transform.localPosition = mCurrPos * FeebackVisualDistance;
            latestObjectPosition           = Object.transform.localPosition;
            //Object.transform.localPosition = CurrentGesturePosition * FeebackVisualDistance;
            Debug.Log("Latest Object position: " + latestObjectPosition);
            //base.StartGesturePosition = Object.transform.localPosition;
        }
    }
Example #10
0
 public override void ManipulationUpdate(Vector3 startGesturePosition, Vector3 currentGesturePosition, Vector3 startHeadOrigin, Vector3 startHeadRay, GestureInteractive.GestureManipulationState gestureState)
 {
     base.ManipulationUpdate(startGesturePosition, currentGesturePosition, startHeadOrigin, startHeadRay, gestureState);
     OnUpdateEventIntInt.Invoke(GetChannel(), (int)SliderValue);
 }