Example #1
0
        /// <summary>
        /// Construct a new surface.
        /// </summary>
        /// <param name="sIdentifier">The unique identifier for this surface.  Cannot be null.  If this is not unique, it will not be checked until the surface is registered with an authority.</param>
        public Surface(String sIdentifier)
        {
            // If the identifier is not valid, throw an error.
            if (sIdentifier == null || sIdentifier.Length == 0)
            {
                throw new Exception("Surface identifier cannot be empty.");
            }

            // Otherwise set the value.  HOWEVER.. this is not authorised by the authority.  It will be checked on registration.
            this.Authority_SetIdentifier(sIdentifier);

            // Load the debug for this surface.
            //pDebugImageControl = new Image();
            //pDebugImageControl.Source = new BitmapImage(new Uri("pack://application:,,,/UbiDisplays;component/Interface/Images/DebugImage.png"));

            // Generate a key to access the projected surface.
            sProjectionDisplayKey = System.Guid.NewGuid().ToString();

            // A surface control.
            pSurfaceContent           = new SurfaceView();
            pSurfaceContent.ShowDebug = true;

            // Create a projected display for this surface.
            pProjectionDisplay         = ProjectionRenderer.AddDisplay(sProjectionDisplayKey, pSurfaceContent);//, pDebugImageControl);
            pProjectionDisplay.Visible = true;
        }
Example #2
0
        public BoxSelection(Vector3 StartPosition, Vector3 EndPosition, Quaternion Orientation, ProjectionRenderer Innards, ProjectionRenderer Border, float Width)
        {
            //Setup core object
            selection          = new GameObject("Box Selection").transform;
            selection.rotation = Orientation;
            selection.position = StartPosition;

            //Set positions
            start = selection.InverseTransformPoint(StartPosition);
            end   = selection.InverseTransformPoint(EndPosition);

            //Set width
            width = Width;

            //Request display projections
            ProjectionPool pool = ProjectionPool.GetPool(0);

            core   = pool.Request(Innards);
            left   = pool.Request(Border);
            right  = pool.Request(Border);
            top    = pool.Request(Border);
            bottom = pool.Request(Border);

            //Parent display
            core.transform.SetParent(selection);
            left.transform.SetParent(selection);
            right.transform.SetParent(selection);
            top.transform.SetParent(selection);
            bottom.transform.SetParent(selection);

            //Update displays
            UpdateDisplays();
        }
Example #3
0
        private void OnEnable()
        {
            //Grab projection
            projection = GetComponent <ProjectionRenderer>();

            //Register to singleton
            StartCoroutine(Register());
        }
Example #4
0
        private void OnEnable()
        {
            //Grab projection renderer
            projectionRenderer         = GetComponent <ProjectionRenderer>();
            projectionRenderer.enabled = true;

            //Fade projection out
            StartCoroutine(FadeIn());
        }
Example #5
0
        public static void Deregister(ProjectionRenderer Projection, GooType Type)
        {
            //Grab goo
            List <ProjectionRenderer> goo = GetGoo(Type);

            //Remove projection from goo
            if (goo != null)
            {
                goo.Remove(Projection);
            }
        }
Example #6
0
        private IEnumerator GrabProjection()
        {
            //Grab ray positioner
            RayPositioner positioner = GetComponent <RayPositioner>();

            //Grab projection
            while (decal == null)
            {
                Decal = positioner.Active;
                yield return(new WaitForEndOfFrame());
            }
        }
Example #7
0
        private void OnTriggerEnter(Collider other)
        {
            if (ripple != null && other.GetComponent <Rigidbody>() != null)
            {
                ProjectionRenderer proj = Instantiate(ripple);

                //Set pos / rot
                proj.transform.position = other.transform.position;
                proj.transform.rotation = Quaternion.LookRotation(Vector3.down);

                //Set scale
                Bounds bounds = other.bounds;
                proj.transform.localScale = Vector3.one * (Mathf.Max(bounds.size.x, bounds.size.y, bounds.size.z));

                //Set parent
                proj.transform.parent = transform;
            }
        }
Example #8
0
        public static bool Register(ProjectionRenderer Projection, GooType Type)
        {
            //Grab goo
            List <ProjectionRenderer> goo = GetGoo(Type);

            if (goo != null)
            {
                //Add projection to goo
                if (!goo.Contains(Projection))
                {
                    goo.Add(Projection);
                }

                //Successfully registered
                return(true);
            }

            //Singleton not yet initialized, cannot be registered
            return(false);
        }
Example #9
0
        /// <summary>
        /// Called by the authority to signal that this surface has been deleted.
        /// </summary>
        internal void Authority_Delete()
        {
            // Remove the projection display.
            if (pProjectionDisplay != null)
            {
                pProjectionDisplay.Visible = false;
                ProjectionRenderer.RemoveDisplay(pProjectionDisplay);
                pProjectionDisplay = null;
            }

            // Remove the reference to the active display.
            if (ActiveDisplay != null)
            {
                Authority_DetachDisplay(ActiveDisplay);
                throw new Exception("Error deleting surface.  Display still active.");
            }

            // Free any resources.
            this.DeleteResources();

            // Remove the debug image.
            if (pSurfaceContent != null)
            {
                pSurfaceContent.Children.Clear();
                pSurfaceContent = null;
            }
            //pDebugImageControl = null;

            // Set the deleted flag.
            bDeleted = true;

            // Deletion event.
            if (OnDeleted != null)
            {
                OnDeleted(this);
            }
        }