Ejemplo n.º 1
0
 public void ReceiverJoystickInput(VRController c, ControllerComponentArgs e)
 {
     if (JoyStickTouched != null)
     {
         JoyStickTouched.Invoke(c, e);
     }
 }
Ejemplo n.º 2
0
    void PushSelected(VRController c, ControllerComponentArgs e)
    {
        // @stats
        // joystick pushpull
        // Calcflow.UserStatistics.StatisticsTracking.StartEvent("Joystick", "Push-Pull",
        // new Dictionary<string, object>()
        // {
        //     {"Hand", rayGrabber.gameObject.name}
        // });

        if (Mathf.Abs(e.x) > Mathf.Abs(e.y))
        {
            return;
        }

        Vector3 currPos = rayGrabber.transform.position;
        Vector3 nextPos = currPos + transform.forward * e.y * speed;

        float angle = Vector3.Angle(transform.forward, nextPos - transform.position);


        if (Mathf.Abs(angle) < 90)
        {
            rayGrabber.transform.position = nextPos;
        }

        // @stats
        // joystick pushpull
        // Calcflow.UserStatistics.StatisticsTracking.EndEvent("Joystick", "Push-Pull",
        // new Dictionary<string, object>()
        // {
        //     {"Hand", rayGrabber.gameObject.name}
        // });
    }
Ejemplo n.º 3
0
    void RotateSelected(VRController c, ControllerComponentArgs e)
    {
        // @stats
        // joystick rotate
        // Calcflow.UserStatistics.StatisticsTracking.StartEvent("Joystick", "Rotate",
        // new Dictionary<string, object>()
        // {
        //     {"Hand", rayGrabber.gameObject.name}
        // });

        if (Mathf.Abs(e.y) > Mathf.Abs(e.x))
        {
            return;
        }

        rayGrabber.transform.RotateAround(rayGrabber.transform.position, Vector3.up, e.x * 4);

        // @stats
        // joystick pushpull
        // Calcflow.UserStatistics.StatisticsTracking.EndEvent("Joystick", "Rotate",
        // new Dictionary<string, object>()
        // {
        //     {"Hand", rayGrabber.gameObject.name}
        // });
    }
Ejemplo n.º 4
0
    public override void triggerReleaseOperation(VRController c, ControllerComponentArgs e)
    {
        base.triggerReleaseOperation(c, e);

        switch (currMode)
        {
        case 0:
            break;

        case 1:
            break;

        case 2:
            if (ball != null)
            {
                print(i++);
                ball.name = "CurveBall";
                ball.transform.SetParent(null, true);
                ball.AddComponent <Rigidbody>();
                rb = ball.GetComponent <Rigidbody>();

                rb.interpolation          = RigidbodyInterpolation.Interpolate;
                rb.mass                   = ballsize / .01f;
                rb.collisionDetectionMode = CollisionDetectionMode.Continuous;
                rb.velocity               = transform.forward * 10;
                rb.useGravity             = false;
            }
            break;
        }
    }
Ejemplo n.º 5
0
    public override void triggerHoldOperation(VRController c, ControllerComponentArgs e)
    {
        base.triggerHoldOperation(c, e);
        switch (currMode)
        {
        case 0:
            break;

        case 1:
            ball = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            ball.transform.localScale = new Vector3(.01f, .01f, .01f);
            ball.transform.position   = tip.position;
            rb = ball.AddComponent <Rigidbody>();
            rb.interpolation          = RigidbodyInterpolation.Interpolate;
            rb.collisionDetectionMode = CollisionDetectionMode.Continuous;
            rb.velocity   = transform.forward * 10;
            rb.useGravity = false;
            break;

        case 2:
            ballsize += 1 / (ballsize / .0001f);
            ball.transform.localScale += new Vector3(ballsize, ballsize, ballsize);
            break;
        }
    }
Ejemplo n.º 6
0
 private void UnGrab(VRController c, ControllerComponentArgs e)
 {
     foreach (Grippable g in grabbed)
     {
         g.ReleaseController(this, e);
     }
     grabbed = new List <Grippable>();
 }
Ejemplo n.º 7
0
    void OpenGrabber(VRController sender, ControllerComponentArgs e)
    {
        Vector3 scale = new Vector3(1f, 1f, 1f);

        //rightRing_b.localScale = scale;
        //rightRing_g.localScale = scale;
        //rightRing_r.localScale = scale;
        targetScale = scale;
    }
Ejemplo n.º 8
0
    void RotateSelected(VRController c, ControllerComponentArgs e)
    {
        if (Mathf.Abs(e.y) > Mathf.Abs(e.x))
        {
            return;
        }

        rayGrabber.transform.RotateAround(rayGrabber.transform.position, Vector3.up, e.x * 4);
    }
Ejemplo n.º 9
0
 /// <summary>
 /// Callback function to release a controller if already registered
 /// </summary>
 /// <param name="c"></param>
 /// <param name="e"></param>
 public virtual void ReleaseController(Grabber g, ControllerComponentArgs e)
 {
     if (activeGrabbers.Contains(g))
     {
         activeGrabbers.Remove(g);
         //c.SendHapticEvent(1, 1, 0.5f);
         OnReleaseController(g);
     }
     IsGrabbed = false;
 }
Ejemplo n.º 10
0
    void CloseGrabber(VRController sender, ControllerComponentArgs e)
    {
        Vector3 scale = new Vector3(.4f, .4f, .4f);

        //leftRing_b.localScale = scale;
        //leftRing_g.localScale = scale;
        //leftRing_r.localScale = scale;

        targetScale = scale;
    }
Ejemplo n.º 11
0
 void togglePenMode(VRController c, ControllerComponentArgs e)
 {
     if (mode == MODE.marker)
     {
         mode = MODE.grab;
     }
     else
     {
         mode = MODE.marker;
     }
 }
Ejemplo n.º 12
0
 void stopErasing(VRController sender, ControllerComponentArgs e)
 {
     if (sender == leftController)
     {
         leftMarker.stopFreeErasing();
     }
     else
     {
         rightMarker.stopFreeErasing();
     }
 }
Ejemplo n.º 13
0
 void startDrawing(VRController sender, ControllerComponentArgs e)
 {
     if (sender == leftController)
     {
         leftMarker.startFreeDrawing();
     }
     else
     {
         rightMarker.startFreeDrawing();
     }
 }
Ejemplo n.º 14
0
 void ToggleMode(VRController c, ControllerComponentArgs e)
 {
     if (penMode)
     {
         SwitchToRayCastMode();
     }
     else
     {
         SwitchToPenMode();
     }
     penMode = !penMode;
 }
Ejemplo n.º 15
0
 void ButtonPress(VRController c, ControllerComponentArgs e)
 {
     if (!sender.CurrTargetData.hitting)
     {
         return;
     }
     button = sender.CurrTargetData.target.GetComponent <RayCastButton>();
     if (button != null)
     {
         button.PressButton(this.gameObject);
     }
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Callback function to register grabbing controller
 /// </summary>
 /// <param name="c"></param>
 /// <param name="e"></param>
 public virtual void RegisterController(Grabber g, ControllerComponentArgs e)
 {
     if (activeGrabbers.Contains(g))
     {
         Debug.Log("Error, controller grabbing twice.");
         return;
     }
     activeGrabbers.AddLast(g);
     g.controller.SendHapticEvent(1, 1, 0.2f);
     OnRegisterController(g);
     IsGrabbed = true;
 }
Ejemplo n.º 17
0
 public void ChangeDistribution(VRController c, ControllerComponentArgs e)
 {
     if (submissionContainer.submission != null)
     {
         ShiftReward((decimal)e.x);
         BalanceDistribution();
     }
     else
     {
         throw new System.MissingMemberException("You didn't set the submission for this distribution picker.");
     }
 }
Ejemplo n.º 18
0
 void ButtonPress(VRController c, ControllerComponentArgs e)
 {
     if (!target)
     {
         return;
     }
     button = GetComponent <RayCastButton>();
     if (button != null)
     {
         button.PressButton(this.gameObject);
     }
 }
Ejemplo n.º 19
0
    void scroll(VRController c, ControllerComponentArgs e)
    {
        float roundBy = 90;
        float temp    = Mathf.Atan2(e.y, e.x);          //calculate angle in rad

        temp = temp * (180 / Mathf.PI);                 //rad to degree
        temp = Mathf.Round(temp / roundBy) * roundBy;   //round to nearest set degree
        temp = (temp + 360) % 360;                      //positive
        int angle = (int)temp;

        if (e.x == 0 && e.y == 0)
        {
            return;
        }

        switch (angle)
        {
        case 0:
            if (currOrientation != orientation.HORIZONTAL)
            {
                return;
            }
            currDirection = direction.LEFT;
            break;

        case 90:
            if (currOrientation != orientation.VERTICAL)
            {
                return;
            }
            currDirection = direction.DOWN;
            break;

        case 180:
            if (currOrientation != orientation.HORIZONTAL)
            {
                return;
            }
            currDirection = direction.RIGHT;
            break;

        case 270:
            if (currOrientation != orientation.VERTICAL)
            {
                return;
            }
            currDirection = direction.UP;
            break;
        }

        moveObjects();
    }
Ejemplo n.º 20
0
    protected bool GrabAll(List <Grippable> gripOptions, VRController c, ControllerComponentArgs e)
    {
        if (gripOptions.Count == 0)
        {
            return(false);
        }

        foreach (Grippable g in gripOptions)
        {
            GrabObject(g, e);
        }
        return(true);
    }
Ejemplo n.º 21
0
    void PushSelected(VRController c, ControllerComponentArgs e)
    {
        Vector3 currPos = rayGrabber.transform.position;
        Vector3 nextPos = currPos + transform.forward * e.y * speed;

        float angle = Vector3.Angle(transform.forward, nextPos - transform.position);


        if (Mathf.Abs(angle) < 90)
        {
            rayGrabber.transform.position = nextPos;
        }
    }
Ejemplo n.º 22
0
    protected void Grab(VRController c, ControllerComponentArgs e)
    {
        if (GrabAll(gripOptionsHigh, c, e))
        {
            return;
        }
        else if (GrabAll(gripOptionsMedium, c, e))
        {
            return;
        }

        GrabAll(gripOptionsLow, c, e);
    }
Ejemplo n.º 23
0
    void SendJoyStickInput(VRController c, ControllerComponentArgs e)
    {
        if (!sender.CurrTargetData.hitting)
        {
            return;
        }
        JoyStickReceiver receiver = sender.CurrTargetData.target.GetComponent <JoyStickReceiver>();

        if (receiver != null)
        {
            receiver.ReceiverJoystickInput(c, e);
        }
    }
Ejemplo n.º 24
0
    // <summary>
    // calls appropriate joy stick call backs when joystick input is given.
    // </summary>
    public virtual void joyStickOperation(VRController c, ControllerComponentArgs e)
    {
        if (lastStick.x < .5 && e.x > .5f)
        {
            stickLeftOperation(c, e);
        }
        if (lastStick.x > -.5 && e.x < -.5f)
        {
            stickRightOperation(c, e);
        }

        if (lastStick.y < .5 && e.y > .5f)
        {
            stickUpOperation(c, e);
        }
        if (lastStick.y > -.5 && e.y < -.5f)
        {
            stickDownOperation(c, e);
        }
        lastStick = new Vector2(e.x, e.y);
    }
Ejemplo n.º 25
0
    //NOTE: need to point at the board right now to register the scroll
    //      ethan will fix it later
    void scroll(VRController c, ControllerComponentArgs e)
    {
        //if (Mathf.Abs(e.x) > Mathf.Abs(e.y)) return;

        float temp = Mathf.Atan2(e.y, e.x);             //calculate angle in rad

        temp  = temp * (180 / Mathf.PI);                //rad to degree
        temp  = Mathf.Round(temp / roundBy) * roundBy;  //round to nearest set degree
        temp  = (temp + 360) % 360;                     //positive
        angle = (int)temp;


        if (angle == 90)            //UP scroll moves buttons down
        {
            //menu.moveButtons(0);
        }
        else if (angle == 270)      //DOWN scroll moves buttons up
        {
            //menu.moveButtons(1);
        }
    }
Ejemplo n.º 26
0
 // Description: allows marker to start erasing lines drawn on 3D space
 public void stopFreeErasing(VRController c, ControllerComponentArgs e)
 {
     stopFreeErasing();
 }
Ejemplo n.º 27
0
    /*
     * --------------------------------------------------
     * ----------------FREEDRAW FUNCTIONS----------------
     * --------------------------------------------------
     */

    // Description: allows marker to start free drawing in 3D space
    public void startFreeDrawing(VRController c, ControllerComponentArgs e)
    {
        startFreeDrawing();
    }
Ejemplo n.º 28
0
 public virtual void stickDownOperation(VRController c, ControllerComponentArgs e)
 {
 }
Ejemplo n.º 29
0
 public virtual void stickRightOperation(VRController c, ControllerComponentArgs e)
 {
     switchModeUp();
     triggerReleaseOperation(c, e);
 }
Ejemplo n.º 30
0
 public virtual void triggerReleaseOperation(VRController c, ControllerComponentArgs e)
 {
     active = false;
 }