void Update() { float translation = Input.GetAxis("Vertical") * speed; float rotation = Input.GetAxis("Horizontal") * rotationSpeed; if (CAVE) { vrTracker wand = null; vrAxis axis = null; if (MiddleVR.VRDeviceMgr != null) { wand = MiddleVR.VRDeviceMgr.GetTracker("VRPNTracker0.Tracker1"); axis = MiddleVR.VRDeviceMgr.GetAxis("VRPNAxis0.Axis"); if (axis != null) // && axis.GetValue(0) != 0 ) { rotation = axis.GetValue(0) * rotationSpeed; } if (axis != null) // && axis.GetValue(1) != 0 ) { translation = axis.GetValue(1) * speed; } } } translation *= Time.deltaTime; rotation *= Time.deltaTime; transform.Translate(0, 0, translation); transform.Rotate(0, rotation, 0); print("Time.deltaTime = " + Time.deltaTime); print("translation = " + translation); print("rotation = " + rotation); }
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_FloatAxis == null && MiddleVR.VRDeviceMgr != null ) { m_FloatAxis = MiddleVR.VRDeviceMgr.CreateAxis(ShareName); m_FloatAxis.SetAxisNb(1); MiddleVRTools.Log("[+] Created shared float axis " + ShareName ); MiddleVR.VRClusterMgr.AddSynchronizedObject(m_FloatAxis, 0); } else if( MiddleVR.VRClusterMgr.IsServer() && m_FloatAxis != null ) { // m_FloatAxis.SetValue(0, Float to watch ); } }
// Update is called once per frame public void Update() { if (m_FloatAxis == null && MiddleVR.VRDeviceMgr != null) { m_FloatAxis = MiddleVR.VRDeviceMgr.CreateAxis(ShareName); m_FloatAxis.SetAxisNb(1); MiddleVRTools.Log("[+] Created shared float axis " + ShareName); MiddleVR.VRClusterMgr.AddSynchronizedObject(m_FloatAxis, 0); } else if (MiddleVR.VRClusterMgr.IsServer() && m_FloatAxis != null) { // m_FloatAxis.SetValue(0, Float to watch ); } }
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_ShareFloatScript != null ) { if (m_FloatAxis == null && MiddleVR.VRDeviceMgr != null) { m_FloatAxis = MiddleVR.VRDeviceMgr.GetAxis(m_ShareFloatScript.ShareName); MiddleVRTools.Log("[+] Acquired shared float axis " + m_FloatAxis.GetName()); } else if( m_FloatAxis != null ) { // Float to watch = m_FloatAxis.GetValue(0); } } }
// Update is called once per frame public void Update() { if (m_ShareFloatScript != null) { if (m_FloatAxis == null && MiddleVR.VRDeviceMgr != null) { m_FloatAxis = MiddleVR.VRDeviceMgr.GetAxis(m_ShareFloatScript.ShareName); MiddleVRTools.Log("[+] Acquired shared float axis " + m_FloatAxis.GetName()); } else if (m_FloatAxis != null) { // Float to watch = m_FloatAxis.GetValue(0); } } }
// Update is called once per frame void Update() { // Get the input vector from keyboard or analog stick Vector3 directionVector; directionVector = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")); //print (directionVector); if (CAVE) { print("CAAAAVVVVVEEEEEE"); vrTracker wand = null; vrAxis axis = null; if (MiddleVR.VRDeviceMgr != null) { wand = MiddleVR.VRDeviceMgr.GetTracker("VRPNTracker0.Tracker1"); axis = MiddleVR.VRDeviceMgr.GetAxis("VRPNAxis0.Axis"); } print("Wand_[x,y,z]: " + wand.GetPosition().x() + "," + wand.GetPosition().y() + "," + wand.GetPosition().z()); print("Axis Value: " + axis.GetValue(0) + ", " + axis.GetValue(1)); directionVector = new Vector3(0, 0, axis.GetValue(1)); print("directionVector = " + directionVector); } if (directionVector != Vector3.zero) { // Get the length of the directon vector and then normalize it // Dividing by the length is cheaper than normalizing when we already have the length anyway float directionLength = directionVector.magnitude; directionVector = directionVector / directionLength; // Make sure the length is no bigger than 1 directionLength = Mathf.Min(1, directionLength); // Make the input vector more sensitive towards the extremes and less sensitive in the middle // This makes it easier to control slow speeds when using analog sticks directionLength = directionLength * directionLength; // Multiply the normalized direction vector by the modified length directionVector = directionVector * directionLength; } // Apply the direction to the CharacterMotor cmotor.inputMoveDirection = transform.rotation * directionVector; cmotor.inputJump = Input.GetButton("Jump"); }
// Start void Start() { // Retrieve trackers by name m_Tracker = MiddleVR.VRDeviceMgr.GetTracker(m_VirtualTrackerName); m_Wiimote = MiddleVR.VRDeviceMgr.GetAxis("VRPNAxis0.Axis"); if (m_Tracker == null) { MiddleVRTools.Log("[X] VirtualTrackerMapping: Error : Can't find tracker '" + m_VirtualTrackerName + "'."); } if (m_Wiimote == null) { MiddleVRTools.Log("[X] Wiimote not found."); } if (m_Tracker != null && m_Wiimote != null) { m_Init = true; } }
protected void Start() { // Retrieve trackers by name m_Tracker = MiddleVR.VRDeviceMgr.GetTracker(m_VirtualTrackerName); m_Wiimote = MiddleVR.VRDeviceMgr.GetAxis("VRPNAxis0.Axis"); if( m_Tracker == null ) { MVRTools.Log("[X] VirtualTrackerMapping: Error : Can't find tracker '" + m_VirtualTrackerName + "'."); } if( m_Wiimote == null ) { MVRTools.Log ("[X] Wiimote not found."); } if (m_Tracker != null && m_Wiimote != null ) { m_IsInit = true; } }
public DebugVrDevices() { _spaceNavAxis = null; }