private bool EventListener(vrEvent iEvent) { vrInteractionEvent evt = vrInteractionEvent.Cast(iEvent); if (evt == null) { return(false); } vrInteraction evtInteraction = evt.GetInteraction(); if (m_Interaction != null && evtInteraction != null && evt != null && evtInteraction.GetId() == m_Interaction.GetId()) { var eventType = evt.GetEventType(); if (eventType == (int)VRInteractionEventEnum.VRInteractionEvent_Activated) { Activate(); } else if (eventType == (int)VRInteractionEventEnum.VRInteractionEvent_Deactivated) { Deactivate(); } } return(true); }
private void _RefreshManipulationMenuName() { vrInteraction interaction = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousManipulation"); if (interaction != null) { switch (interaction.GetName()) { case "InteractionManipulationRay": { m_ManipulationOptions.SetLabel("Manipulation (Ray)"); break; } case "InteractionManipulationHomer": { m_ManipulationOptions.SetLabel("Manipulation (Homer)"); break; } default: { m_ManipulationOptions.SetLabel("Manipulation (" + interaction.GetName() + ")"); break; } } } else { m_ManipulationOptions.SetLabel("Manipulation"); } }
private void Grab(GameObject iGrabbedObject) { if (iGrabbedObject == null) { return; } m_CurrentManipulatedObject = iGrabbedObject; VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>(); m_ObjectPreviousSyncDir = vrActorScript.SyncDirection; vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity; vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode(); m_it.SetManipulatedNode(middleVRNode); m_it.SetPivotPositionVirtualWorld(MVRTools.FromUnity(m_CurrentManipulatedObject.GetComponent <Collider>().bounds.center)); // Save initial position m_ObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition; m_ObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation; // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } // Hide Wand m_VRMgr.ShowWandGeometry(false); }
private vrInteraction _GetNextInteraction(string iTag) { vrInteraction nextInteraction = null; vrInteraction activeInteraction = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousNavigation"); if (activeInteraction != null) { // Found active interaction, search for the next one uint interactionsNb = MiddleVR.VRInteractionMgr.GetInteractionsNb(); uint index = MiddleVR.VRInteractionMgr.GetInteractionIndex(activeInteraction); for (uint i = 0; i < interactionsNb - 1; ++i) { // We loop in the interactions list to find the next interaction with the right tag uint nextIndex = (index + 1 + i) % interactionsNb; vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteractionByIndex(nextIndex); if (interaction != null && interaction.TagsContain("ContinuousNavigation")) { nextInteraction = interaction; break; } } } else { // No active interaction, try to activate the first if existing nextInteraction = MiddleVR.VRInteractionMgr.GetInteractionByTag("ContinuousNavigation", 0); } return(nextInteraction); }
private void _RefreshVirtualHandMenuName() { vrInteraction interaction = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("VirtualHand"); if (interaction != null) { switch (interaction.GetName()) { case "InteractionVirtualHandGogo": { m_VirtualHandOptions.SetLabel("Virtual Hand (Gogo)"); break; } default: { m_VirtualHandOptions.SetLabel("Virtual Hand (" + interaction.GetName() + ")"); break; } } } else { m_VirtualHandOptions.SetLabel("Virtual Hand"); } }
private void Grab(GameObject iGrabbedObject) { m_CurrentManipulatedObject = iGrabbedObject; m_it.SetManipulatedNode(AcquireGameObjectNode(m_CurrentManipulatedObject, "InteractionManipulationHomerNode")); m_it.SetPivotPositionVirtualWorld(MVRTools.FromUnity(m_CurrentManipulatedObject.GetComponent <Collider>().bounds.center)); // Pause rigidbody acceleration Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent <Rigidbody>(); if (manipulatedRigidbody != null) { m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic; manipulatedRigidbody.isKinematic = true; } // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } // Hide Wand m_VRMgr.ShowWandGeometry(false); }
private void Grab(GameObject iGrabbedObject) { if (iGrabbedObject == null) { return; } // Initialize manipulated node m_CurrentManipulatedObject = iGrabbedObject; VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>(); m_ObjectPreviousSyncDir = vrActorScript.SyncDirection; vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity; vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode(); m_it.SetManipulatedNode(middleVRNode); // Save initial position m_ObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition; m_ObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation; // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } }
private void _RefreshNavigationMenuName() { vrInteraction interaction = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousNavigation"); if (interaction != null) { switch (interaction.GetName()) { case "InteractionNavigationWandJoystick": { m_NavigationOptions.SetLabel("Navigation (Joystick)"); break; } case "InteractionNavigationElastic": { m_NavigationOptions.SetLabel("Navigation (Elastic)"); break; } case "InteractionNavigationGrabWorld": { m_NavigationOptions.SetLabel("Navigation (Grab The World)"); break; } default: { m_NavigationOptions.SetLabel("Navigation (" + interaction.GetName() + ")"); break; } } } else { m_NavigationOptions.SetLabel("Navigation"); } }
private void Ungrab() { if (m_CurrentManipulatedObject == null) { return; } // Give to return objects script VRInteractionManipulationReturnObjects returningObjectScript = this.GetComponent <VRInteractionManipulationReturnObjects>(); if (returningObjectScript != null) { if (returningObjectScript.enabled) { returningObjectScript.AddReturningObject(m_CurrentManipulatedObject, m_ObjectInitialLocalPosition, m_ObjectInitialLocalRotation, false); } } // Reset m_it.SetManipulatedNode(null); VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>(); vrActorScript.SyncDirection = m_ObjectPreviousSyncDir; m_CurrentManipulatedObject = null; // Reactivate selection after the manipulation if (m_PausedSelection != null) { MiddleVR.VRInteractionMgr.Activate(m_PausedSelection); m_PausedSelection = null; } }
public void CreateInteractionToggleButton(vrInteraction iInteraction, string iButtonName, vrWidgetMenu iParentMenu, string iButtonHandlerName) { string itName = iInteraction.GetName(); vrWidgetToggleButton button = new vrWidgetToggleButton("VRMenu." + itName + "ToggleButton", iParentMenu, iButtonName, MVRTools.GetCommand(iButtonHandlerName), iInteraction.IsActive()); m_Buttons.Add(itName, button); MVRTools.RegisterObject(this, button); }
private bool EventListener(vrEvent iEvent) { // Catch interaction events vrInteractionEvent interactionEvt = vrInteractionEvent.Cast(iEvent); if (interactionEvt != null) { vrInteraction interaction = interactionEvt.GetInteraction(); bool needLabelRefresh = false; // Identify interaction // If existing in the Menu, update the menu if (interactionEvt.GetEventType() == (int)VRInteractionEventEnum.VRInteractionEvent_Activated) { vrWidgetToggleButton interactionButton; if (m_Buttons.TryGetValue(interaction.GetName(), out interactionButton)) { interactionButton.SetChecked(true); } needLabelRefresh = true; } else if (interactionEvt.GetEventType() == (int)VRInteractionEventEnum.VRInteractionEvent_Deactivated) { vrWidgetToggleButton interactionButton; if (m_Buttons.TryGetValue(interaction.GetName(), out interactionButton)) { interactionButton.SetChecked(false); } needLabelRefresh = true; } // Refresh interaction menu label if activated or deactivated if (needLabelRefresh) { if (interaction.TagsContain("ContinuousNavigation")) { _RefreshNavigationMenuName(); } else if (interaction.TagsContain("ContinuousManipulation")) { _RefreshManipulationMenuName(); } else if (interaction.TagsContain("VirtualHand")) { _RefreshVirtualHandMenuName(); } } } return(true); }
public void CreateInteractionToggleButton(vrInteraction iInteraction, string iButtonName, vrWidgetMenu iParentMenu, vrCommand.Delegate iButtonHandler) { string itName = iInteraction.GetName(); vrCommand newCommand = new vrCommand("VRMenu." + itName + "ToggleCommand", iButtonHandler); m_Commands.Add(itName, newCommand); vrWidgetToggleButton button = new vrWidgetToggleButton("VRMenu." + itName + "ToggleButton", iParentMenu, iButtonName, newCommand, iInteraction.IsActive()); m_Buttons.Add(itName, button); }
protected void InitializeFromActiveNavigation() { // Search for navigation interaction parameters uint interactionNb = MiddleVR.VRInteractionMgr.GetInteractionsNb(); if (interactionNb == 0) { MVRTools.Log(4, "[~] VRHeadCollision: no interaction found in Interaction Manager."); return; } bool fly = true; vrNode3D navNodeMVR = null; for (uint i = 0; i < interactionNb; ++i) { vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteractionByIndex(i); if (interaction.IsActive() && interaction.TagsContain("Navigation")) { // Get fly mode vrProperty flyProp = interaction.GetProperty("Fly"); if (flyProp != null) { fly = flyProp.GetBool(); } // Get navigation node vrProperty navNodeProp = interaction.GetProperty("NavigationNode"); if (navNodeProp != null) { navNodeMVR = MiddleVR.VRDisplayMgr.GetNode(navNodeProp.GetObject().GetName()); } break; } } if (navNodeMVR == null) { MVRTools.Log(2, "[X] VRNavigationCollision: impossible to retrieve navigation node."); return; } // Initialize parameters from found ones SetCollisionNode(GameObject.Find(CollisionNodeName)); SetNavigationNode(navNodeMVR); SetFly(fly); // Try to start the collisions Initialize(); }
private void Ungrab() { if (m_CurrentManipulatedObject == null) { return; } if (OnGrab != null) { OnGrab(this, e_GrabStatus.UNGRABBED); } // Give to return objects script VRInteractionManipulationReturnObjects returningObjectScript = this.GetComponent <VRInteractionManipulationReturnObjects>(); if (returningObjectScript != null) { if (returningObjectScript.enabled) { returningObjectScript.AddReturningObject(m_CurrentManipulatedObject, m_ManipulatedObjectInitialLocalPosition, m_ManipulatedObjectInitialLocalRotation, false); } } // Reset m_it.SetManipulatedNode(null); VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>(); vrActorScript.SyncDirection = m_ObjectPreviousSyncDir; // Unpause rigidbody acceleration Rigidbody manipulatedRigidbody = m_CurrentManipulatedObject.GetComponent <Rigidbody>(); if (manipulatedRigidbody != null) { manipulatedRigidbody.isKinematic = m_ManipulatedObjectInitialIsKinematic; } // Reactivate selection after the manipulation if (m_PausedSelection != null) { MiddleVR.VRInteractionMgr.Activate(m_PausedSelection); m_PausedSelection = null; } m_CurrentManipulatedObject = null; }
public vrInteraction CreateInteraction(string iName) { if (m_Interaction == null) { // Create the requested interaction m_Interaction = new vrInteraction(iName); MiddleVR.VRInteractionMgr.AddInteraction(m_Interaction); } else { // Interaction already existing, rename it m_Interaction.SetName(iName); } return(m_Interaction); }
public vrInteraction CreateInteraction(string iName) { if (m_Interaction == null) { // Create the requested interaction m_Interaction = new vrInteraction(iName); MiddleVR.VRInteractionMgr.AddInteraction(m_Interaction); } else { // Interaction already existing, rename it m_Interaction.SetName(iName); } return m_Interaction; }
private void ManipulationHomerHandler(bool iValue) { // Activate Homer Manipulation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"); bool activate = iValue; if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Manipulation Homer activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Manipulation Homer deactivated."); } }
private void NavigationGrabWorldHandler(bool iValue) { // Activate Grab World Navigation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld"); bool activate = iValue; if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Navigation Grab World activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Navigation Grab World deactivated."); } }
private void NavigationElasticHandler(bool iValue) { // Activate Elastic Navigation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationElastic"); bool activate = iValue; if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Navigation Elastic activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Navigation Elastic deactivated."); } }
private void NavigationJoystickHandler(bool iValue) { // Activate Joystick Navigation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick"); bool activate = iValue; if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Navigation Joystick activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Navigation Joystick deactivated."); } }
private void VirtualHandGogoButtonHandler(bool iValue) { // Activate Gogo Virtual Hand vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"); bool activate = iValue; if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Virtual Hand Gogo activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Virtual Hand Gogo deactivated."); } }
private void Grab(GameObject iGrabbedObject) { if (iGrabbedObject == null) { return; } if (OnGrab != null) { OnGrab(this, e_GrabStatus.GRABBED); } // Initialize manipulated node m_CurrentManipulatedObject = iGrabbedObject; VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent <VRActor>(); m_ObjectPreviousSyncDir = vrActorScript.SyncDirection; vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.BothDirections; vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode(); m_it.SetManipulatedNode(middleVRNode); // Save initial position m_ManipulatedObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition; m_ManipulatedObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation; // Pause rigidbody acceleration Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent <Rigidbody>(); if (manipulatedRigidbody != null) { m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic; manipulatedRigidbody.isKinematic = true; } // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } }
private void Ungrab() { if (m_CurrentManipulatedObject == null) { return; } // Give to return objects script VRInteractionManipulationReturnObjects returningObjectScript = this.GetComponent <VRInteractionManipulationReturnObjects>(); if (returningObjectScript != null) { if (returningObjectScript.enabled) { returningObjectScript.AddReturningObject(m_CurrentManipulatedObject, m_ManipulatedObjectInitialLocalPosition, m_ManipulatedObjectInitialLocalRotation, false); } } // Reset m_it.SetManipulatedNode(null); ReleaseGameObjectNode(m_CurrentManipulatedObject); // Show Wand m_VRMgr.ShowWandGeometry(true); // Unpause rigidbody acceleration Rigidbody manipulatedRigidbody = m_CurrentManipulatedObject.GetComponent <Rigidbody>(); if (manipulatedRigidbody != null) { manipulatedRigidbody.isKinematic = m_ManipulatedObjectInitialIsKinematic; } // Reactivate selection after the manipulation if (m_PausedSelection != null) { MiddleVR.VRInteractionMgr.Activate(m_PausedSelection); m_PausedSelection = null; } m_CurrentManipulatedObject = null; }
private vrValue ManipulationHomerHandler(vrValue iValue) { // Activate Homer Manipulation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionManipulationHomer"); bool activate = iValue.GetBool(); if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Manipulation Homer activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Manipulation Homer deactivated."); } return null; }
private vrValue NavigationGrabWorldHandler(vrValue iValue) { // Activate Grab World Navigation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationGrabWorld"); bool activate = iValue.GetBool(); if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Navigation Grab World activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Navigation Grab World deactivated."); } return null; }
private vrValue VirtualHandGogoButtonHandler(vrValue iValue) { // Activate Gogo Virtual Hand vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionVirtualHandGogo"); bool activate = iValue.GetBool(); if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Virtual Hand Gogo activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Virtual Hand Gogo deactivated."); } return null; }
private vrValue NavigationJoystickHandler(vrValue iValue) { // Activate Joystick Navigation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationWandJoystick"); bool activate = iValue.GetBool(); if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Navigation Joystick activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Navigation Joystick deactivated."); } return null; }
private vrValue NavigationElasticHandler(vrValue iValue) { // Activate Elastic Navigation vrInteraction interaction = MiddleVR.VRInteractionMgr.GetInteraction("InteractionNavigationElastic"); bool activate = iValue.GetBool(); if (activate) { MiddleVR.VRInteractionMgr.Activate(interaction); MVRTools.Log("[ ] Navigation Elastic activated."); } else { MiddleVR.VRInteractionMgr.Deactivate(interaction); MVRTools.Log("[ ] Navigation Elastic deactivated."); } return(null); }
private bool EventListener(vrEvent iEvent) { // Catch interaction events vrInteractionEvent interactionEvt = vrInteractionEvent.Cast(iEvent); if (interactionEvt != null) { vrInteraction interaction = interactionEvt.GetInteraction(); bool needLabelRefresh = false; // Identify interaction // If existing in the Menu, update the menu if (interactionEvt.GetEventType() == (int)VRInteractionEventEnum.VRInteractionEvent_Activated) { vrWidgetToggleButton interactionButton; if (m_Buttons.TryGetValue(interaction.GetName(), out interactionButton)) { interactionButton.SetChecked(true); } needLabelRefresh = true; } else if (interactionEvt.GetEventType() == (int)VRInteractionEventEnum.VRInteractionEvent_Deactivated) { vrWidgetToggleButton interactionButton; if (m_Buttons.TryGetValue(interaction.GetName(), out interactionButton)) { interactionButton.SetChecked(false); } needLabelRefresh = true; } } return(true); }
private void Grab(GameObject iGrabbedObject) { // Initialize manipulated node m_CurrentManipulatedObject = iGrabbedObject; m_it.SetManipulatedNode(AcquireGameObjectNode(m_CurrentManipulatedObject, "VRInteractionManipulationRayNode")); // Pause rigidbody acceleration Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent <Rigidbody>(); if (manipulatedRigidbody != null) { m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic; manipulatedRigidbody.isKinematic = true; } // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } }
private void ContinueGrab(GameObject iGrabbedObject) { m_CurrentManipulatedObject = iGrabbedObject; m_it.SetManipulatedNode(AcquireGameObjectNode(m_CurrentManipulatedObject, "InteractionManipulationHomerNode")); m_it.SetPivotPositionVirtualWorld(MVRTools.FromUnity(m_CurrentManipulatedObject.GetComponent<Collider>().bounds.center)); // Pause rigidbody acceleration Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent<Rigidbody>(); if (manipulatedRigidbody != null) { m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic; manipulatedRigidbody.isKinematic = true; } // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } // Hide Wand m_VRMgr.ShowWandGeometry(false); }
private void Grab(GameObject iGrabbedObject) { if (iGrabbedObject == null) { return; } if (OnGrab != null) { OnGrab(this, e_GrabStatus.GRABBED); } // Initialize manipulated node m_CurrentManipulatedObject = iGrabbedObject; VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent<VRActor>(); m_ObjectPreviousSyncDir = vrActorScript.SyncDirection; vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.BothDirections; vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode(); m_it.SetManipulatedNode(middleVRNode); // Save initial position m_ManipulatedObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition; m_ManipulatedObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation; // Pause rigidbody acceleration Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent<Rigidbody>(); if (manipulatedRigidbody != null) { m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic; manipulatedRigidbody.isKinematic = true; } // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } }
// Update is called once per frame void Update() { //MVRTools.Log("VRManagerUpdate"); // Initialize interactions if (!m_InteractionsInitialized) { _SetNavigation(Navigation); _SetManipulation(Manipulation); _SetVirtualHandMapping(VirtualHandMapping); m_InteractionsInitialized = true; } MVRNodesMapper nodesMapper = MVRNodesMapper.Instance; nodesMapper.UpdateNodesUnityToMiddleVR(); if (m_isInit) { MVRTools.Log(4, "[>] Unity Update - Start"); if (m_Kernel.GetFrame() >= m_FirstFrameAfterReset + 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { m_DisplayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } if (m_Kernel.GetFrame() == 0) { // Set the random seed in kernel for dispatching only during start-up. // With clustering, a client will be set by a call to kernel.Update(). if (!m_ClusterMgr.IsCluster() || (m_ClusterMgr.IsCluster() && m_ClusterMgr.IsServer())) { // The cast is safe because the seed is always positive. uint seed = (uint)UnityEngine.Random.seed; m_Kernel._SetRandomSeed(seed); } } m_Kernel.Update(); if (m_Kernel.GetFrame() == 0) { // Set the random seed in a client only during start-up. if (m_ClusterMgr.IsCluster() && m_ClusterMgr.IsClient()) { // The cast is safe because the seed comes from // a previous value of Unity. int seed = (int)m_Kernel.GetRandomSeed(); UnityEngine.Random.seed = seed; } } UpdateInput(); if (ShowFPS) { this.GetComponent <GUIText>().text = m_Kernel.GetFPS().ToString("f2"); } nodesMapper.UpdateNodesMiddleVRToUnity(false); MVRTools.UpdateCameraProperties(); if (m_displayLog) { string txt = m_Kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = m_DeviceMgr.GetKeyboard(); if (keyb != null) { if (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT)) { if (keyb.IsKeyToggled(MiddleVR.VRK_D)) { ShowFPS = !ShowFPS; } if (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } // Toggle Fly mode on interactions if (keyb.IsKeyToggled(MiddleVR.VRK_F)) { Fly = !Fly; } // Navigation mode switch if (keyb.IsKeyToggled(MiddleVR.VRK_N)) { vrInteraction navigation = _GetNextInteraction("ContinuousNavigation"); if (navigation != null) { MiddleVR.VRInteractionMgr.Activate(navigation); } } } } DeltaTime = m_Kernel.GetDeltaTime(); MVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentioning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } // If QualityLevel changed, we have to reset the Unity Manager if (m_NeedDelayedRenderingReset) { if (m_RenderingResetDelay == 0) { MVRTools.Log(3, "[ ] Graphic quality forced, reset Unity Manager."); MVRTools.VRReset(); MVRTools.CreateViewportsAndCameras(DontChangeWindowGeometry, m_AllowRenderTargetAA); m_isGeometrySet = false; m_NeedDelayedRenderingReset = false; } else { --m_RenderingResetDelay; } } }
private void Grab( GameObject iGrabbedObject ) { if( iGrabbedObject == null ) { return; } m_CurrentManipulatedObject = iGrabbedObject; VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent<VRActor>(); m_ObjectPreviousSyncDir = vrActorScript.SyncDirection; vrActorScript.SyncDirection = MVRNodesMapper.ENodesSyncDirection.MiddleVRToUnity; vrNode3D middleVRNode = vrActorScript.GetMiddleVRNode(); m_it.SetManipulatedNode(middleVRNode); m_it.SetPivotPositionVirtualWorld(MVRTools.FromUnity(m_CurrentManipulatedObject.GetComponent<Collider>().bounds.center)); // Save initial position m_ManipulatedObjectInitialLocalPosition = m_CurrentManipulatedObject.transform.localPosition; m_ManipulatedObjectInitialLocalRotation = m_CurrentManipulatedObject.transform.localRotation; // Pause rigidbody acceleration Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent<Rigidbody>(); if (manipulatedRigidbody != null) { m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic; manipulatedRigidbody.isKinematic = true; } // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } // Hide Wand m_VRMgr.ShowWandGeometry(false); }
private void Ungrab() { if (m_CurrentManipulatedObject == null) { return; } if (OnGrab != null) { OnGrab(this, e_GrabStatus.UNGRABBED); } // Give to return objects script VRInteractionManipulationReturnObjects returningObjectScript = this.GetComponent<VRInteractionManipulationReturnObjects>(); if (returningObjectScript != null) { if (returningObjectScript.enabled) { returningObjectScript.AddReturningObject(m_CurrentManipulatedObject, m_ManipulatedObjectInitialLocalPosition, m_ManipulatedObjectInitialLocalRotation, false); } } // Reset m_it.SetManipulatedNode(null); VRActor vrActorScript = m_CurrentManipulatedObject.GetComponent<VRActor>(); vrActorScript.SyncDirection = m_ObjectPreviousSyncDir; // Unpause rigidbody acceleration Rigidbody manipulatedRigidbody = m_CurrentManipulatedObject.GetComponent<Rigidbody>(); if (manipulatedRigidbody != null) { manipulatedRigidbody.isKinematic = m_ManipulatedObjectInitialIsKinematic; } // Reactivate selection after the manipulation if (m_PausedSelection != null) { MiddleVR.VRInteractionMgr.Activate(m_PausedSelection); m_PausedSelection = null; } m_CurrentManipulatedObject = null; }
private void ContinueGrab(GameObject iGrabbedObject) { // Initialize manipulated node m_CurrentManipulatedObject = iGrabbedObject; m_it.SetManipulatedNode(AcquireGameObjectNode(m_CurrentManipulatedObject, "VRInteractionManipulationRayNode")); // Pause rigidbody acceleration Rigidbody manipulatedRigidbody = iGrabbedObject.GetComponent<Rigidbody>(); if (manipulatedRigidbody != null) { m_ManipulatedObjectInitialIsKinematic = manipulatedRigidbody.isKinematic; manipulatedRigidbody.isKinematic = true; } // Deactivate selection during the manipulation vrInteraction selection = MiddleVR.VRInteractionMgr.GetActiveInteractionByTag("ContinuousSelection"); if (selection != null) { m_PausedSelection = selection; MiddleVR.VRInteractionMgr.Deactivate(m_PausedSelection); } }
private void Ungrab() { if (m_CurrentManipulatedObject == null) { return; } // Give to return objects script VRInteractionManipulationReturnObjects returningObjectScript = this.GetComponent<VRInteractionManipulationReturnObjects>(); if (returningObjectScript != null) { if (returningObjectScript.enabled) { returningObjectScript.AddReturningObject(m_CurrentManipulatedObject, m_ManipulatedObjectInitialLocalPosition, m_ManipulatedObjectInitialLocalRotation, false); } } // Reset m_it.SetManipulatedNode(null); ReleaseGameObjectNode(m_CurrentManipulatedObject); // Unpause rigidbody acceleration Rigidbody manipulatedRigidbody = m_CurrentManipulatedObject.GetComponent<Rigidbody>(); if (manipulatedRigidbody != null) { manipulatedRigidbody.isKinematic = m_ManipulatedObjectInitialIsKinematic; } // Reactivate selection after the manipulation if (m_PausedSelection != null) { MiddleVR.VRInteractionMgr.Activate(m_PausedSelection); m_PausedSelection = null; } m_CurrentManipulatedObject = null; }
public void SetInteraction(vrInteraction iInteraction) { m_Interaction = iInteraction; }