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); } } }
// 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); } } }
// 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); } } }
// 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 ); } } }
private void ConvertGeometry(Mesh mesh) { Vector3[] vertices = mesh.vertices; int[] triangles = mesh.triangles; MiddleVRTools.Log(3, "PhysicsBody: Number of vertices: " + vertices.Length); MiddleVRTools.Log(3, "PhysicsBody: Number of Triangles: " + triangles.Length); // We will reuse the same vectors to avoid many memory allocations. Vector3 vertexPos = new Vector3(); vrVec3 vPos = new vrVec3(); // We compute a matrix to scale vertices according to their world // coordinates, so this scale depends on the scales of the GameObject // parents. Matrices 4x4 are used because matrices 3x3 aren't available. vrMatrix worldMatrix = MVRTools.RawFromUnity(transform.localToWorldMatrix); worldMatrix.SetCol(3, new vrVec4(0.0f, 0.0f, 0.0f, 0.0f)); worldMatrix.SetRow(3, new vrVec4(0.0f, 0.0f, 0.0f, 0.0f)); vrQuat invRotWorlQ = worldMatrix.GetRotation(); invRotWorlQ = invRotWorlQ.Normalize().GetInverse(); vrMatrix invRotWorldMatrix = new vrMatrix(); invRotWorldMatrix.SetRotation(invRotWorlQ); invRotWorldMatrix.SetCol(3, new vrVec4(0.0f, 0.0f, 0.0f, 0.0f)); invRotWorldMatrix.SetRow(3, new vrVec4(0.0f, 0.0f, 0.0f, 0.0f)); vrMatrix scaleWorldMatrix = invRotWorldMatrix.Mult(worldMatrix); Matrix4x4 scaleWorldMatrixUnity = MiddleVRTools.RawToUnity(scaleWorldMatrix); foreach (Vector3 vertex in vertices) { vertexPos = scaleWorldMatrixUnity.MultiplyPoint3x4(vertex); MiddleVRTools.FromUnity(vertexPos, ref vPos); m_Geometry.AddVertex(vPos); MiddleVRTools.Log(6, "PhysicsBody: Adding a vertex at position (" + vPos.x() + ", " + vPos.y() + ", " + vPos.z() + ")."); } for (int i = 0, iEnd = triangles.Length; i < iEnd; i += 3) { uint index0 = (uint)triangles[i]; uint index1 = (uint)triangles[i + 1]; uint index2 = (uint)triangles[i + 2]; m_Geometry.AddTriangle(index0, index1, index2); MiddleVRTools.Log(6, "PhysicsBody: Adding a triangle with vertex indexes (" + index0 + ", " + index1 + ", " + index2 + ")."); } }
// On clients, handle the command call private vrValue _CommandHandler(vrValue iValue) { if (m_ClusterMgr.IsClient()) { // extract position and orientation from the vrValue vrVec3 pos = iValue[0].GetVec3(); vrQuat orient = iValue[1].GetQuat(); Vector3 p = new Vector3(pos.x(), pos.y(), pos.z()); Quaternion q = new Quaternion(orient.x(), orient.y(), orient.z(), orient.w()); transform.position = p; transform.rotation = q; } return(null); }
// 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 ); } }
// 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 ); } }