Beispiel #1
0
        void ReturnResults()
        {
            if (userToGetUpdate != null)
            {
                try
                {
                    if (!QcUnity.IsNullOrDestroyed_Obj(userToGetUpdate))
                    {
                        userToGetUpdate.AfterCameraRender(_projectorCamera.targetTexture);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }

                lastUserUpdateReturned = QcUnity.TimeSinceStartup();

                userToGetUpdate = null;

                if (!pauseAutoUpdates)
                {
                    painterProjectorCameraConfiguration.To(_projectorCamera);
                }
            }
        }
Beispiel #2
0
        void ReturnResults()
        {
            if (userToGetUpdate != null)
            {
                //Debug.Log("Returning user "+userToGetUpdate.ToString());

                try
                {
                    userToGetUpdate.AfterCameraRender(_projectorCamera.targetTexture);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }

                lastUserUpdateReturned = QcUnity.TimeSinceStartup();

                //if (userToGetUpdate as VolumeRayTrace != null)
                //Debug.Log("Returning result");

                userToGetUpdate = null;

                if (!pauseAutoUpdates)
                {
                    painterProjectorCameraConfiguration.To(_projectorCamera);
                }
            }
        }
Beispiel #3
0
 public void RenderRightNow(IUseDepthProjector proj)
 {
     userToGetUpdate = proj;
     RequestRender(false);
     // Returning results will give previous frame
     // ReturnResults();
 }
Beispiel #4
0
        void ReturnResults()
        {
            if (userToGetUpdate != null)
            {
                //Debug.Log("Returning user "+userToGetUpdate.ToString());

                try
                {
                    userToGetUpdate.AfterCameraRender(_projectorCamera.targetTexture);
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }

                lastUserUpdateReturned = Time.time;

                userToGetUpdate = null;

                if (!pauseAutoUpdates)
                {
                    painterProjectorCameraConfiguration.To(_projectorCamera);
                }
            }
        }
Beispiel #5
0
        public static bool TrySubscribeToDepthCamera(IUseDepthProjector pj)
        {
            if (!depthUsers.Contains(pj))
            {
                depthUsers.Add(pj);
                return(true);
            }

            return(false);
        }
Beispiel #6
0
        public static bool TrySubscribeToDepthCamera(IUseDepthProjector pj)
        {
            if (depthUsers.Count > 64)
            {
                Debug.LogError("Too many depth users");
                return(false);
            }

            if (!depthUsers.Contains(pj))
            {
                depthUsers.Add(pj);
                return(true);
            }

            return(false);
        }
Beispiel #7
0
        private void TryGetNextUser()
        {
            if (lastUpdatedUser >= depthUsers.Count)
            {
                lastUpdatedUser = 0;
                userToGetUpdate = null;
            }
            else
            {
                bool gotNull = false;

                while (lastUpdatedUser < depthUsers.Count)
                {
                    userToGetUpdate = depthUsers[lastUpdatedUser];

                    if (QcUnity.IsNullOrDestroyed_Obj(userToGetUpdate))
                    {
                        gotNull         = true;
                        userToGetUpdate = null;
                    }
                    else
                    if (userToGetUpdate.ProjectorReady())
                    {
                        break;
                    }
                    else
                    {
                        userToGetUpdate = null;
                    }

                    lastUpdatedUser++;
                }

                lastUpdatedUser++;

                if (gotNull)
                {
                    for (int i = depthUsers.Count - 1; i >= 0; i--)
                    {
                        if (QcUnity.IsNullOrDestroyed_Obj(depthUsers[i]))
                        {
                            depthUsers.RemoveAt(i);
                        }
                    }
                }
            }
        }
Beispiel #8
0
        public void ManagedUpdate()
        {
            if (userToGetUpdate != null && (Time.time - lastUserUpdateReturned > 1))
            {
                Debug.LogError("Could not return to user {0}".F(userToGetUpdate));
                userToGetUpdate = null;
            }

            if ((sinceLastPainterCall > 0.25f) && _projectorCamera && userToGetUpdate == null)
            {
                if (!pauseAutoUpdates)
                {
                    TryGetNextUser();
                }

                RequestRender(true);
            }

            sinceLastPainterCall += Time.deltaTime;
        }
Beispiel #9
0
        public void ManagedUpdate()
        {
            if (userToGetUpdate != null && (QcUnity.TimeSinceStartup() - lastUserUpdateReturned > 1))
            {
                logger.Log_Interval(60, "Could not return to user {0}".F(userToGetUpdate));

                userToGetUpdate = null;
            }

            if ((sinceLastPainterCall > 0.25f) && _projectorCamera && userToGetUpdate == null)
            {
                if (!pauseAutoUpdates)
                {
                    TryGetNextUser();
                }

                RequestRender(true);
            }

            sinceLastPainterCall += Time.deltaTime;
        }
Beispiel #10
0
        private void RequestRender(bool updatePainterIfNoUser)
        {
            bool gotUser = false;

            _projectorCamera.ResetReplacementShader();
            _projectorCamera.clearFlags = CameraClearFlags.Depth;

            try
            {
                if (userToGetUpdate != null)
                {
                    var cfg = userToGetUpdate.GetProjectorCameraConfiguration();
                    var trg = userToGetUpdate.GetTargetTexture();

                    if (trg && cfg != null)
                    {
                        if (!pauseAutoUpdates)
                        {
                            painterProjectorCameraConfiguration.From(_projectorCamera);
                        }

                        cfg.To(_projectorCamera);
                        _projectorCamera.targetTexture = trg;

                        var prm = userToGetUpdate.GetGlobalCameraMatrixParameters();
                        if (prm != null)
                        {
                            prm.SetGlobalFrom(_projectorCamera);
                        }

                        gotUser = true;

                        var mode = userToGetUpdate.GetMode();

                        switch (mode)
                        {
                        case Mode.ReplacementShader:

                            var repl = userToGetUpdate as IUseReplacementCamera;

                            if (repl != null)
                            {
                                _projectorCamera.SetReplacementShader(repl.ProjectorShaderToReplaceWith(),
                                                                      repl.ProjectorTagToReplace());
                                _projectorCamera.clearFlags      = CameraClearFlags.Color;
                                _projectorCamera.backgroundColor = repl.CameraReplacementClearColor();
                                // _projectorCamera.farClipPlane = 3000;
                            }

                            break;
                        }

                        currentMode = mode;
                    }
                }

                if (!gotUser)
                {
                    userToGetUpdate = null;
                }
            }
            catch (Exception ex)
            {
                logger.Log_Interval(10, ex.ToString());
                userToGetUpdate = null;
            }

            if (userToGetUpdate == null)
            {
                UpdateCameraPositionForPainter();

                _projectorCamera.targetTexture = RenderTextureBuffersManager.depthTarget;

                _painterDepthCameraMatrix.SetGlobalFrom(_projectorCamera);
            }

            if (userToGetUpdate != null ||
                (TexMgmtData.useDepthForProjector && updatePainterIfNoUser && !pauseAutoUpdates))
            {
                _projectorCamera.Render();
            }
        }
Beispiel #11
0
 public void RenderRightNow(IUseDepthProjector proj)
 {
     userToGetUpdate = proj;
     RequestRender(false);
 }