Exemplo n.º 1
0
        private void CheckWorldSide(ViveSR_Portal portal)
        {
            Vector3 selfPos   = transform.position;
            Vector4 testPoint = new Vector4(selfPos.x, selfPos.y, selfPos.z, 1.0f);

            isInRealWorld    = (Vector4.Dot(portal.planeEquation, testPoint) >= 0);
            isInVirtualWorld = !isInRealWorld;

            currentWorld = (isInRealWorld ? WorldMode.RealWorld : WorldMode.VRWorld);
        }
Exemplo n.º 2
0
        public void AddPortal(GameObject portalGO)
        {
            ViveSR_Portal portal = portalGO.GetComponent <ViveSR_Portal>();

            if (portal)
            {
                portals.Add(portal);
                portal.SetRenderRule(viewerInWorld, realWorldStencilValue, virtualWorldStencilValue);
                portal.UpdatePlaneNormal();
            }
        }
Exemplo n.º 3
0
        public void ClearPortal(GameObject portalGO)
        {
            ViveSR_Portal portal = portalGO.GetComponent <ViveSR_Portal>();

            if (portal)
            {
                // if it is in the list
                if (portals.Remove(portal))
                {
                    Destroy(portal.gameObject);
                }
            }
        }
Exemplo n.º 4
0
        public void OnTriggerEnter(Collider other)
        {
            ViveSR_Portal otherPortal = other.transform.root.GetComponent <ViveSR_Portal>();

            if (otherPortal)
            {
                hitPortal    = otherPortal;
                hitPortalRnd = hitPortal.GetComponentInChildren <MeshRenderer>();
                CheckWorldSide(hitPortal);  // check which world is now
                isTransitioning   = true;
                selfCld.isTrigger = true;
                materialCB        = otherPortal.TransitionMaterialUpdateCB; // set the material behaviours when transitioning

                if (renderers == null)
                {
                    renderers = gameObject.GetComponentsInChildren <Renderer>(true);
                }
                SetClippingPlaneEnable(renderers, true, currentWorld);
                CheckTransitioningBehavious();
            }
        }
Exemplo n.º 5
0
        public void OnTriggerExit(Collider other)
        {
            ViveSR_Portal otherPortal = other.transform.root.GetComponent <ViveSR_Portal>();

            if (otherPortal)
            {
                hitPortal    = otherPortal;
                hitPortalRnd = hitPortal.GetComponentInChildren <MeshRenderer>();

                CheckWorldSide(hitPortal);  // check which world is now
                isTransitioning   = false;
                selfCld.isTrigger = originIsTrigger;

                if (isPlayer)
                {
                    portalMgr.viewerInWorld = currentWorld;
                    portalMgr.UpdateViewerWorld();
                    gameObject.layer = LayerMask.NameToLayer((currentWorld == WorldMode.RealWorld)? "Default" : "VirtualWorldLayer");
                }
                else
                {
                    if (isController)
                    {
                        portalMgr.controllerInWorld = currentWorld;
                    }
                    if (renderers == null)
                    {
                        renderers = gameObject.GetComponentsInChildren <Renderer>(true);
                    }
                    SwitchMaterials(renderers, currentWorld);
                    SetClippingPlaneEnable(renderers, false, currentWorld);
                }

                CheckTransitioningBehavious();
            }
        }