// wait for the first web cam frame to set config structs with correct size values // (mWebCamTexture.width and height are set to default values before the first frame is captured) public void Update() { if (!IsTextureSizeAvailable && mWebCamTexture.DidUpdateThisFrame) { QCARRenderer.Vec2I resampledSize = mWebCamProfile.ResampledTextureSize; mVideoModeData = new CameraDevice.VideoModeData { width = resampledSize.x, height = resampledSize.y, frameRate = mWebCamProfile.RequestedFPS // real fps not known, but not used in Unity any way... }; mVideoTextureInfo = new QCARRenderer.VideoTextureInfo { imageSize = resampledSize, textureSize = resampledSize }; mTextureRenderer = new TextureRenderer(mWebCamTexture.Texture, mRenderTextureLayer, resampledSize); mBufferReadTexture = new Texture2D(resampledSize.x, resampledSize.y); mReadPixelsRect = new Rect(0, 0, resampledSize.x, resampledSize.y); IsTextureSizeAvailable = true; } // turn on and off BGRenderingBehaviour depending if Background Rendering has been enabled or not: mBgRenderingTexBehaviour.CheckAndSetActive(QCARRenderer.Instance.DrawVideoBackground); }
internal void Update() { if (QCARRuntimeUtilities.IsPlayMode()) { if (!this.IsTextureSizeAvailable && this.mWebCamTexture.DidUpdateThisFrame) { QCARRenderer.Vec2I resampledTextureSize = this.mWebCamProfile.ResampledTextureSize; CameraDevice.VideoModeData data = new CameraDevice.VideoModeData { width = resampledTextureSize.x, height = resampledTextureSize.y, frameRate = this.mWebCamProfile.RequestedFPS }; this.mVideoModeData = data; QCARRenderer.VideoTextureInfo info = new QCARRenderer.VideoTextureInfo { imageSize = resampledTextureSize, textureSize = resampledTextureSize }; this.mVideoTextureInfo = info; this.mTextureRenderer = new TextureRenderer(this.mWebCamTexture.Texture, this.mRenderTextureLayer, resampledTextureSize); this.mBufferReadTexture = new Texture2D(resampledTextureSize.x, resampledTextureSize.y); this.mReadPixelsRect = new Rect(0f, 0f, (float)resampledTextureSize.x, (float)resampledTextureSize.y); this.IsTextureSizeAvailable = true; } this.mBgRenderingTexBehaviour.CheckAndSetActive(QCARRenderer.Instance.DrawVideoBackground); } }
public override QCARRenderer.VideoTextureInfo GetVideoTextureInfo() { if (QCARRuntimeUtilities.IsPlayMode()) { CameraDeviceImpl instance = (CameraDeviceImpl)CameraDevice.Instance; return(instance.WebCam.GetVideoTextureInfo()); } IntPtr texInfo = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(QCARRenderer.VideoTextureInfo))); QCARWrapper.Instance.RendererGetVideoBackgroundTextureInfo(texInfo); QCARRenderer.VideoTextureInfo info = (QCARRenderer.VideoTextureInfo)Marshal.PtrToStructure(texInfo, typeof(QCARRenderer.VideoTextureInfo)); Marshal.FreeHGlobal(texInfo); return(info); }
public void UpdateBehaviour() { if (mVideoBgConfigChanged && QCARRenderer.Instance.IsVideoBackgroundInfoAvailable()) { // reset the video texture: if (mTexture != null) { Destroy(mTexture); } CreateAndSetVideoTexture(); QCARRenderer.VideoTextureInfo texInfo = QCARRenderer.Instance.GetVideoTextureInfo(); // Cache the info: mTextureInfo = QCARRenderer.Instance.GetVideoTextureInfo();; Debug.Log("VideoTextureInfo " + texInfo.textureSize.x + " " + texInfo.textureSize.y + " " + texInfo.imageSize.x + " " + texInfo.imageSize.y); // Create the video mesh MeshFilter meshFilter = GetComponent <MeshFilter>(); if (meshFilter == null) { meshFilter = gameObject.AddComponent <MeshFilter>(); } meshFilter.mesh = CreateVideoMesh(m_NumDivisions, m_NumDivisions); // Position the video mesh PositionVideoMesh(); if (TextureChanged != null) { TextureChanged(); } mVideoBgConfigChanged = false; } }
// Update is called once per frame void Update() { // Setup the geometry and orthographic camera as soon as the video // background info is available. if (QCARRenderer.Instance.IsVideoBackgroundInfoAvailable()) { // Check if we need to update the texture: QCARRenderer.VideoTextureInfo texInfo = QCARRenderer.Instance.GetVideoTextureInfo(); if (!mTextureInfo.imageSize.Equals(texInfo.imageSize) || !mTextureInfo.textureSize.Equals(texInfo.textureSize)) { // Cache the info: mTextureInfo = texInfo; Debug.Log("VideoTextureInfo " + texInfo.textureSize.x + " " + texInfo.textureSize.y + " " + texInfo.imageSize.x + " " + texInfo.imageSize.y); // Create the video mesh MeshFilter meshFilter = GetComponent <MeshFilter>(); if (meshFilter == null) { meshFilter = gameObject.AddComponent <MeshFilter>(); } meshFilter.mesh = CreateVideoMesh(); // Position the video mesh PositionVideoMesh(); } else if (mScreenOrientation != QCARRuntimeUtilities.ScreenOrientation || mScreenWidth != Screen.width || mScreenHeight != Screen.height) { // Position the video mesh PositionVideoMesh(); } } }
private void Update() { if (QCARRenderer.Instance.IsVideoBackgroundInfoAvailable()) { QCARRenderer.VideoTextureInfo videoTextureInfo = QCARRenderer.Instance.GetVideoTextureInfo(); if (!this.mTextureInfo.imageSize.Equals(videoTextureInfo.imageSize) || !this.mTextureInfo.textureSize.Equals(videoTextureInfo.textureSize)) { this.mTextureInfo = videoTextureInfo; Debug.Log(string.Concat(new object[] { "VideoTextureInfo ", videoTextureInfo.textureSize.x, " ", videoTextureInfo.textureSize.y, " ", videoTextureInfo.imageSize.x, " ", videoTextureInfo.imageSize.y })); MeshFilter component = base.GetComponent <MeshFilter>(); if (component == null) { component = base.gameObject.AddComponent <MeshFilter>(); } component.mesh = this.CreateVideoMesh(); this.PositionVideoMesh(); } else if (((this.mScreenOrientation != QCARRuntimeUtilities.ScreenOrientation) || (this.mScreenWidth != Screen.width)) || (this.mScreenHeight != Screen.height)) { this.PositionVideoMesh(); } } }
public void UpdateBehaviour() { if (mVideoBgConfigChanged && QCARRenderer.Instance.IsVideoBackgroundInfoAvailable()) { // reset the video texture: if (mTexture != null) Destroy(mTexture); CreateAndSetVideoTexture(); QCARRenderer.VideoTextureInfo texInfo = QCARRenderer.Instance.GetVideoTextureInfo(); // Cache the info: mTextureInfo = QCARRenderer.Instance.GetVideoTextureInfo(); ; Debug.Log("VideoTextureInfo " + texInfo.textureSize.x + " " + texInfo.textureSize.y + " " + texInfo.imageSize.x + " " + texInfo.imageSize.y); // Create the video mesh MeshFilter meshFilter = GetComponent<MeshFilter>(); if (meshFilter == null) { meshFilter = gameObject.AddComponent<MeshFilter>(); } meshFilter.mesh = CreateVideoMesh(m_NumDivisions, m_NumDivisions); // Position the video mesh PositionVideoMesh(); if (TextureChanged != null) TextureChanged(); mVideoBgConfigChanged = false; } }
// Update is called once per frame void Update() { // Setup the geometry and orthographic camera as soon as the video // background info is available. if (QCARRenderer.Instance.IsVideoBackgroundInfoAvailable()) { // Check if we need to update the texture: QCARRenderer.VideoTextureInfo texInfo = QCARRenderer.Instance.GetVideoTextureInfo(); if (!mTextureInfo.imageSize.Equals(texInfo.imageSize) || !mTextureInfo.textureSize.Equals(texInfo.textureSize)) { // Cache the info: mTextureInfo = texInfo; Debug.Log("VideoTextureInfo " + texInfo.textureSize.x + " " + texInfo.textureSize.y + " " + texInfo.imageSize.x + " " + texInfo.imageSize.y); // Create the video mesh MeshFilter meshFilter = GetComponent<MeshFilter>(); if (meshFilter == null) { meshFilter = gameObject.AddComponent<MeshFilter>(); } meshFilter.mesh = CreateVideoMesh(); // Position the video mesh PositionVideoMesh(); } else if (mScreenOrientation != QCARRuntimeUtilities.ScreenOrientation || mScreenWidth != Screen.width || mScreenHeight != Screen.height) { // Position the video mesh PositionVideoMesh(); } } }
// wait for the first web cam frame to set config structs with correct size values // (mWebCamTexture.width and height are set to default values before the first frame is captured) public void Update() { if (!IsTextureSizeAvailable && mWebCamTexture.DidUpdateThisFrame) { QCARRenderer.Vec2I resampledSize = mWebCamProfile.ResampledTextureSize; mVideoModeData = new CameraDevice.VideoModeData { width = resampledSize.x, height = resampledSize.y, frameRate = mWebCamProfile.RequestedFPS // real fps not known, but not used in Unity any way... }; mVideoTextureInfo = new QCARRenderer.VideoTextureInfo { imageSize = resampledSize, textureSize = resampledSize }; mTextureRenderer = new TextureRenderer(mWebCamTexture.Texture, mRenderTextureLayer, resampledSize); mBufferReadTexture = new Texture2D(resampledSize.x, resampledSize.y); mReadPixelsRect = new Rect(0, 0, resampledSize.x, resampledSize.y); IsTextureSizeAvailable = true; } // turn on and off BGRenderingBehaviour depending if Background Rendering has been enabled or not: mBgRenderingTexBehaviour.CheckAndSetActive(QCARRenderer.Instance.DrawVideoBackground); }