// Update is called once per frame void Update() { if (!attached) { GameObject node = GameObject.Find(VRNode); if (VRNode.Length == 0) { MiddleVRTools.Log(0, "[X] AttachToNode: Please specify a valid vrNode name."); } if (node != null) { transform.parent = node.transform; transform.localPosition = new Vector3(positionx, positiony, positionz); transform.rotation = new Quaternion(0, 180, -180, 1); MiddleVRTools.Log(2, "[+] AttachToNode: " + this.name + " attached to : " + node.name); attached = true; } else { if (m_Searched == false) { MiddleVRTools.Log(0, "[X] AttachToNode: Failed to find Game object '" + VRNode + "'"); m_Searched = true; } } } }
private bool DisableAllCollisions(bool iDisabled) { if (MiddleVR.VRPhysicsMgr == null) { return(false); } vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { return(false); } if (physicsEngine.IsStarted()) { bool actionApplied = physicsEngine.EnableCollisions(!iDisabled); if (actionApplied) { if (iDisabled) { MiddleVRTools.Log(2, "[ ] PhysicsDisableAllCollisions: all collisions disabled."); } else { MiddleVRTools.Log(2, "[ ] PhysicsDisableAllCollisions: all collisions enabled."); } } return(actionApplied); } return(false); }
protected void Update() { if (!m_DidFirstAttachment) { var physicsMgr = MiddleVR.VRPhysicsMgr; if (physicsMgr == null) { MiddleVRTools.Log(0, "[X] PhysicsBodyManipulator: No PhysicsManager found."); enabled = false; return; } vrPhysicsEngine physicsEngine = physicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { return; } if (physicsEngine.IsStarted()) { AttachOrDetachBody(true); m_DidFirstAttachment = true; } } }
protected void Update() { if (!mApplied) { vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { MiddleVRTools.Log(0, "[X] PhysicsDisableAllCollisions: No PhysicsEngine found."); enabled = false; return; } if (physicsEngine.IsStarted()) { bool disabled = physicsEngine.EnableCollisions(false); if (disabled) { MiddleVRTools.Log(2, "[ ] PhysicsDisableAllCollisions: all collisions disabled."); } mApplied = true; } } }
public void ApplyVRSettings() { PlayerSettings.defaultIsFullScreen = false; PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; PlayerSettings.runInBackground = true; PlayerSettings.captureSingleScreen = false; //PlayerSettings.usePlayerLog = false; QualitySettings.vSyncCount = 0; MiddleVRTools.Log("VR Player settings changed:"); MiddleVRTools.Log("- DefaultIsFullScreen = false"); MiddleVRTools.Log("- DisplayResolutionDialog = Disabled"); MiddleVRTools.Log("- RunInBackground = true"); MiddleVRTools.Log("- CaptureSingleScreen = false"); //MiddleVRTools.Log("- UsePlayerLog = false"); #if UNITY_3_4 MiddleVRTools.Log("Quality settings changed for the current quality level (" + QualitySettings.currentLevel + ") :"); #else string[] names = QualitySettings.names; MiddleVRTools.Log("Quality settings changed for the current quality level (" + names[QualitySettings.GetQualityLevel()] + ") :"); #endif MiddleVRTools.Log("- VSyncCount = 0"); }
public void ApplyVRSettings() { PlayerSettings.defaultIsFullScreen = false; PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled; PlayerSettings.runInBackground = true; PlayerSettings.captureSingleScreen = false; PlayerSettings.MTRendering = false; //PlayerSettings.usePlayerLog = false; MiddleVRTools.Log("VR Player settings changed:"); MiddleVRTools.Log("- DefaultIsFullScreen = false"); MiddleVRTools.Log("- DisplayResolutionDialog = Disabled"); MiddleVRTools.Log("- RunInBackground = true"); MiddleVRTools.Log("- CaptureSingleScreen = false"); //MiddleVRTools.Log("- UsePlayerLog = false"); string[] names = QualitySettings.names; int qualityLevel = QualitySettings.GetQualityLevel(); // Disable VSync on all quality levels for (int i = 0; i < names.Length; ++i) { QualitySettings.SetQualityLevel(i); QualitySettings.vSyncCount = 0; } QualitySettings.SetQualityLevel(qualityLevel); MiddleVRTools.Log("Quality settings changed for all quality levels:"); MiddleVRTools.Log("- VSyncCount = 0"); }
protected bool AddConstraint() { vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { return(false); } if (m_PhysicsConstraint == null) { return(false); } bool addedToSimulation = false; // Cannot fail since we require this component. VRPhysicsBody body0 = GetComponent <VRPhysicsBody>(); VRPhysicsBody body1 = null; if (m_ConnectedBody != null) { body1 = m_ConnectedBody.GetComponent <VRPhysicsBody>(); } if (body0.PhysicsBody != null) { m_PhysicsConstraint.SetAxis(MiddleVRTools.FromUnity(Axis)); m_PhysicsConstraint.SetLowerLimit(m_Limits.Min); m_PhysicsConstraint.SetUpperLimit(m_Limits.Max); m_PhysicsConstraint.SetReferencePosition(m_ZeroPosition); m_PhysicsConstraint.SetBody(0, body0.PhysicsBody); m_PhysicsConstraint.SetBody(1, body1 != null ? body1.PhysicsBody : null); addedToSimulation = physicsEngine.AddConstraint(m_PhysicsConstraint); if (addedToSimulation) { MiddleVRTools.Log(3, "[ ] The constraint '" + m_PhysicsConstraintName + "' was added to the physics simulation."); } else { MiddleVRTools.Log(3, "[X] Failed to add the constraint '" + m_PhysicsConstraintName + "' to the physics simulation."); } } else { MiddleVRTools.Log(0, "[X] The PhysicsBody of '" + name + "' for the prismatic physics constraint '" + m_PhysicsConstraintName + "' is null."); } return(addedToSimulation); }
protected void Start() { if (MiddleVR.VRClusterMgr.IsCluster() && !MiddleVR.VRClusterMgr.IsServer()) { enabled = false; return; } if (MiddleVR.VRPhysicsMgr == null) { MiddleVRTools.Log(0, "[X] PhysicsEnableCollisions: No PhysicsManager found."); enabled = false; return; } vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { MiddleVRTools.Log(0, "[X] PhysicsEnableCollisions: No PhysicsEngine found."); enabled = false; return; } }
// 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 ); } } }
protected void Update() { if (MiddleVR.VRDeviceMgr != null && MiddleVR.VRDeviceMgr.IsKeyPressed(MiddleVR.VRK_H) && MiddleVR.VRDeviceMgr.IsKeyToggled(MiddleVR.VRK_C)) { if (MiddleVR.VRPhysicsMgr == null) { MiddleVRTools.Log(0, "[X] VRChangeManipulationDeviceIPSISample: No PhysicsManager found."); enabled = false; return; } vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { return; } uint bodiesNb = physicsEngine.GetBodiesNb(); m_PhysicsBodyId = (m_PhysicsBodyId + 1) % ((int)bodiesNb); MiddleVRTools.Log(0, "[+] VRChangeManipulationDeviceIPSISample: proposed body id: " + m_PhysicsBodyId + "."); vrPhysicsBody physicsBody = physicsEngine.GetBody((uint)m_PhysicsBodyId); if (physicsBody != null && physicsBody.IsA("PhysicsBodyIPSI")) { var kernel = MiddleVR.VRKernel; var objId = physicsBody.GetId(); // SetAttachedToAManipDevice (do an attachment). var setAttachedToAManipDeviceValues = vrValue.CreateList(); setAttachedToAManipDeviceValues.AddListItem(objId); setAttachedToAManipDeviceValues.AddListItem(true); kernel.ExecuteCommand( "Haption.IPSI.SetAttachedToAManipulationDevice", setAttachedToAManipDeviceValues); // The previous manipulated physics body (if any), will be // automatically marked as not-manipulated. // SetManipulationDevice (only attachment). var setManipDeviceValues = vrValue.CreateList(); setManipDeviceValues.AddListItem(objId); setManipDeviceValues.AddListItem(m_ManipulationDeviceId); kernel.ExecuteCommand( "Haption.IPSI.SetManipulationDeviceId", setManipDeviceValues); MiddleVRTools.Log(0, "[+] VRChangeManipulationDeviceIPSISample: attached '" + physicsBody.GetName() + "' to the manipulation device '" + m_ManipulationDeviceId + "'."); } } }
// Update is called once per frame void Update() { MiddleVRTools.Log(4, "[>] VR PostFrame Update!"); MiddleVR.VRClusterMgr.EndFrameUpdate(); StartCoroutine(EndOfFrame()); }
// Use this for initialization public void Start() { if (m_ShareID == 0) { m_ShareID = g_shareID++; MiddleVRTools.Log("[ ] " + this.name + " ShareID: " + m_ShareID); } }
protected bool AddConstraint() { vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { return(false); } if (m_PhysicsConstraint == null) { return(false); } bool addedToSimulation = false; // Cannot fail since we require this component. VRPhysicsBody body0 = GetComponent <VRPhysicsBody>(); VRPhysicsBody body1 = null; if (m_ConnectedBody != null) { body1 = m_ConnectedBody.GetComponent <VRPhysicsBody>(); } if (body0.PhysicsBody != null) { var scaleShearMatrix = MVRTools.ComputeScaleShearMatrixWorld(transform); m_PhysicsConstraint.SetPosition(MiddleVRTools.FromUnity(scaleShearMatrix * Anchor)); m_PhysicsConstraint.SetAxis0(MiddleVRTools.FromUnity(Axis0)); m_PhysicsConstraint.SetAxis1(MiddleVRTools.FromUnity(Axis1)); m_PhysicsConstraint.SetBody(0, body0.PhysicsBody); m_PhysicsConstraint.SetBody(1, body1 != null ? body1.PhysicsBody : null); addedToSimulation = physicsEngine.AddConstraint(m_PhysicsConstraint); if (addedToSimulation) { MiddleVRTools.Log(3, "[ ] The constraint '" + m_PhysicsConstraintName + "' was added to the physics simulation."); } else { MiddleVRTools.Log(0, "[X] Failed to add the constraint '" + m_PhysicsConstraintName + "' to the physics simulation."); } } else { MiddleVRTools.Log(0, "[X] The PhysicsBody of '" + name + "' for the U-joint physics constraint '" + m_PhysicsConstraintName + "' is null."); } return(addedToSimulation); }
void Start() { MiddleVRTools.Log(4, "[>] VR Manager Start."); #if !UNITY_3_4 && !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_0_1 && !UNITY_4_1 m_AllowRenderTargetAA = true; #endif InitializeVR(); // Reset Manager's position so text display is correct. transform.position = new UnityEngine.Vector3(0, 0, 0); transform.rotation = new Quaternion(); transform.localScale = new UnityEngine.Vector3(1, 1, 1); m_Wand = GameObject.Find("VRWand"); if (ShowFPS) { guiText.enabled = true; } else { guiText.enabled = false; } if (ShowWand) { ShowWandGeometry(true); } else { ShowWandGeometry(false); } if (ForceQuality) { #if UNITY_3_4 QualitySettings.currentLevel = (QualityLevel)ForceQualityIndex; #else QualitySettings.SetQualityLevel(ForceQualityIndex); #endif //bool useOpenGLQuadbuffer = MiddleVR.VRDisplayMgr.GetActiveViewport(0).GetStereo() && (MiddleVR.VRDisplayMgr.GetActiveViewport(0).GetStereoMode()==0); //VRStereoMode_QuadBuffer = 0 if (!Application.isEditor && (/* useOpenGLQuadbuffer || */ MiddleVR.VRClusterMgr.GetForceOpenGLConversion())) { m_NeedDelayedRenderingReset = true; m_RenderingResetDelay = 1; } } // Manage VSync after the quality settings MiddleVRTools.ManageVSync(); // Set AA from vrx configuration file //QualitySettings.antiAliasing = m_AntiAliasingLevel; MiddleVRTools.Log(4, "[<] End of VR Manager Start."); }
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 + ")."); } }
// Update is called once per frame void Update() { //MiddleVRTools.Log("VRManagerUpdate"); if (m_isInit) { MiddleVRTools.Log(4, "[>] Unity Update - Start"); if (kernel.GetFrame() >= 1 && !m_isGeometrySet && !Application.isEditor) { if (!DontChangeWindowGeometry) { displayMgr.SetUnityWindowGeometry(); } m_isGeometrySet = true; } kernel.Update(); UpdateInput(); if (ShowFPS) { guiText.text = kernel.GetFPS().ToString("f2"); } MiddleVRTools.UpdateNodes(); if (m_displayLog) { string txt = kernel.GetLogString(true); print(txt); m_GUI.text = txt; } vrKeyboard keyb = MiddleVR.VRDeviceMgr.GetKeyboard(); if (keyb != null && keyb.IsKeyToggled(MiddleVR.VRK_F) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowFPS = !ShowFPS; guiText.enabled = ShowFPS; } if (keyb != null && (keyb.IsKeyToggled(MiddleVR.VRK_W) || keyb.IsKeyToggled(MiddleVR.VRK_Z)) && (keyb.IsKeyPressed(MiddleVR.VRK_LSHIFT) || keyb.IsKeyPressed(MiddleVR.VRK_RSHIFT))) { ShowWand = !ShowWand; ShowWandGeometry(ShowWand); } DeltaTime = kernel.GetDeltaTime(); MiddleVRTools.Log(4, "[<] Unity Update - End"); } else { //Debug.LogWarning("[ ] If you have an error mentionning 'DLLNotFoundException: MiddleVR_CSharp', please restart Unity. If this does not fix the problem, please make sure MiddleVR is in the PATH environment variable."); } }
public void SetNavigationNode(GameObject iNavigationNode) { m_NavigationNode = iNavigationNode; m_VRNavigationNode = MiddleVR.VRDisplayMgr.GetNode(iNavigationNode.name); if (m_VRNavigationNode == null) { MiddleVRTools.Log(2, "[X] VRHeadCollision: the navigation node to set doesn't have a corresponding vrNode3D in MiddleVR nodes."); } }
protected void Start() { if (MiddleVR.VRPhysicsMgr == null) { MiddleVRTools.Log(0, "[X] PhysicsDisableAllCollisions: No PhysicsManager found."); enabled = false; return; } }
// 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); } }
protected void Update() { if (MiddleVR.VRPhysicsMgr == null) { return; } vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine == null) { return; } for (int i = 0; i < m_MaxContactsNb; i++) { GameObject go = m_ContactsToShow[i]; if (go != null) { go.SetActive(false); } } // We will reuse the same vectors to avoid many memory allocations. Vector3 contactPosition = new Vector3(); Vector3 contactNormal = new Vector3(); for (uint i = 0, iEnd = physicsEngine.GetContactInfosNb(); i < iEnd && i < m_MaxContactsNb; i++) { vrPhysicsContactInfo contactInfo = physicsEngine.GetContactInfo(i); MiddleVRTools.ToUnity(contactInfo.GetPositionOnBody0(), ref contactPosition); MiddleVRTools.ToUnity(contactInfo.GetNormalOnBody0(), ref contactNormal); Quaternion contactQ = Quaternion.FromToRotation(Vector3.up, contactNormal); Vector3 p = m_Translation + contactPosition; GameObject go = m_ContactsToShow[i]; if (go != null) { go.transform.position = p; go.transform.rotation = m_RotationAsQuat * contactQ; go.SetActive(true); } if (m_RayDebug) { Debug.DrawRay(p, m_RotationAsQuat * contactNormal, Color.green); } } }
protected void AttachOrDetachBody(bool doAttachement) { VRPhysicsBody physicsBodyComponent = GetComponent <VRPhysicsBody>(); if (physicsBodyComponent == null) { return; } vrPhysicsBody physicsBody = null; if (MiddleVR.VRPhysicsMgr != null) { vrPhysicsEngine physicsEngine = MiddleVR.VRPhysicsMgr.GetPhysicsEngine(); if (physicsEngine != null) { // Prefer to find the object by its name so we won't access // a dangling pointer when the body was destroyed by MiddleVR. physicsBody = physicsEngine.GetBody(m_PhysicsBodyName); } } if (physicsBody == null) { return; } var kernel = MiddleVR.VRKernel; var physicsBodyId = physicsBody.GetId(); if (doAttachement) { // Do "+1" because "0" means "unknown attach point type". uint attachPointType = (uint)m_AttachPointType + 1; var scaleShearMatrix = MVRTools.ComputeScaleShearMatrixWorld(transform); var offsetTrans = scaleShearMatrix * m_OffsetTranslation; var offsetRot = Quaternion.Euler(m_OffsetRotation); var attachManipDeviceToBodyPrmsValue = vrValue.CreateList(); attachManipDeviceToBodyPrmsValue.AddListItem(m_ManipulationDeviceId); attachManipDeviceToBodyPrmsValue.AddListItem(physicsBodyId); attachManipDeviceToBodyPrmsValue.AddListItem(attachPointType); attachManipDeviceToBodyPrmsValue.AddListItem( MiddleVRTools.FromUnity(offsetTrans)); attachManipDeviceToBodyPrmsValue.AddListItem( MiddleVRTools.FromUnity(offsetRot)); kernel.ExecuteCommand( "Haption.IPSI.AttachManipulationDeviceToBody", attachManipDeviceToBodyPrmsValue); } }
// Update is called once per frame void Update() { MiddleVRTools.Log(4, "[>] Unity: VR PostFrame Update!"); MiddleVR.VRClusterMgr.EndFrameUpdate(); MiddleVRTools.Log(4, "[ ] Unity: StartCoRoutine EndOfFrame!"); StartCoroutine(EndOfFrame()); MiddleVRTools.Log(4, "[<] Unity: End of VR PostFrame Update!"); }
protected void Start() { haptionDriver = MiddleVR.VRKernel.GetObject("Haption Driver"); if (haptionDriver == null) { MiddleVRTools.Log(0, "TrackHaptionDeviceButtonsStatus: No driver Haption found!"); enabled = false; return; } }
// Update is called once per frame void Update () { if (m_Node == null && MiddleVR.VRDisplayMgr != null) { m_Node = MiddleVR.VRDisplayMgr.GetNode(VRNodeName); } if (m_Node != null) { transform.localPosition = MiddleVRTools.ToUnity(m_Node.GetPositionWorld()); transform.localRotation = MiddleVRTools.ToUnity(m_Node.GetOrientationWorld()); } }
// Use this public method from interaction scripts to initialize and start collision public void Initialize() { if (m_CollisionNode != null && m_NavigationNode != null && m_VRNavigationNode != null) { m_LastCollisionNodePosition = m_CollisionNode.transform.position; m_Initialized = true; MiddleVRTools.Log(2, "[ ] VRHeadCollision: initialized"); } else { MiddleVRTools.Log(2, "[X] VRHeadCollision: impossible to retrieve sepcified navigation or collision nodes"); } }
void UpdateElasticRepresentation() { if (m_ElasticRepresentation == null) { MiddleVR.VRLog(2, "[X] VRInteractionNavigationElastic error: bad elastic representation reference"); return; } Vector3 startPosition = MiddleVRTools.ToUnity(m_it.GetInteractionStartWorldMatrix().GetTranslation()); Vector3 endPosition = MiddleVRTools.ToUnity(m_ReferenceNode.GetPositionWorld()); m_ElasticRepresentation.SetElasticPoints(startPosition, endPosition); }
private void ConvertGeometry(Matrix4x4 iTopMatrixWorld, Transform iTransform, Mesh iMesh, vrPhysicsGeometry ioGeometry, uint iGeometryIndex) { var vertices = iMesh.vertices; var triangles = iMesh.triangles; MiddleVRTools.Log(3, "[ ] PhysicsBody: Number of vertices in sub-geometry '" + iGeometryIndex + "': " + vertices.Length); MiddleVRTools.Log(3, "[ ] PhysicsBody: Number of triangles in sub-geometry '" + iGeometryIndex + "': " + triangles.Length); var m = iTopMatrixWorld.inverse * iTransform.localToWorldMatrix; // We will reuse the same vector to avoid many memory allocations. vrVec3 vPos = new vrVec3(); MiddleVRTools.Log(6, "[>] PhysicsBody: Adding vertices."); foreach (Vector3 vertex in vertices) { var vertexPos = m.MultiplyPoint3x4(vertex); MiddleVRTools.FromUnity(vertexPos, ref vPos); ioGeometry.AddVertex(vPos, iGeometryIndex); MiddleVRTools.Log(6, "[ ] PhysicsBody: Adding a vertex at position (" + vPos.x() + ", " + vPos.y() + ", " + vPos.z() + ") to sub-geometry '" + iGeometryIndex + "'."); } MiddleVRTools.Log(6, "[<] PhysicsBody: End of adding vertices."); MiddleVRTools.Log(6, "[>] PhysicsBody: Adding triangles."); for (int i = 0, iEnd = triangles.Length; i < iEnd; i += 3) { var index0 = (uint)triangles[i + 0]; var index1 = (uint)triangles[i + 1]; var index2 = (uint)triangles[i + 2]; ioGeometry.AddTriangle(index0, index1, index2, iGeometryIndex); MiddleVRTools.Log(6, "[ ] PhysicsBody: Adding a triangle with vertex indexes (" + index0 + ", " + index1 + ", " + index2 + ") to sub-geometry '" + iGeometryIndex + "'."); } MiddleVRTools.Log(6, "[<] PhysicsBody: End of adding triangles."); }
// 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_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 ); } }
void AddClusterScripts(GameObject iObject) { MiddleVRTools.Log(2, "[ ] Adding cluster sharing scripts to " + iObject.name); if (iObject.GetComponent <VRShareTransform>() == null) { VRShareTransform script = iObject.AddComponent <VRShareTransform>() as VRShareTransform; script.Start(); } if (iObject.GetComponent <VRApplySharedTransform>() == null) { VRApplySharedTransform script = iObject.AddComponent <VRApplySharedTransform>() as VRApplySharedTransform; script.Start(); } }