void OnControllerPinchStay(InteractionController controller)
    {
        var index    = controller.isRight ? 1 : 0;
        var pinchPos = controller.GetPinchPosition();

        _grabCurPositions[index] = pinchPos;
    }
        public override void Stretch(InteractionController obj)
        {
            if (stretchEnabled)
            {
                Debug.Log("Can't Stretch To 4D yet...");
                InteractablePrism thisPrism = this;

                List <AbstractLineSegment> lineList  = new List <AbstractLineSegment>();
                List <AbstractPoint>       pointList = new List <AbstractPoint>();

                thisPrism.bases[0].pointList.ForEach(p => pointList.Add(GeoObjConstruction.iPoint(p.Position3)));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[0], pointList[1]));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[1], pointList[2]));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[3], pointList[4]));
                lineList.Add(GeoObjConstruction.iLineSegment(pointList[1], pointList[0]));

                InteractablePrism nextPrism = GeoObjConstruction.iPrism(GeoObjConstruction.iPolygon(lineList, pointList));

                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < thisPrism.bases.Count; j++)
                    {
                        GeoObjConstruction.makePlaneWall(i, thisPrism.bases[j].lineList, nextPrism.bases[j].lineList);
                    }

                    for (int k = 0; k < thisPrism.sides.Count; k++)
                    {
                        GeoObjConstruction.makePlaneWall(i, thisPrism.sides[k].lineList, nextPrism.sides[k].lineList);
                    }
                }
            }
        }
Example #3
0
    public override void OnFrame(InteractionController controller)
    {
        if (IsGrabbed)
        {
            //disable interaction once the hand leaves the region of interest
            //var hand = controller.GetHand();
            //float distance = MathUtil.Distance(controller.Target.transform.position, gameObject.transform.position);
            //if (distance > MAX_INTERACTION_DISTANCE)
            //{
            //    controller.Drop();
            //    return;
            //}

            //rotate the oven door such that it is as close to the hand as possible
            //this motion is described by finding the point closest to another (on a circle)
            var hand         = controller.GetHand();
            var closestPoint = MathUtil.ClosestPointOnCircle(hand.transform.position, DoorHingeLocation, DoorHingeToHandleRadius);

            //if the hand is too far from that point, drop the door
            float distanceFromHandToHandle = MathUtil.Distance(hand.transform.position, closestPoint);
            if (distanceFromHandToHandle > MAX_INTERACTION_DISTANCE)
            {
                controller.Drop();
                return;
            }

            //calculate door rotation angle
            float diffZ = (closestPoint.z - DoorHingeLocation.z) / DoorHingeToHandleRadius;
            float angle = Mathf.Asin(diffZ);

            //perform rotation
            Door.transform.rotation = Quaternion.Euler(angle, 0f, 0f);

            //hide hand
            var handRenderer = hand.GetComponent <MeshRenderer>();
            handRenderer.enabled = false;


            ////rotate the dial as the hand rotates
            //float targetAngle = controller.Target.transform.rotation.eulerAngles.z - StartEulerRotation.z;
            //targetAngle *= -1;
            //targetAngle = Mathf.DeltaAngle(0f, targetAngle);                            // converts to -180..180
            //float originalAngle = Mathf.DeltaAngle(0f, StartEulerRotation.z);           // converts to -180..180
            //float diffAngle = Mathf.DeltaAngle(originalAngle, targetAngle);             // total diff

            //if (targetAngle > ANGLE_ZERO_DEADBAND && targetAngle < 0)
            //{
            //    //round to zero
            //    targetAngle = 0;
            //}
            //if (targetAngle > 0 && targetAngle < ANGLE_MAX)
            //{
            //    //round to nearest
            //    if (ANGLE_MAX - targetAngle > targetAngle) targetAngle = 0;
            //    else targetAngle = ANGLE_MAX;
            //}

            //gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, 0, targetAngle));
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (IsBroken)
        {
            if (repairing)
            {
                float curTime = (Time.time - startTime);
                InteractionController.SetUseDisplay(repairTime, curTime);

                if (curTime >= repairTime)
                {
                    IsBroken  = false;
                    repairing = false;
                    InteractionController.FinishRepair();
                }
            }
            else if ((Time.time - brokenTime) >= autoRepairTime)
            {
                RepairManager.Instance.ShowRepairNotification("Auto repaired " + gameObject.name + " for " + MoneySystem.FormatMoney(autoRepairCost));

                IsBroken = false;
                InteractionController.FinishRepair();
                MoneySystem.TakeMoney(autoRepairCost);
            }
        }
    }
        /// <summary>
        /// Initialises an instance of the Match that will be played in our application
        /// </summary>
        /// <returns></returns>
        public Contest InitialiseMatch(int matchId)
        {
            var initMessage = "Initialising Match...\n\n";

            InteractionController.Output(initMessage);

            Regex rgx = new Regex(@"^[0-9]+$");//Regular expression that only matches when complete string is a number

            //  Request Match Length: "Specify Number of Games To Play?"
            var requestMessage  = $"Please Specify number of rounds to play in Match:\n\n{{number using digits 1-9 between 1 and 10}}";
            var numRoundsString = InteractionController.RequestInput(requestMessage).ToString();
            var canParse        = int.TryParse(numRoundsString, out var numberRounds);

            //  Validate Input: Between 1 and 9 Games: Try parse
            while (!(canParse && numberRounds > 0 && numberRounds < 10))
            {
                var validationRequest = $"Please provide a Valid choice:\n\n{{Must be a number greater than 0 and less than 10}}";
                var validNumRounds    = InteractionController.RequestValidInput(validationRequest, rgx);
                canParse = int.TryParse(validNumRounds, out numberRounds);
            }

            //  Initialise the Score instance with the two Player instances already created.
            Score.Scores[Players[0]] = 0;
            Score.Scores[Players[1]] = 0;

            //Initialise and return Match instance
            var match = new Match(matchId, Players, numberRounds, Score, InteractionController, new List <IContestResult>(), new List <Contest>());

            //  return match
            return(match);
        }
Example #6
0
 private void ToggleHandCollisions(InteractionController controller, bool enable)
 {
     foreach (var collider in controller.HandColliders)
     {
         collider.enabled = enable;
     }
 }
 void Update()
 {
     if (imageManager.trackables.count == 0)
     {
         Debug.Log("PlanetsMainMode no trackables, going to Scan mode");
         InteractionController.EnableMode("Scan");
     }
     else
     {
         Ray        ray = new Ray(camera.transform.position, camera.transform.forward);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
         {
             Planet planet = hit.collider.GetComponentInParent <Planet>();
             planetName.text         = planet.planetName;
             detailsText.text        = planet.description;
             infoButton.interactable = true;
         }
         else
         {
             planetName.text         = "";
             detailsText.text        = "";
             infoButton.interactable = false;
         }
     }
 }
Example #8
0
 void Awake()
 {
     // Applying references
     rb2d     = GetComponent <Rigidbody2D>();
     animator = GetComponent <Animator>();
     interactionController = GetComponent <InteractionController>();
 }
Example #9
0
    public static Vector3 GetPinchNormal(this InteractionController controller)
    {
        var hand      = controller.intHand.leapHand;
        var direction = (-hand.GetIndex().Direction + hand.GetThumb().Direction) * 0.5f;

        return(direction.ToVector3());
    }
Example #10
0
    public static InteractionController GetClosestHand(this InteractionManager manager, Vector3 position, out float distance)
    {
        distance = float.PositiveInfinity;
        InteractionController closestController = null;

        if (manager == null)
        {
            return(closestController);
        }

        foreach (var controller in manager.interactionControllers)
        {
            if (!controller.isActiveAndEnabled)
            {
                continue;
            }
            if (!controller.isTracked)
            {
                continue;
            }
            var controllerDistance = Vector3.Distance(controller.position, position);
            if (controllerDistance < distance)
            {
                distance          = controllerDistance;
                closestController = controller;
            }
        }
        return(closestController);
    }
Example #11
0
        public override void OnDrop(InteractionController controller)
        {
            base.OnDrop(controller);

            var handRenderer = controller.HandRenderer;

            //disable hand collisions for a bit
            ToggleHandCollisions(controller, false);

            //remove item from hand
            isGrabbed            = false;
            handRenderer.enabled = true;

            //disable joint
            Destroy(gameObject.GetComponent <FixedJoint>());

            //enable collider
            //if (objectCollider) objectCollider.enabled = true;

            //apply force equal to controller velocity
            objectRigidbody.AddForceAtPosition(controller.Velocity * 50f, controller.Position, ForceMode.Force);

            //unfreeze rotation
            objectRigidbody.freezeRotation = false;

            //prapare to reinsert hand collisions
            timesDropped[controller] = Time.time;
        }
 public CollDataBundle(EventManager.EDCollisionExit collEvent)
 {
     collision       = new Coll2D(collEvent.flippedColl ? collEvent.collider : collEvent.collision2D.collider, collEvent.collision2D, collEvent.flippedColl);
     collisionCont   = collEvent.collisionCont;
     callback        = collEvent.collisionCallback;
     interactionCont = collEvent.interactionCont;
 }
Example #13
0
 void Update()
 {
     if (faceManager.trackables.count > 0)
     {
         InteractionController.EnableMode("Main");
     }
 }
Example #14
0
    private float helper_timeSlice_lastYUpdate = 0.0f;      // helper value to keep track of the last y-position update of the Time Slice when moved through Leap Motion Grasp Interaction

    /// <summary>
    /// Method to identify the Activation Toggle of a 3D Radar Chart (from potentially multiple in the Scene) the Leap Motion controller collided with, and set link interface references accordingly.
    /// </summary>
    /// <param name="controller">InteractionController representing the Leap Motion hand controller a contact event occured with.</param>
    private void vrlmTriggerActivationToggleOnPerControllerContactBegin(InteractionController controller)
    {
        // Developer Note: This is basically required to support interaction with multiple 3D Radar Charts in the Scene, assuming interaction with each charts' Activation Toggle switches the focus.

        // Generally, the routine goes as follows
        // (1) Identify collided (contacted) GameObject (potentially one or multiple).
        // (2) Identify Activation Toggle component among collided GameObjects, and retrieve reference to its 3D Radar Chart's main interface.
        // (3) Link references between VRLM and TDRC interfaces accordingly.
        // (4) Continue with interaction.

        // (1)
        HashSet <IInteractionBehaviour> .Enumerator em = controller.contactingObjects.GetEnumerator();
        IInteractionBehaviour ib = null;

        while (em.MoveNext())
        {
            ib = em.Current;

            // (2)
            TDRCInteractionActivationToggle iatComponent = ib.transform.GetComponent <TDRCInteractionActivationToggle>();
            if (iatComponent != null)
            {
                break;
            }
        }

        // (3)
        ThreeDimRadarChartInterface tdrcInterfaceRef = ib.transform.parent.parent.GetComponent <ThreeDimRadarChartInterface>();

        tdrcInterface = tdrcInterfaceRef;

        // (4)
        vrlmTriggerActivationToggle();
    }
Example #15
0
 public override void OnFrame(InteractionController controller)
 {
     base.OnFrame(controller);
     if (startCooking && name.Contains("patty"))
     {
         if (timer >= 100)
         {
             secondsCooked += 1;
             timer          = 0;
         }
         timer += 1;
         if (secondsCooked < 5)
         {
             ObjectRenderer.material = Resources.Load("Materials/PattyRaw") as Material;
             currentMaterial         = Resources.Load("Materials/PattyRaw") as Material;
         }
         else if (secondsCooked < 9)
         {
             ObjectRenderer.material = Resources.Load("Materials/PattyCooked") as Material;
             currentMaterial         = Resources.Load("Materials/PattyCooked") as Material;
         }
         else if (secondsCooked < 12)
         {
             ObjectRenderer.material = Resources.Load("Materials/PattyOvercooked") as Material;
             currentMaterial         = Resources.Load("Materials/PattyOvercooked") as Material;
             stopCookingIngredient();
         }
     }
     if (currentMaterial != null)
     {
         ObjectRenderer.material = currentMaterial;
     }
 }
 public void SetData(InteractionController interactionCont, List <Collider2D> addedColliders, List <Collider2D> removedColliders, bool wereTriggers)
 {
     this.interactionCont  = interactionCont;
     this.addedColliders   = addedColliders == null ? new List <Collider2D>() : addedColliders;
     this.removedColliders = removedColliders == null ? new List <Collider2D>() : removedColliders;
     this.wereTriggers     = wereTriggers;
 }
Example #17
0
    // Update is called once per frame
    void Update()
    {
        Debug.DrawRay(transform.position, transform.forward * interactDistance, Color.green);

        if (Physics.Raycast(transform.position, transform.forward, out RaycastHit _hit, interactDistance) && !PlayerState.instance.busy && !PlayerState.instance.paused)  //do we hit something?
        {
            GameObject obj = _hit.collider.gameObject;

            if (current != obj)               //are we looking at something new?
            {
                InteractionController interaction = _hit.collider.gameObject.GetComponent <InteractionController>();

                if (interaction != null)     //is it interactable?
                {
                    if (current != null)     //deactivate outline if possible
                    {
                        current.GetComponent <InteractionController>().outline.disable();
                    }
                    current = obj.gameObject;   //transfer current;
                    interaction.gameObject.GetComponent <OutlineController>().outline();
                }
                else if (current != null)    //we are now looking at something not interactable, disable outline if possible
                {
                    current.GetComponent <InteractionController>().outline.disable();
                    current = null;
                }
            }
            else   //check if we are clicking
            {
                if (Input.GetKeyDown(KeyCode.Mouse0))
                {
                    current.GetComponent <InteractionController>().Activate();
                }
            }
        }
Example #18
0
        public override void OnGrab(InteractionController controller)
        {
            base.OnGrab(controller);

            var handRenderer = controller.HandRenderer;

            //make the hand mesh invisible
            isGrabbed            = true;
            handRenderer.enabled = false;

            //get original hand rotation
            originalRotationOnGrab = Quaternion.Inverse(controller.Target.transform.rotation * gameObject.transform.rotation);

            //freeze rotation
            objectRigidbody.freezeRotation = true;
            gameObject.transform.position  = controller.Target.transform.position;

            //disable colliders
            //if (objectCollider) objectCollider.enabled = false;
            ToggleHandCollisions(controller, false);

            //create joint
            FixedJoint joint = gameObject.AddComponent <FixedJoint>();

            joint.connectedBody = controller.HandRigidbody;

            timesDropped.Remove(controller);
        }
Example #19
0
    public static Vector3 GetPointPosition(this InteractionController controller)
    {
        var finger = controller.intHand.leapHand.GetIndex();

        // a bit longer from the tip
        return(finger.TipPosition.ToVector3() + 0.01f * finger.Direction.ToVector3());
    }
Example #20
0
        public override void OnGrab(InteractionController controller)
        {
            base.OnGrab(controller);

            //get initial rotation of the hand
            startEulerRotation = controller.Target.transform.rotation.eulerAngles.z +
                                 gameObject.transform.localRotation.eulerAngles.z;
        }
Example #21
0
 public void RemoveController(InteractionController controller)
 {
     graspingControllers.Remove(controller);
     if (graspingControllers.Count == 1)
     {
         firstHandGraspOffset = interactionObject.transform.position - graspingControllers[0].GetGraspPoint();
     }
 }
Example #22
0
    private void Awake()
    {
        _instance = this;

        collier = GetComponent <SphereCollider>();

        timer = resetTimeSize;
    }
Example #23
0
    public static bool IsPointing(this InteractionController controller)
    {
        // only check two fingers because the latter two are more unstable
        var hand = controller.intHand.leapHand;

        return(hand.GetIndex().IsExtended&&
               !hand.GetMiddle().IsExtended);
    }
Example #24
0
 private void Start()
 {
     theIC              = FindObjectOfType <InteractionController>();
     theCam             = FindObjectOfType <CameraController>();
     theSpriteManager   = FindObjectOfType <SpriteManager>();
     theSplashManager   = FindObjectOfType <SplashManager>();
     theCutSceneManager = FindObjectOfType <CutSceneManager>();
 }
Example #25
0
        private void Start()
        {
            rbody = GetComponent <Rigidbody>();
            rbody.freezeRotation = true;

            relativeCam           = GetComponent <RelativeCam>();
            interactionController = GetComponent <InteractionController>();
        }
 public void Setup()
 {
     combatController      = CharacterDesign.CombatModule(gameObject);
     movementController    = CharacterDesign.MovementModule(gameObject);
     interactionController = CharacterDesign.InteractionModule(gameObject);
     animationController   = CharacterDesign.AnimationModule(gameObject);
     playerStats           = CharacterDesign.StatsModule(gameObject);
 }
Example #27
0
 private void EnableDefaults()
 {
     FlashLightController.Enable();
     WeaponController.Enable();
     SelectionController.Enable();
     InteractionController.Enable();
     MasterSoundController.Enable();
 }
Example #28
0
        public InteractionManager(KinectSensor sensor, RemoScheduler _remoScheduler)
        {
            leftHandLocation  = new Point();
            rightHandLocation = new Point();
            remoScheduler     = _remoScheduler;

            interactionController = new InteractionController();
            interactionController.setSensor(sensor);
        }
        public void RemoveController(InteractionController controller)
        {
            var collection = _controllerToPoints[controller];

            _controllerToPoints.Remove(controller);

            // Return the collection to the pool so it can be re-used.
            PosePointCollection.Return(collection);
        }
        private void drawControllerStatusEditor(InteractionController controller)
        {
            // Controller object
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.ObjectField(controller, typeof(InteractionController), true);
            EditorGUI.EndDisabledGroup();

            // Status
            var messages = statusMessagesBuffer;

            messages.Clear();

            // Check various states and add messages to the messages buffer.
            checkTrackingStatus(controller, messages);

            if (controller.intHand != null)
            {
                checkInteractionHandStatus(controller.intHand, messages);
            }
            else if (controller is InteractionXRController)
            {
                checkInteractionVRControllerStatus(controller as InteractionXRController, messages);
            }

            // Render the status messages.
            Rect statusMessagesRect = EditorGUILayout.BeginVertical(GUILayout.MinHeight(20));

            EditorGUI.DrawRect(statusMessagesRect, Colors.DarkGray);
            statusMessagesRect = statusMessagesRect.ShrinkOne();
            EditorGUI.DrawRect(statusMessagesRect, Colors.LightGray);
            statusMessagesRect = statusMessagesRect.ShrinkOne();
            EditorGUI.DrawRect(statusMessagesRect, Colors.DarkGray);

            if (messages.Count == 0)
            {
                messages.Add(new ControllerStatusMessage()
                {
                    message = "No Status Messages",
                    tooltip = "",
                    color   = Colors.Good
                });
            }

            foreach (var statusMessage in messages)
            {
                var messageColorStyle = new GUIStyle(EditorStyles.label);
                messageColorStyle.normal.textColor = statusMessage.color;

                EditorGUILayout.LabelField(new GUIContent("[" + statusMessage.message + "]",
                                                          statusMessage.tooltip),
                                           messageColorStyle);
                GUILayout.Space(1);
            }
            GUILayout.Space(1);

            EditorGUILayout.EndVertical();
        }
Example #31
0
 void Awake()
 {
     _instance = this;
     _grabbingInfoSettings = GetComponent<GrabbingInfoSettings>();
 }
Example #32
0
 void OnDestroy()
 {
     _instance = null;
 }