// Update is called once per frame
	public void Update () {
        if (MiddleVR.VRClusterMgr.IsClient() && m_STScript != null )
        {
            if (m_tracker == null && MiddleVR.VRDeviceMgr != null)
            {
                m_tracker = MiddleVR.VRDeviceMgr.GetTracker(m_STScript.ShareName);
                MiddleVRTools.Log("[+] Acquired shared tracker " + m_tracker.GetName());
            }

            if( m_tracker != null)
            {
                // Get rid of anything that could move the object
                //Destroy(rigidbody);

                vrVec3 pos = m_tracker.GetPosition();
                vrQuat or = m_tracker.GetOrientation();

                Vector3 p = new Vector3(pos.x(), pos.y(), pos.z());
                Quaternion q = new Quaternion((float)or.x(), (float)or.y(), (float)or.z(), (float)or.w());

                transform.position = p;
                transform.rotation = q;

                //MiddleVRTools.Log("Client applying data : " + p.z );
            }
        }
	}
    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);
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        vrTracker  tracker = null;
        vrKeyboard keyb    = null;

        if (MiddleVR.VRDeviceMgr != null)
        {
            tracker = MiddleVR.VRDeviceMgr.GetTracker(Tracker);
            keyb    = MiddleVR.VRDeviceMgr.GetKeyboard();
        }

        if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_SPACE))
        {
            if (tracker != null)
            {
                float yaw = tracker.GetYaw();

                vrQuat neutralOr = new vrQuat(0, 0, 0, 1);
                neutralOr.SetEuler(-yaw, 0, 0);
                vrQuat nq = neutralOr.GetInverse();

                tracker.SetNeutralOrientation(nq);
            }
        }
    }
    protected void Update()
    {
        vrTracker  tracker  = null;
        vrKeyboard keyboard = null;

        var deviceMgr = MiddleVR.VRDeviceMgr;

        if (deviceMgr != null)
        {
            tracker  = deviceMgr.GetTracker(Tracker);
            keyboard = deviceMgr.GetKeyboard();
        }

        if (keyboard != null && keyboard.IsKeyToggled(MiddleVR.VRK_SPACE))
        {
            if (tracker != null)
            {
                float yaw = tracker.GetYaw();

                vrQuat neutralQ = new vrQuat();
                neutralQ.SetEuler(-yaw, 0.0f, 0.0f);
                vrQuat invNeutralQ = neutralQ.GetInverse();

                tracker.SetNeutralOrientation(invNeutralQ);
            }
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    public void Update()
    {
        if (MiddleVR.VRClusterMgr.IsClient() && m_STScript != null)
        {
            if (m_tracker == null && MiddleVR.VRDeviceMgr != null)
            {
                m_tracker = MiddleVR.VRDeviceMgr.GetTracker(m_STScript.ShareName);
                MiddleVRTools.Log("[+] Acquired shared tracker " + m_tracker.GetName());
            }

            if (m_tracker != null)
            {
                // Get rid of anything that could move the object
                //Destroy(rigidbody);

                vrVec3 pos = m_tracker.GetPosition();
                vrQuat or  = m_tracker.GetOrientation();

                Vector3    p = new Vector3(pos.x(), pos.y(), pos.z());
                Quaternion q = new Quaternion((float)or.x(), (float)or.y(), (float)or.z(), (float)or.w());

                transform.position = p;
                transform.rotation = q;

                //MiddleVRTools.Log("Client applying data : " + p.z );
            }
        }
    }
Esempio n. 6
0
 void Start()
 {
     // Grab all controlers...
     leftJoystick  = MiddleVR.VRDeviceMgr.GetJoystickByIndex(0);
     rightJoystick = MiddleVR.VRDeviceMgr.GetJoystickByIndex(1);
     leftTracker   = MiddleVR.VRDeviceMgr.GetTracker(0);
     rightTracker  = MiddleVR.VRDeviceMgr.GetTracker(1);
     leftTrigger   = leftJoystick.IsButtonPressed(0);
     rightTrigger  = rightJoystick.IsButtonPressed(0);
 }
Esempio n. 7
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 !");
            }
        }
    }
Esempio n. 8
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");
    }
    // Update is called once per frame
    void Update()
    {
        vrTracker  tracker = null;
        vrKeyboard keyb    = null;

        if (MiddleVR.VRDeviceMgr != null)
        {
            tracker = MiddleVR.VRDeviceMgr.GetTracker(Tracker);
            keyb    = MiddleVR.VRDeviceMgr.GetKeyboard();
        }

        if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_SPACE))
        {
            if (tracker != null)
            {
                tracker.SetNeutralOrientation(tracker.GetOrientation());
            }
        }
    }
Esempio n. 10
0
    void Start()
    {
        // Retrieve trackers by name
        m_SourceTracker             = MiddleVR.VRDeviceMgr.GetTracker(m_SourceTrackerName);
        m_DestinationVirtualTracker = MiddleVR.VRDeviceMgr.GetTracker(m_DestinationVirtualTrackerName);

        if (m_SourceTracker == null)
        {
            MVRTools.Log("[X] VirtualTrackerMapping: Error : Can't find tracker '" + m_SourceTrackerName + "'.");
        }
        if (m_DestinationVirtualTracker == null)
        {
            MVRTools.Log("[X] VirtualTrackerMapping: Error : Can't find tracker '" + m_DestinationVirtualTrackerName + "'.");
        }

        if (m_SourceTracker != null && m_DestinationVirtualTracker != null)
        {
            m_Init = true;
        }
    }
	// Start
	void Start () 
	{
		// Retrieve trackers by name
		m_SourceTracker             = MiddleVR.VRDeviceMgr.GetTracker(m_SourceTrackerName);
		m_DestinationVirtualTracker = MiddleVR.VRDeviceMgr.GetTracker(m_DestinationVirtualTrackerName);
		
		if( m_SourceTracker == null )
        {
            MiddleVRTools.Log("[X] VirtualTrackerMapping: Error : Can't find tracker '" + m_SourceTrackerName + "'.");
        }
        if( m_DestinationVirtualTracker == null )
		{
			MiddleVRTools.Log("[X] VirtualTrackerMapping: Error : Can't find tracker '" + m_DestinationVirtualTrackerName + "'.");
		}

        if (m_SourceTracker != null && m_DestinationVirtualTracker != null)
        {
            m_Init = true;
        }
	}
Esempio n. 12
0
    // 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;
        }
    }
	// Update is called once per frame
	public void Update () {
        if( m_tracker == null && MiddleVR.VRDeviceMgr != null )
        {
            ShareName = "S_" + m_ShareID.ToString();
            m_tracker = MiddleVR.VRDeviceMgr.CreateTracker(ShareName);
            MiddleVRTools.Log("[+] Created shared tracker " + ShareName );
            MiddleVR.VRClusterMgr.AddSynchronizedObject(m_tracker, 1);
        }

        if( MiddleVR.VRClusterMgr.IsServer() && m_tracker != null )
        {
            Vector3 p = transform.position;
            Quaternion q = transform.rotation;

            vrVec3 pos = new vrVec3(p.x, p.y, p.z);
            vrQuat or = new vrQuat(q.x, q.y, q.z, q.w);

            m_tracker.SetPosition(pos);
            m_tracker.SetOrientation(or);

            //MiddleVRTools.Log("Server pushing data : " + p.z );
        }
	}
Esempio n. 15
0
    // Update is called once per frame
    public void Update()
    {
        if (m_tracker == null && MiddleVR.VRDeviceMgr != null)
        {
            ShareName = "S_" + m_ShareID.ToString();
            m_tracker = MiddleVR.VRDeviceMgr.CreateTracker(ShareName);
            MiddleVRTools.Log("[+] Created shared tracker " + ShareName);
            MiddleVR.VRClusterMgr.AddSynchronizedObject(m_tracker, 1);
        }

        if (MiddleVR.VRClusterMgr.IsServer() && m_tracker != null)
        {
            Vector3    p = transform.position;
            Quaternion q = transform.rotation;

            vrVec3 pos = new vrVec3(p.x, p.y, p.z);
            vrQuat or  = new vrQuat(q.x, q.y, q.z, q.w);

            m_tracker.SetPosition(pos);
            m_tracker.SetOrientation(or);

            //MiddleVRTools.Log("Server pushing data : " + p.z );
        }
    }