public void SetBackboneUnitControllerHover(bool value) { if (controllerHoverOn != value) { controllerHoverOn = value; myResidue.residueHovered = value; BackboneUnit buAmide = myResidue.amide_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit buCalpha = myResidue.calpha_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit buCarbonyl = myResidue.carbonyl_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit thisBBU = gameObject.GetComponent <BackboneUnit>(); if (thisBBU != buAmide) { buAmide.SetBackboneUnitControllerHover(value); } if (thisBBU != buCalpha) { buCalpha.SetBackboneUnitControllerHover(value); } if (thisBBU != buCarbonyl) { buCarbonyl.SetBackboneUnitControllerHover(value); } UpdateRenderMode(); } //controllerHoverOn = flag; //myResidue.residueHovered = flag; //UpdateRenderMode(); }
public void OnHoverEnter(Transform t) { if (t.gameObject.name == "BackButton") { t.gameObject.GetComponent <Renderer>().material = backACtive; } else { //Debug.Log("---> " + t); GameObject go = t.gameObject; BackboneUnit bu = (go.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { //Debug.Log(" --> script"); bu.SetBackboneUnitControllerHover(true); } //oldHoverMat = t.gameObject.GetComponent<Renderer>().material; //t.gameObject.GetComponent<Renderer>().material = yellowMat; } if (outText != null) { outText.text = "<b>Last Interaction:</b>\nHover Enter:" + t.gameObject.name; } }
private void UpdateSelection() { if (getSelectKey()) { //SELECT if (lastHit != null) { GameObject go = lastHit.gameObject; BackboneUnit bu = (go.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { bu.SetMyResidueSelect(true); } } } if (getDeselectKey()) { // DESELECT if (lastHit != null) { GameObject go = lastHit.gameObject; BackboneUnit bu = (go.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { bu.SetMyResidueSelect(false); } } } }
public void SetRemoteGrabSelect(bool value) { if (remoteGrabSelectOn != value) { remoteGrabSelectOn = value; myResidue.residueGrabbed = value; BackboneUnit buAmide = myResidue.amide_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit buCalpha = myResidue.calpha_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit buCarbonyl = myResidue.carbonyl_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit thisBBU = gameObject.GetComponent <BackboneUnit>(); if (thisBBU != buAmide) { buAmide.SetRemoteGrabSelect(value); } if (thisBBU != buCalpha) { buCalpha.SetRemoteGrabSelect(value); } if (thisBBU != buCarbonyl) { buCarbonyl.SetRemoteGrabSelect(value); } UpdateRenderMode(); } }
void HoverEnter(GameObject go) { // Debug.Log(" Hover Entering " + go.name + " GameObject"); BackboneUnit bu = (go.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { //Debug.Log(" --> script"); bu.SetBackboneUnitControllerHover(true); } }
void HoverExit() { GameObject go = lastHit.gameObject; //Debug.Log(" Hover Exiting " + go.name + " GameObject"); BackboneUnit bu = (go.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { bu.SetBackboneUnitControllerHover(false); } }
public void OnHoverBDown(Transform t) { { //Debug.Log("---> " + t); GameObject go = t.gameObject; BackboneUnit bu = (go.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { //Debug.Log(" --> script"); bu.SetMyResidueSelect(true); } //t.gameObject.GetComponent<Renderer>().material = oldHoverMat; } }
public void SetMyResidueSelect(bool flag) { //Residue res = (gameObject.transform.parent.gameObject.GetComponent("Residue") as Residue); if (myResidue) { //Debug.Log(" " + res); BackboneUnit buAmide = myResidue.amide_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit buCalpha = myResidue.calpha_pf.GetComponent("BackboneUnit") as BackboneUnit; BackboneUnit buCarbonyl = myResidue.carbonyl_pf.GetComponent("BackboneUnit") as BackboneUnit; buAmide.SetBackboneUnitSelect(flag); buCalpha.SetBackboneUnitSelect(flag); buCarbonyl.SetBackboneUnitSelect(flag); //Debug.Log(res + " " + flag); myResidue.residueSelected = flag; } }
public bool IsResidueSelected() { BackboneUnit buAmide = amide_pf.GetComponent("BackboneUnit") as BackboneUnit; return(buAmide.controllerSelectOn); }
void UpdateMouseRaycast() { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); //Debug.Log(Input.mousePosition); Vector3 forward = Camera.main.transform.TransformDirection(Vector3.forward) * 10; //Debug.DrawRay(transform.position, forward, Color.green); Debug.DrawRay(ray.origin, ray.GetPoint(50.0f), Color.green); Camera.main.ScreenToViewportPoint(Input.mousePosition); //myMouseProxy.transform.position = ray.GetPoint(1.0f); //Debug.DrawLine(ray.origin, ray.origin + ray.direction * 100, Color.red); //Debug.DrawRay(ray.origin, ray.direction * 100, Color.cyan); if (Physics.Raycast(ray, out hit, 200.0f)) { if (hit.transform) { hitPoint = hit.point; //myMouseProxy.transform.position = hitPoint; distToHitPoint = Vector3.Magnitude(hitPoint - Camera.main.transform.position); // raycast is hitting something GameObject go = hit.transform.gameObject; //Debug.Log(hit.transform.gameObject.name); if (hit.transform != lastHit) { // something is not what I hit (or didn't hit) last frame if (lastHit != null) { // was hitting something last frame - but have exited it HoverExit(); } // have entered something new HoverEnter(go); } // store current hit as lasthit lastHit = hit.transform; doTractorBeam(go, ray); } else { } } else { if (lastHit != null) { HoverExit(); lastHit = null; } } // REMOTE GRAB if (getRemoteGrabDown() && lastHit && !grabbing) { startGrab = true; grabbing = true; remoteGrabObj = lastHit.gameObject; grabObjOffset = remoteGrabObj.transform.position - hitPoint; grabObjDist = distToHitPoint - fudge; grabObjDistTarget = grabObjDist; BackboneUnit bu = (remoteGrabObj.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { bu.SetRemoteGrabSelect(true); } } if (getRemoteGrabUp()) { grabbing = false; if (remoteGrabObj) { BackboneUnit bu = (remoteGrabObj.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { bu.SetRemoteGrabSelect(false); } remoteGrabObj = null; } } if (grabbing) { // add wheel input and smooth if (Input.GetAxis("Mouse ScrollWheel") != 0) { float scrollAmount = (Input.GetAxis("Mouse ScrollWheel") * mouseWheelSensitivity); scrollAmount *= (grabObjDistTarget * 0.3f); grabObjDistTarget += scrollAmount; } grabObjDist = Mathf.Lerp(grabObjDist, grabObjDistTarget, mouseTractorSmoothing); // ray.GetPoint(grabObjDist) doesn't behave as expected - hence fudge Vector3 remoteGrabTargetPosition = ray.GetPoint(grabObjDist) + grabObjOffset; RemoteGrabInteraction(remoteGrabObj.transform, remoteGrabTargetPosition); //// copy pasted from OVRRawRaycaster.cs Transform remoteGrab = remoteGrabObj.transform; if (remoteGrab.gameObject.tag == "UI") { // UI - make the 'front' face the pointer // flipped because UI GO was initially set up with z facing away //Use pointer position //Vector3 lookAwayPos = remoteGrab.gameObject.transform.position + pointer.direction; //Use HMD (possibly better - maybe a bit queasy) Vector3 lookAwayPos = remoteGrab.gameObject.transform.position + Camera.main.transform.forward; // use the transform of the GO this script is attached to (RawInteraction) as proxy for storing target rotation :) transform.position = remoteGrab.position; transform.LookAt(lookAwayPos, Vector3.up); // lerp to target - eases the rotation of the UI - useful when remote grab just initiated remoteGrab.gameObject.transform.rotation = Quaternion.Lerp(remoteGrab.gameObject.transform.rotation, transform.rotation, Time.deltaTime * 10.0f); //remoteGrab.gameObject.transform.LookAt(lookAwayPos, Vector3.up); } //// } }
void Update() { activeController = OVRInputHelpers.GetControllerForButton(OVRInput.Button.PrimaryIndexTrigger, activeController); Ray pointer = OVRInputHelpers.GetSelectionRay(activeController, trackingSpace); RaycastHit hit; // Was anything hit? if (Physics.Raycast(pointer, out hit, raycastDistance, ~excludeLayers)) { myHitPos = hit.point; myOVRPointerVisualizer.rayDrawDistance = hit.distance; //Debug.Log(hit.distance); if (lastHit != null && lastHit != hit.transform) { if (onHoverExit != null) { onHoverExit.Invoke(lastHit); } lastHit = null; } if (lastHit == null) { if (onHoverEnter != null) { onHoverEnter.Invoke(hit.transform); } } if (onHover != null) { onHover.Invoke(hit.transform); } lastHit = hit.transform; // Handle selection callbacks. An object is selected if the button selecting it was // pressed AND released while hovering over the object. if (activeController != OVRInput.Controller.None) { if (OVRInput.GetDown(secondaryButton, activeController)) { secondaryDown = lastHit; //Debug.Log("1"); } else if (OVRInput.GetUp(secondaryButton, activeController)) { if (secondaryDown != null && secondaryDown == lastHit) { if (onSecondarySelect != null) { onSecondarySelect.Invoke(secondaryDown, pointer); //Debug.Log("2"); } } } if (!OVRInput.Get(secondaryButton, activeController)) { secondaryDown = null; //Debug.Log("3"); } if (OVRInput.GetDown(primaryButton, activeController)) { primaryDown = lastHit; //Debug.Log("4"); } else if (OVRInput.GetUp(primaryButton, activeController)) { if (primaryDown != null && primaryDown == lastHit) { if (onPrimarySelect != null) { onPrimarySelect.Invoke(primaryDown, pointer); //Debug.Log("5"); } } } if (!OVRInput.Get(primaryButton, activeController)) { primaryDown = null; //Debug.Log("6"); } } if (lastHit) { /// if (OVRInput.Get(aButton, activeController)) { aDown = lastHit; } else { aDown = null; } if (OVRInput.Get(bButton, activeController)) { bDown = lastHit; } else { bDown = null; } } if (aDown) { //Debug.Log("A---->" + aDown); onHoverADown.Invoke(aDown); } if (bDown) { //Debug.Log("B---->" + bDown); onHoverBDown.Invoke(bDown); } if (primaryDown && !secondaryDown) { //Debug.Log(primaryDown); //Debug.Log(axisValue); if (!tractorBeaming) { tractorBeaming = true; tractorTime = 0.0f; tractorAxisInputFiltered = 0.0f; } else { tractorTime += Time.deltaTime; if (tractorTime > tractorDelay) { float axisValue = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, activeController); tractorAxisInputFiltered = Mathf.Lerp(tractorAxisInputFiltered, axisValue, tractorLerp); onPrimarySelectDownAxis.Invoke(primaryDown, pointer, tractorAxisInputFiltered); } } } else if (secondaryDown && !primaryDown) { //Debug.Log(secondaryDown); //Debug.Log(axisValue); if (!tractorBeaming) { tractorBeaming = true; tractorTime += Time.deltaTime; tractorAxisInputFiltered = 0.0f; } else { tractorTime++; if (tractorTime > tractorDelay) { float axisValue = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, activeController); tractorAxisInputFiltered = Mathf.Lerp(tractorAxisInputFiltered, axisValue, tractorLerp); onSecondarySelectDownAxis.Invoke(secondaryDown, pointer, tractorAxisInputFiltered); } } } else { tractorBeaming = false; } #if UNITY_ANDROID && !UNITY_EDITOR // Gaze pointer fallback else { if (Input.GetMouseButtonDown(0)) { triggerDown = lastHit; } else if (Input.GetMouseButtonUp(0)) { if (triggerDown != null && triggerDown == lastHit) { if (onPrimarySelect != null) { onPrimarySelect.Invoke(triggerDown); } } } if (!Input.GetMouseButton(0)) { triggerDown = null; } } #endif //REMOTE GRAB if (!remoteGrab) { // remoteGrab not set - looking for candidate if (lastHit) { if (primaryDown && secondaryDown) { if (lastHit == primaryDown && lastHit == secondaryDown) { // START remote grabbing //Debug.Log(lastHit + " is candidate for remoteGrab"); remoteGrab = lastHit; // initially set remoteGrabTargetDistance to hit.distance remoteGrabTargetDistance = hit.distance; remoteGrabHitOffset = remoteGrab.position - hit.point; //Debug.Log(" --->" + hit.distance); remoteGrabStartPos = hit.point; approxMovingAvgPoke = 0f; remoteGrabTime = 0.0f; remoteGrabObjectStartQ = remoteGrab.gameObject.transform.rotation; remoteGrabControllerStartQ = OVRInput.GetLocalControllerRotation(activeController); BackboneUnit bu = (remoteGrab.gameObject.GetComponent("BackboneUnit") as BackboneUnit); if (bu != null) { bu.SetRemoteGrabSelect(true); //bu.remoteGrabSelectOn = true; //bu.UpdateRenderMode(); } //Rigidbody hitRigidBody = lastHit.gameObject.GetComponent<Rigidbody>(); //remoteGrabOffset = hitRigidBody.position - hit.point; } } } } else { } }