public void ReceiverJoystickInput(VRController c, ControllerComponentArgs e) { if (JoyStickTouched != null) { JoyStickTouched.Invoke(c, e); } }
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} // }); }
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} // }); }
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; } }
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; } }
private void UnGrab(VRController c, ControllerComponentArgs e) { foreach (Grippable g in grabbed) { g.ReleaseController(this, e); } grabbed = new List <Grippable>(); }
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; }
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); }
/// <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; }
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; }
void togglePenMode(VRController c, ControllerComponentArgs e) { if (mode == MODE.marker) { mode = MODE.grab; } else { mode = MODE.marker; } }
void stopErasing(VRController sender, ControllerComponentArgs e) { if (sender == leftController) { leftMarker.stopFreeErasing(); } else { rightMarker.stopFreeErasing(); } }
void startDrawing(VRController sender, ControllerComponentArgs e) { if (sender == leftController) { leftMarker.startFreeDrawing(); } else { rightMarker.startFreeDrawing(); } }
void ToggleMode(VRController c, ControllerComponentArgs e) { if (penMode) { SwitchToRayCastMode(); } else { SwitchToPenMode(); } penMode = !penMode; }
void ButtonPress(VRController c, ControllerComponentArgs e) { if (!sender.CurrTargetData.hitting) { return; } button = sender.CurrTargetData.target.GetComponent <RayCastButton>(); if (button != null) { button.PressButton(this.gameObject); } }
/// <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; }
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."); } }
void ButtonPress(VRController c, ControllerComponentArgs e) { if (!target) { return; } button = GetComponent <RayCastButton>(); if (button != null) { button.PressButton(this.gameObject); } }
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(); }
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); }
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; } }
protected void Grab(VRController c, ControllerComponentArgs e) { if (GrabAll(gripOptionsHigh, c, e)) { return; } else if (GrabAll(gripOptionsMedium, c, e)) { return; } GrabAll(gripOptionsLow, c, e); }
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); } }
// <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); }
//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); } }
// Description: allows marker to start erasing lines drawn on 3D space public void stopFreeErasing(VRController c, ControllerComponentArgs e) { stopFreeErasing(); }
/* * -------------------------------------------------- * ----------------FREEDRAW FUNCTIONS---------------- * -------------------------------------------------- */ // Description: allows marker to start free drawing in 3D space public void startFreeDrawing(VRController c, ControllerComponentArgs e) { startFreeDrawing(); }
public virtual void stickDownOperation(VRController c, ControllerComponentArgs e) { }
public virtual void stickRightOperation(VRController c, ControllerComponentArgs e) { switchModeUp(); triggerReleaseOperation(c, e); }
public virtual void triggerReleaseOperation(VRController c, ControllerComponentArgs e) { active = false; }