예제 #1
0
        public IEnumerator NewScreenshot()
        {
            if (mutex)
            {
                yield return(true);
            }
            PluginLogger.debug("BYPASSED MUTEX");
            mutex = true;
            PluginLogger.debug("WAITING FOR END OF FRAME");
            yield return(new WaitForEndOfFrame());

            UpdateCameras();

            List <Camera> renderingCameras = new List <Camera>();

            foreach (string cameraName in activeCameras)
            {
                PluginLogger.debug("GETTING CAMERA" + cameraName);
                renderingCameras.Add(cameraDuplicates[cameraName]);
            }

            this.imageBytes = SnapshotRenderer.renderSnaphot(renderingCameras, camerares, camerares);
            this.didRender  = true;
            mutex           = false;
        }
예제 #2
0
        public static byte[] renderSnaphot(List <Camera> cameras, int width, int height)
        {
            PluginLogger.debug("RENDERING SNAPSHOT");

            /*RenderTexture rt = new RenderTexture(width, height, 24);
             *
             * foreach(Camera camera in cameras) {
             *  camera.targetTexture = rt;
             *  //camera.Render();
             * } */

            Texture2D screenShot = new Texture2D(width, height, TextureFormat.RGB24, false);

            //RenderTexture backupRenderTexture = RenderTexture.active;
            //RenderTexture.active = rt;
            screenShot.ReadPixels(new Rect(0, 0, width, height), 0, 0);

            foreach (Camera camera in cameras)
            {
                camera.targetTexture = null;
            }

            //RenderTexture.active = backupRenderTexture;

            byte[] result = screenShot.EncodeToJPG();
            Destroy(screenShot);
            //Destroy(rt);

            return(result);
        }
예제 #3
0
        public void UpdateCameras()
        {
            if (CameraManager.Instance != null)
            {
                PluginLogger.debug("CURRENT CAMERA MODE: " + CameraManager.Instance.currentCameraMode);
            }

            activeCameras = new List <string>();

            foreach (Camera camera in Camera.allCameras)
            {
                debugCameraDetails(camera);
                // Don't duplicate any cameras we're going to skip
                if (skippedCameras.IndexOf(camera.name) != -1)
                {
                    continue;
                }

                Camera cameraDuplicate;

                if (!cameraDuplicates.ContainsKey(camera.name))
                {
                    var cameraDuplicateGameObject = new GameObject(cameraContainerNamePrefix + camera.name);
                    cameraDuplicate = cameraDuplicateGameObject.AddComponent <Camera>();
                    cameraDuplicates[camera.name] = cameraDuplicate;
                }
                else
                {
                    cameraDuplicate = cameraDuplicates[camera.name];
                }

                cameraDuplicate.CopyFrom(camera);
                cameraDuplicate.enabled     = false;
                cameraDuplicate.fieldOfView = fovAngle;
                cameraDuplicate.aspect      = aspect;

                //Now that the camera has been duplicated, add it to the list of active cameras
                activeCameras.Add(camera.name);
            }
        }
예제 #4
0
        void LateUpdate()
        {
            PluginLogger.debug("LATEUPDATE FOR CAMERA");
            if (InternalCamera.Instance != null)
            {
                PluginLogger.debug("INTERNAL CAMERA Position: " + InternalCamera.Instance.transform.position.ToString());
                PluginLogger.debug("INTERNAL CAMERA Rotation: " + InternalCamera.Instance.transform.rotation.ToString());

                if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)
                {
                    foreach (Camera camera in Camera.allCameras)
                    {
                        if (camera.name == "InternalCamera")
                        {
                            fovAngle = camera.fieldOfView;
                        }
                    }
                }
                else
                {
                    fovAngle = defaultFovAngle;
                }

                PluginLogger.debug("INTERNAL CAMERA Zoom: " + fovAngle);
            }
            else
            {
                PluginLogger.debug("NO INTERNAL CAMERA");
            }

            if (CameraManager.Instance != null)
            {
                PluginLogger.debug("CAMERA FOUND, TAKING SCREENSHOT");
                StartCoroutine(NewScreenshot());
            }
        }
예제 #5
0
 public void debugCameraDetails(Camera cam)
 {
     PluginLogger.debug("CAMERA: " + cam.name + " ; NEAR CLIP PLANE: " + cam.nearClipPlane + "; FAR CLIP PLANE: " + cam.farClipPlane + " FOV : " + cam.fieldOfView + " POSITION: " + cam.transform.position.ToString() + " ROTATION: " + cam.transform.rotation.ToString());
 }
예제 #6
0
 public virtual void debugCameraDetails(Camera cam)
 {
     PluginLogger.debug("CAMERA: " + cam.name + " POS: " + cam.transform.position + "; ROT: " + cam.transform.rotation + " ; NEAR:" + cam.nearClipPlane + "; FAR: " + cam.farClipPlane);
 }
예제 #7
0
 public void verboseCameraDebug(Camera camera)
 {
     PluginLogger.debug(verboseCameraDetails(camera));
 }
 public void DebugInfo()
 {
     PluginLogger.debug("RPM CAMERA LOADED: " + part.name + " ; NAME: " + cameraName + " ; POS: " + part.transform.position + "; ROTATION: " + rotateCamera + " ; TRANSLATE: " + translateCamera);
 }