public static bool GetButtonUp(uint buttonIndex) { vrButtons wandButtons = MiddleVR.VRDeviceMgr.GetWandButtons(); uint buttonNb = wandButtons.GetButtonsNb(); if (buttonIndex > buttonNb) { return(false); } switch (buttonIndex) { case 0: return(wandButtons._IsToggledReleased(MiddleVR.VRDeviceMgr.GetWandButton0())); case 1: return(wandButtons._IsToggledReleased(MiddleVR.VRDeviceMgr.GetWandButton1())); case 2: return(wandButtons._IsToggledReleased(MiddleVR.VRDeviceMgr.GetWandButton2())); case 3: return(wandButtons._IsToggledReleased(MiddleVR.VRDeviceMgr.GetWandButton3())); case 4: return(wandButtons._IsToggledReleased(MiddleVR.VRDeviceMgr.GetWandButton4())); case 5: return(wandButtons._IsToggledReleased(MiddleVR.VRDeviceMgr.GetWandButton5())); } return(false); }
// Use this for initialization public void Start() { // Wand retrieval m_WandButtons = vrDeviceManager.GetInstance().GetWandButtons(); // Retrieve renderer components ml_GraphicComponents = GetComponentsInChildren<Renderer>() as Renderer[]; ml_ActionSounds = new Dictionary<string, AudioClip>(); ml_ActionSounds["Shot1"] = Resources.Load("Audio/bullet1") as AudioClip; ml_ActionSounds["Shot2"] = Resources.Load("Audio/bullet11") as AudioClip; ml_ActionSounds["Shot3"] = Resources.Load("Audio/bullet3") as AudioClip; ml_ActionSounds["Shot4"] = Resources.Load("Audio/bullet7") as AudioClip; ml_ActionSounds["Shot5"] = Resources.Load("Audio/bullet2") as AudioClip; ml_ActionSounds["Shot6"] = Resources.Load("Audio/bullet9") as AudioClip; m_MusicToy = Resources.Load ("Audio/ggjpuppetwar") as AudioClip; m_PlayerAudio = gameObject.GetComponent<AudioSource>(); if(!m_PlayerAudio) { gameObject.AddComponent<AudioSource>(); m_PlayerAudio = gameObject.GetComponent<AudioSource>(); } m_PlayerAudio.clip = m_MusicToy; m_PlayerAudio.loop = true; m_PlayerAudio.volume = 0.5f; m_PlayerAudio.Stop (); }
// Update is called once per frame void Update() { //for desktop use /*if(Input.GetKeyDown(KeyCode.Z)){ * StartCoroutine(Spark ()); * StartCoroutine(light ()); * }*/ vrButtons buttons = null; // Getting a reference to different device types if (MiddleVR.VRDeviceMgr != null) { buttons = MiddleVR.VRDeviceMgr.GetButtons("VRPNButtons0.Buttons"); } if (buttons != null) { if (buttons.IsToggled(2)) { //if(Input.GetKeyDown(KeyCode.Z)){ StartCoroutine(Spark()); StartCoroutine(lightFlame()); //} } } }
// Update is called once per frame public void Update () { if( m_EventButton == null && MiddleVR.VRDeviceMgr != null ) { m_EventButton = MiddleVR.VRDeviceMgr.CreateButtons(ShareName); m_EventButton.SetButtonsNb(1); MiddleVRTools.Log("[+] Created shared event button " + ShareName ); MiddleVR.VRClusterMgr.AddSynchronizedObject(m_EventButton, 0); } }
// Update is called once per frame public void Update() { if (m_EventButton == null && MiddleVR.VRDeviceMgr != null) { m_EventButton = MiddleVR.VRDeviceMgr.CreateButtons(ShareName); m_EventButton.SetButtonsNb(1); MiddleVRTools.Log("[+] Created shared event button " + ShareName); MiddleVR.VRClusterMgr.AddSynchronizedObject(m_EventButton, 0); } }
void Start() { print ("Start"); if (MiddleVR.VRDeviceMgr == null) return; _keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); _spaceNavAxis = MiddleVR.VRDeviceMgr.GetAxis("SpaceNavAxes.Axis"); _spaceNavButtons = MiddleVR.VRDeviceMgr.GetButtons("SpaceNavButtons.Buttons"); _flystickAxis = MiddleVR.VRDeviceMgr.GetAxis("FlystickAxes.Axis"); _flystickButtons = MiddleVR.VRDeviceMgr.GetButtons("FlystickButtons.Buttons"); print("SpaceNavAxes: "+ _spaceNavAxis); }
// Use this for initialization void Start() { scatterplotTogglePrefab = Resources.Load("Prefabs/checkbox") as GameObject; renderer = gameObject.GetComponent <Canvas>(); collider = gameObject.GetComponent <BoxCollider>(); panel = GameObject.Find("Panel"); inputFiles = GameObject.Find("dropdown_input_files").GetComponent <Dropdown>(); inputFiles.onValueChanged.AddListener(InputFileSelectionChanged); //dataFiles = Resources.LoadAll<TextAsset>(csvDirectoryName); FileInfo[] fileInfos = new DirectoryInfo(Application.streamingAssetsPath).GetFiles("*.csv"); dataFiles = new TextAsset[fileInfos.Length]; int textAssetIndex = 0; foreach (FileInfo fileInfo in fileInfos) { inputFiles.options.Add(new Dropdown.OptionData() { text = fileInfo.Name }); dataFiles[textAssetIndex] = new TextAsset(File.ReadAllText(fileInfo.FullName)); dataFiles[textAssetIndex++].name = fileInfo.Name; } inputFiles.RefreshShownValue(); toggleList = GameObject.Find("toggle_list"); scrollbar = GameObject.Find("scrollbar").GetComponent <Scrollbar>(); selectAll = GameObject.Find("button_select_all").GetComponent <Button>(); selectAll.onClick.AddListener(OnSelectAll); deselectAll = GameObject.Find("button_deselect_all").GetComponent <Button>(); deselectAll.onClick.AddListener(OnDeselectAll); buttonImport = GameObject.Find("button_import").GetComponent <Button>(); buttonImport.onClick.AddListener(OnButtonImportClicked); decrement = GameObject.Find("button_decrement").GetComponent <Button>(); decrement.onClick.AddListener(OnButtonDecrement); pointSize = GameObject.Find("label_point_size_value").GetComponent <Text>(); pointSize.text = visualizer.pointSize.ToString(); increment = GameObject.Find("button_increment").GetComponent <Button>(); increment.onClick.AddListener(OnButtonIncrement); headNode = GameObject.Find("HeadNode"); wandButtons = MiddleVR.VRDeviceMgr.GetJoystickByIndex(0).GetButtonsDevice(); SetVisible(false); // Call manually to trigger the loading of the CSV file InputFileSelectionChanged(0); }
private void TestDevices() { vrTracker tracker = null; vrJoystick joy = null; vrAxis axis = null; vrButtons buttons = null; var deviceMgr = MiddleVR.VRDeviceMgr; // Getting a reference to different device types if (deviceMgr != null) { tracker = deviceMgr.GetTracker("VRPNTracker0.Tracker0"); joy = deviceMgr.GetJoystickByIndex(0); axis = deviceMgr.GetAxis("VRPNAxis0.Axis"); buttons = deviceMgr.GetButtons("VRPNButtons0.Buttons"); } // Getting tracker data if (tracker != null) { MVRTools.Log("TrackerX : " + tracker.GetPosition().x()); } // Testing joystick button if (joy != null && joy.IsButtonPressed(0)) { MVRTools.Log("Joystick!"); } // Testing axis value if (axis != null && axis.GetValue(0) > 0) { MVRTools.Log("Axis Value: " + axis.GetValue(0)); } // Testing button state if (buttons != null) { if (buttons.IsToggled(0)) { MVRTools.Log("Button 0 pressed !"); } if (buttons.IsToggled(0, false)) { MVRTools.Log("Button 0 released !"); } } }
void Start() { print("Start"); if (MiddleVR.VRDeviceMgr == null) { return; } _keyboard = MiddleVR.VRDeviceMgr.GetKeyboard(); _spaceNavAxis = MiddleVR.VRDeviceMgr.GetAxis("SpaceNavAxes.Axis"); _spaceNavButtons = MiddleVR.VRDeviceMgr.GetButtons("SpaceNavButtons.Buttons"); _flystickAxis = MiddleVR.VRDeviceMgr.GetAxis("FlystickAxes.Axis"); _flystickButtons = MiddleVR.VRDeviceMgr.GetButtons("FlystickButtons.Buttons"); print("SpaceNavAxes: " + _spaceNavAxis); }
// Update is called once per frame public void Update() { if (m_BoolButton == null && MiddleVR.VRDeviceMgr != null) { m_BoolButton = MiddleVR.VRDeviceMgr.CreateButtons(ShareName); m_BoolButton.SetButtonsNb(1); MiddleVRTools.Log("[+] Created shared bool button " + ShareName); MiddleVR.VRClusterMgr.AddSynchronizedObject(m_BoolButton, 0); } else if (MiddleVR.VRClusterMgr.IsServer() && m_BoolButton != null) { // m_BoolButton.SetPressedState(0, Boolean to watch ); } }
// Update is called once per frame public void Update () { if( m_BoolButton == null && MiddleVR.VRDeviceMgr != null ) { m_BoolButton = MiddleVR.VRDeviceMgr.CreateButtons(ShareName); m_BoolButton.SetButtonsNb(1); MiddleVRTools.Log("[+] Created shared bool button " + ShareName ); MiddleVR.VRClusterMgr.AddSynchronizedObject(m_BoolButton, 0); } else if( MiddleVR.VRClusterMgr.IsServer() && m_BoolButton != null ) { // m_BoolButton.SetPressedState(0, Boolean to watch ); } }
// Update is called once per frame public void Update() { if (m_ShareBoolScript != null) { if (m_BoolButton == null && MiddleVR.VRDeviceMgr != null) { m_BoolButton = MiddleVR.VRDeviceMgr.GetButtons(m_ShareBoolScript.ShareName); MiddleVRTools.Log("[+] Acquired shared bool button " + m_BoolButton.GetName()); } else if (m_BoolButton != null) { // Boolean to watch = m_BoolButton.IsPressed(0); } } }
// Update is called once per frame public void Update() { if ( m_ShareBoolScript != null ) { if (m_BoolButton == null && MiddleVR.VRDeviceMgr != null) { m_BoolButton = MiddleVR.VRDeviceMgr.GetButtons(m_ShareBoolScript.ShareName); MiddleVRTools.Log("[+] Acquired shared bool button " + m_BoolButton.GetName()); } else if( m_BoolButton != null ) { // Boolean to watch = m_BoolButton.IsPressed(0); } } }
void MiddleVR_Buttons() { vrButtons buttons = null; if (MiddleVR.VRDeviceMgr != null) { buttons = MiddleVR.VRDeviceMgr.GetButtons("VRPNButtons1.Buttons"); } if (buttons != null) { if (buttons.IsToggled(0) | Input.GetKeyDown(KeyCode.F1)) { MiddleVRTools.Log("Button 0 has been pressed"); hand_node.GetComponent <Renderer>().material.color = Color.blue; } } }
protected void Update() { int haptionDeviceId = 0; string haptionDeviceNameBase = "Haption" + haptionDeviceId; vrButtons buttons = MiddleVR.VRDeviceMgr.GetButtons(haptionDeviceNameBase + ".Buttons"); for (uint i = 0, iEnd = buttons.GetButtonsNb(); i < iEnd; ++i) { if (buttons.IsToggled(i, true)) { MiddleVRTools.Log(1, "[+] Haption button '" + i + "' is pressed."); } else if (buttons.IsToggled(i, false)) { MiddleVRTools.Log(1, "[+] Haption button '" + i + "' is released."); } } }
// Update is called once per frame public void Update() { if (m_ShareEventScript != null) { if (m_EventButton == null && MiddleVR.VRDeviceMgr != null) { m_EventButton = MiddleVR.VRDeviceMgr.GetButtons(m_ShareEventScript.ShareName); MiddleVRTools.Log("[+] Acquired shared event button " + m_EventButton.GetName()); } else if (m_EventButton != null) { if (m_EventButton.IsPressed(0)) { // Every node receive the event VRCallbackName // this.SendMessage("FinalFunction"); m_EventButton.SetPressedState(0, false); } } } }
// Update is called once per frame public void Update() { if ( m_ShareEventScript != null ) { if (m_EventButton == null && MiddleVR.VRDeviceMgr != null) { m_EventButton = MiddleVR.VRDeviceMgr.GetButtons(m_ShareEventScript.ShareName); MiddleVRTools.Log("[+] Acquired shared event button " + m_EventButton.GetName()); } else if( m_EventButton != null ) { if( m_EventButton.IsPressed(0) ) { // Every node receive the event VRCallbackName // this.SendMessage("FinalFunction"); m_EventButton.SetPressedState(0,false); } } } }
void UpdateInput() { vrDeviceManager dmgr = MiddleVR.VRDeviceMgr; if (dmgr != null) { vrButtons wandButtons = dmgr.GetWandButtons(); if (wandButtons != null) { uint buttonNb = wandButtons.GetButtonsNb(); if (buttonNb > 0) { WandButton0 = wandButtons.IsPressed(dmgr.GetWandButton0()); } if (buttonNb > 1) { WandButton1 = wandButtons.IsPressed(dmgr.GetWandButton1()); } if (buttonNb > 2) { WandButton2 = wandButtons.IsPressed(dmgr.GetWandButton2()); } if (buttonNb > 3) { WandButton3 = wandButtons.IsPressed(dmgr.GetWandButton3()); } if (buttonNb > 4) { WandButton4 = wandButtons.IsPressed(dmgr.GetWandButton4()); } if (buttonNb > 5) { WandButton5 = wandButtons.IsPressed(dmgr.GetWandButton5()); } } WandAxisHorizontal = dmgr.GetWandHorizontalAxisValue(); WandAxisVertical = dmgr.GetWandVerticalAxisValue(); } }
// Update is called once per frame void Update() { if (!wand && !BookControl.bookInUse) { deselectBook(false); } if (MainGame.lampLit && !lit) { lit = true; light.intensity = 0.01f; light.cullingMask = 1 << 10; createBooks.SetLayerRecursively(transform.gameObject, 10); } /*if (Input.GetKeyUp (KeyCode.O)) { * StartCoroutine( takeBook() ); * } * * if (Input.GetKeyUp (KeyCode.P)) { * StartCoroutine( PlayOneShot("flipPage") ); * } * * if (Input.GetKeyUp (KeyCode.C)) { * StartCoroutine( replaceBook() ); * }*/ vrButtons buttons = null; // Getting a reference to different device types if (MiddleVR.VRDeviceMgr != null) { buttons = MiddleVR.VRDeviceMgr.GetButtons("VRPNButtons0.Buttons"); } if (buttons != null) { if (buttons.IsToggled(0) && bookInUse) { StartCoroutine("flipPage"); } } }
// Use this for initialization public void Start() { // Particle system for world motion m_moveFeedback = GetComponentInChildren<ParticleSystem>(); // Wand retrieval m_WandButtons = vrDeviceManager.GetInstance().GetWandButtons(); // Hand config m_ChildHand = GameObject.FindGameObjectWithTag("ChildHand"); Quaternion myRotation = Quaternion.Euler(0f,90f,0f); GameManager.Instance.AttachNodeToHand(m_ChildHand, Vector3.zero, myRotation); // Initialize hand by atatching to vr node // Retrieve animator m_HandAnimator = m_ChildHand.GetComponent<Animator>(); // Assign toy if (!m_ChildToy) m_ChildToy = GameObject.FindGameObjectWithTag("ChildToy"); // Handlers // Callbacks to transition childToToy += biggerWorld; toyToChild += smallerWorld; ml_Music = new Dictionary<string, AudioClip>(); ml_Music["Child"] = Resources.Load("Audio/ggjpuppetambchild") as AudioClip; m_ChildAudio = gameObject.GetComponent<AudioSource>(); if(!m_ChildAudio) { gameObject.AddComponent<AudioSource>(); m_ChildAudio = gameObject.GetComponent<AudioSource>(); } m_ChildAudio.clip = ml_Music["Child"]; m_ChildAudio.loop = true; m_ChildAudio.Play(); }
private void UpdateInput() { vrButtons wandButtons = m_DeviceMgr.GetWandButtons(); if (wandButtons != null) { uint buttonNb = wandButtons.GetButtonsNb(); if (buttonNb > 0) { WandButton0 = wandButtons.IsPressed(m_DeviceMgr.GetWandButton0()); } if (buttonNb > 1) { WandButton1 = wandButtons.IsPressed(m_DeviceMgr.GetWandButton1()); } if (buttonNb > 2) { WandButton2 = wandButtons.IsPressed(m_DeviceMgr.GetWandButton2()); } if (buttonNb > 3) { WandButton3 = wandButtons.IsPressed(m_DeviceMgr.GetWandButton3()); } if (buttonNb > 4) { WandButton4 = wandButtons.IsPressed(m_DeviceMgr.GetWandButton4()); } if (buttonNb > 5) { WandButton5 = wandButtons.IsPressed(m_DeviceMgr.GetWandButton5()); } } WandAxisHorizontal = m_DeviceMgr.GetWandHorizontalAxisValue(); WandAxisVertical = m_DeviceMgr.GetWandVerticalAxisValue(); }
// Update is called once per frame void Update () { if (m_Buttons == null) { m_Buttons = MiddleVR.VRDeviceMgr.GetWandButtons(); } if( m_Buttons == null ) { if (m_SearchedButtons == false) { //MiddleVRTools.Log("[~] VRWandInteraction: Wand buttons undefined. Please specify Wand Buttons in the configuration tool."); m_SearchedButtons = true; } } Collider hit = GetClosestHit(); if( hit != null ) { //print("Closest : " + hit.name); if( CurrentObject != hit.gameObject && ObjectInHand == null ) { //MiddleVRTools.Log("Enter other : " + hit.name); HighlightObject( CurrentObject, false ); CurrentObject = hit.gameObject; HighlightObject(CurrentObject, true ); //MiddleVRTools.Log("Current : " + CurrentObject.name); } } // Else else { //MiddleVRTools.Log("No touch ! "); if (CurrentObject != null && CurrentObject != ObjectInHand) { HighlightObject(CurrentObject, false, HighlightColor ); CurrentObject = null; } } //MiddleVRTools.Log("Current : " + CurrentObject); if (m_Buttons != null && CurrentObject != null ) { uint MainButton = MiddleVR.VRDeviceMgr.GetWandButton0(); VRActor script = CurrentObject.GetComponent<VRActor>(); //MiddleVRTools.Log("Trying to take :" + CurrentObject.name); if (script != null) { // Grab if (m_Buttons.IsToggled(MainButton)) { if (script.Grabable) { Grab(CurrentObject); } } // Release if (m_Buttons.IsToggled(MainButton, false) && ObjectInHand != null) { Ungrab(); } // Action if (((!RepeatAction && m_Buttons.IsToggled(MainButton)) || (RepeatAction&& m_Buttons.IsPressed(MainButton)))) { CurrentObject.SendMessage("VRAction", SendMessageOptions.DontRequireReceiver); } } } }
// Update is called once per frame void Update() { if (m_Buttons == null) { m_Buttons = MiddleVR.VRDeviceMgr.GetWandButtons(); } if (m_Buttons == null) { if (m_SearchedButtons == false) { //MiddleVRTools.Log("[~] VRWandInteraction: Wand buttons undefined. Please specify Wand Buttons in the configuration tool."); m_SearchedButtons = true; } } Collider hit = GetClosestHit(); if (hit != null) { //print("Closest : " + hit.name); if (m_CurrentObject != hit.gameObject && m_ObjectInHand == null) { //MiddleVRTools.Log("Enter other : " + hit.name); HighlightObject(m_CurrentObject, false); m_CurrentObject = hit.gameObject; HighlightObject(m_CurrentObject, true); if (book != null && !book.name.Equals(m_CurrentObject.name)) { if (book.GetComponent <BookControl>() != null) { book.GetComponent <BookControl>().wand = false; } } //MiddleVRTools.Log("Current : " + m_CurrentObject.name); } } // Else else { //MiddleVRTools.Log("No touch ! "); if (m_CurrentObject != null && m_CurrentObject != m_ObjectInHand) { HighlightObject(m_CurrentObject, false, HighlightColor); m_CurrentObject = null; } } //MiddleVRTools.Log("Current : " + m_CurrentObject); if (m_Buttons != null && m_CurrentObject != null) { uint MainButton = MiddleVR.VRDeviceMgr.GetWandButton0(); VRActor script = m_CurrentObject.GetComponent <VRActor>(); if (book != null && !book.name.Equals(m_CurrentObject.name)) { if (book.GetComponent <BookControl>() != null) { book.GetComponent <BookControl>().wand = false; } } //MiddleVRTools.Log("Trying to take :" + m_CurrentObject.name); if (script != null) { if (m_CurrentObject.GetComponent <BookControl>() != null) { book = m_CurrentObject; book.GetComponent <BookControl>().selectBook(); } // Grab if (m_Buttons.IsToggled(MainButton)) { if (script.Grabable) { Grab(m_CurrentObject); } } // Release if (m_Buttons.IsToggled(MainButton, false) && m_ObjectInHand != null) { Ungrab(); } // Action if (((!RepeatAction && m_Buttons.IsToggled(MainButton)) || (RepeatAction && m_Buttons.IsPressed(MainButton)))) { m_CurrentObject.SendMessage("VRAction", SendMessageOptions.DontRequireReceiver); } } else { if (book != null && book.GetComponent <BookControl>() != null) { book.GetComponent <BookControl>().wand = false; } } } }
// Update is called once per frame void Update() { if (handNode2 == null) { handNode2 = GameObject.Find("RightHand"); } if (headNode == null) { headNode = GameObject.Find("LeftHand"); } if (handNode2 == null || headNode == null) { return; } handDir = handNode2.transform.forward; handDir.y = 0; handDir = handDir.normalized; handDirLat = new Vector3(handDir.z, 0, -handDir.x); if (MiddleVR.VRDeviceMgr != null) { if (MiddleVR.VRDeviceMgr.GetJoysticksNb() > 0) { vrJoystick joy = MiddleVR.VRDeviceMgr.GetJoystickByIndex(0); vrButtons but = joy.GetButtonsDevice(); if (joy != null) { float x = joy.GetAxisValue(0); float y = joy.GetAxisValue(1); float fourth = joy.GetAxisValue(3); float deltaTime = (float)MiddleVR.VRKernel.GetDeltaTime(); if (but.IsPressed(5)) { var currentXZHeadDir = headNode.transform.forward; currentXZHeadDir.y = 0; currentXZHeadDir = currentXZHeadDir.normalized; if (buttonDown) { firstXZHeadDir = currentXZHeadDir; buttonDown = false; } else { var cosAlpha = Vector3.Dot(firstXZHeadDir, currentXZHeadDir); var sinAlpha = Vector3.Cross(firstXZHeadDir, currentXZHeadDir).y; var alpha = Mathf.Atan2(sinAlpha, cosAlpha); transform.RotateAround(headNode.transform.position, new Vector3(0, 1, 0), -alpha * Mathf.Rad2Deg); } } else { buttonDown = true; } if (fourth > deadZone || fourth < -deadZone) { transform.RotateAround(headNode.transform.position, new Vector3(0, 1, 0), camSens * deltaTime * fourth); } if (x * x + y * y > deadZone * deadZone) { transform.Translate(-handDir * mainSpeed * deltaTime * y, Space.World); transform.Translate(handDirLat * mainSpeed * deltaTime * x, Space.World); } } } } }