public WebCamImpl(Camera arCamera, Camera backgroundCamera, int renderTextureLayer, string webcamDeviceName, bool flipHorizontally) { if (QCARRuntimeUtilities.IsPlayMode()) { this.mRenderTextureLayer = renderTextureLayer; this.mARCamera = arCamera; this.mOriginalCameraClearFlags = this.mARCamera.clearFlags; this.mARCamera.clearFlags = CameraClearFlags.Depth; this.mBackgroundCameraInstance = backgroundCamera; this.mBgRenderingTexBehaviour = this.mBackgroundCameraInstance.GetComponentInChildren <BGRenderingAbstractBehaviour>(); if (this.mBgRenderingTexBehaviour == null) { Debug.LogError("Instanciated Prefab does not contain VideoTextureBehaviour!"); } else { this.mOriginalCameraCullMask = this.mARCamera.cullingMask; this.mARCamera.cullingMask &= ~(((int)1) << this.mBgRenderingTexBehaviour.gameObject.layer); this.mARCamera.cullingMask &= ~(((int)1) << this.mRenderTextureLayer); WebCamProfile profile = new WebCamProfile(); if (QCARRuntimeUtilities.IsQCAREnabled() && (WebCamTexture.devices.Length > 0)) { bool flag = false; foreach (WebCamDevice device in WebCamTexture.devices) { if (device.name.Equals(webcamDeviceName)) { flag = true; } } if (!flag) { webcamDeviceName = WebCamTexture.devices[0].name; } this.mWebCamProfile = profile.GetProfile(webcamDeviceName); this.mWebCamTexture = new WebCamTexAdaptorImpl(webcamDeviceName, this.mWebCamProfile.RequestedFPS, this.mWebCamProfile.RequestedTextureSize); } else { this.mWebCamProfile = profile.Default; this.mWebCamTexture = new NullWebCamTexAdaptor(this.mWebCamProfile.RequestedFPS, this.mWebCamProfile.RequestedTextureSize); } this.mBgRenderingTexBehaviour.SetFlipHorizontally(flipHorizontally); this.mFlipHorizontally = flipHorizontally; } } }
public WebCamImpl(Camera arCamera, Camera backgroundCamera, int renderTextureLayer, string webcamDeviceName, bool flipHorizontally) { #if UNITY_EDITOR mRenderTextureLayer = renderTextureLayer; // get main camera, set correct clear flags: mARCamera = arCamera; mOriginalCameraClearFlags = mARCamera.clearFlags; mARCamera.clearFlags = CameraClearFlags.Depth; // instanciate BackgroundCamera mBackgroundCameraInstance = backgroundCamera; // make sure the correct prefab has been attached: mBgRenderingTexBehaviour = mBackgroundCameraInstance.GetComponentInChildren <BGRenderingBehaviour>(); if (mBgRenderingTexBehaviour == null) { Debug.LogError("Instanciated Prefab does not contain VideoTextureBehaviour!"); } else { mOriginalCameraCullMask = mARCamera.cullingMask; // set mask to cull away bg rendering behaviour and texture buffer layer mARCamera.cullingMask &= ~(1 << mBgRenderingTexBehaviour.gameObject.layer); mARCamera.cullingMask &= ~(1 << mRenderTextureLayer); // load the webcam profiles WebCamProfile profiles = new WebCamProfile(); if (QCARRuntimeUtilities.IsQCAREnabled() && (WebCamTexture.devices.Length > 0)) { // check if selected web cam shows up in list of available devices: bool selectedWebCamAvailable = false; foreach (WebCamDevice webCamDevice in WebCamTexture.devices) { if (webCamDevice.name.Equals(webcamDeviceName)) { selectedWebCamAvailable = true; } } // if it was not found, default to first available camera if (!selectedWebCamAvailable) { webcamDeviceName = WebCamTexture.devices[0].name; } mWebCamProfile = profiles.GetProfile(webcamDeviceName); // create webcam texture adaptor mWebCamTexture = new WebCamTexAdaptorImpl(webcamDeviceName, mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } else { // no webcam connected, use default profile and null implementation for webcam mWebCamProfile = profiles.Default; // create null webcam implementation mWebCamTexture = new NullWebCamTexAdaptor(mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } // override the texture created by the the VideoTextureBehaviour mBgRenderingTexBehaviour.SetFlipHorizontally(flipHorizontally); mFlipHorizontally = flipHorizontally; } #endif }
public WebCamImpl(Camera arCamera, Camera backgroundCamera, int renderTextureLayer, string webcamDeviceName, bool flipHorizontally) { #if UNITY_EDITOR mRenderTextureLayer = renderTextureLayer; // get main camera, set correct clear flags: mARCamera = arCamera; mOriginalCameraClearFlags = mARCamera.clearFlags; mARCamera.clearFlags = CameraClearFlags.Depth; // instanciate BackgroundCamera mBackgroundCameraInstance = backgroundCamera; // make sure the correct prefab has been attached: mBgRenderingTexBehaviour = mBackgroundCameraInstance.GetComponentInChildren<BGRenderingBehaviour>(); if (mBgRenderingTexBehaviour == null) { Debug.LogError("Instanciated Prefab does not contain VideoTextureBehaviour!"); } else { mOriginalCameraCullMask = mARCamera.cullingMask; // set mask to cull away bg rendering behaviour and texture buffer layer mARCamera.cullingMask &= ~(1 << mBgRenderingTexBehaviour.gameObject.layer); mARCamera.cullingMask &= ~(1 << mRenderTextureLayer); // load the webcam profiles WebCamProfile profiles = new WebCamProfile(); if (QCARRuntimeUtilities.IsQCAREnabled() && (WebCamTexture.devices.Length > 0)) { // check if selected web cam shows up in list of available devices: bool selectedWebCamAvailable = false; foreach (WebCamDevice webCamDevice in WebCamTexture.devices) if (webCamDevice.name.Equals(webcamDeviceName)) selectedWebCamAvailable = true; // if it was not found, default to first available camera if (!selectedWebCamAvailable) webcamDeviceName = WebCamTexture.devices[0].name; mWebCamProfile = profiles.GetProfile(webcamDeviceName); // create webcam texture adaptor mWebCamTexture = new WebCamTexAdaptorImpl(webcamDeviceName, mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } else { // no webcam connected, use default profile and null implementation for webcam mWebCamProfile = profiles.Default; // create null webcam implementation mWebCamTexture = new NullWebCamTexAdaptor(mWebCamProfile.RequestedFPS, mWebCamProfile.RequestedTextureSize); } // override the texture created by the the VideoTextureBehaviour mBgRenderingTexBehaviour.SetFlipHorizontally(flipHorizontally); mFlipHorizontally = flipHorizontally; } #endif }