////////////////////////////////////////////////////////////////// // Virtual Camera Overrides ////////////////////////////////////////////////////////////////// public override void SetUp(ZView zView, IntPtr connection, ZView.ModeSetupPhase phase) { switch (phase) { case ZView.ModeSetupPhase.Initialization: this.UpdateImageResolution(zView, connection); break; case ZView.ModeSetupPhase.Completion: // Grab the image dimensions from the connection settings. UInt16 imageWidth = zView.GetSettingUInt16(connection, ZView.SettingKey.ImageWidth); UInt16 imageHeight = zView.GetSettingUInt16(connection, ZView.SettingKey.ImageHeight); // Create the render texture. _renderTexture = new RenderTexture((int)imageWidth, (int)imageHeight, 24, RenderTextureFormat.ARGB32); _renderTexture.filterMode = FilterMode.Point; _renderTexture.name = "RenderTextureStandard"; _renderTexture.Create(); // Cache the render texture's native texture pointer. Per Unity documentation, // calling GetNativeTexturePtr() when using multi-threaded rendering will // synchronize with the rendering thread (which is a slow operation). So, only // call and cache once upon initialization. _nativeTexturePtr = _renderTexture.GetNativeTexturePtr(); break; default: break; } }
////////////////////////////////////////////////////////////////// // Virtual Camera Overrides ////////////////////////////////////////////////////////////////// public override void SetUp(ZView zView, IntPtr connection, ZView.ModeSetupPhase phase) { switch (phase) { case ZView.ModeSetupPhase.Initialization: // Do nothing. break; case ZView.ModeSetupPhase.Completion: // Grab the image dimensions from the connection settings. _imageWidth = zView.GetSettingUInt16(connection, ZView.SettingKey.ImageWidth); _imageHeight = zView.GetSettingUInt16(connection, ZView.SettingKey.ImageHeight); // Create the mask depth render texture (mask only). // NOTE: This is used for both RGB or RGBA overlay. _maskDepthRenderTexture = new RenderTexture((int)_imageWidth, (int)_imageHeight, 24, RenderTextureFormat.ARGB32); _maskDepthRenderTexture.filterMode = FilterMode.Point; _maskDepthRenderTexture.name = "MaskDepthRenderTexture"; _maskDepthRenderTexture.Create(); // Create the non-environment render texture (non-environment objects + mask). // NOTE: For the RGB overlay, this is used to perform a depth render // of the non-environment objects (excluding the mask). For the RGBA overlay, // this is used to render non-environment objects (including the mask depth). _nonEnvironmentRenderTexture = new RenderTexture((int)_imageWidth, (int)_imageHeight, 24, RenderTextureFormat.ARGB32); _nonEnvironmentRenderTexture.filterMode = FilterMode.Point; _nonEnvironmentRenderTexture.name = "NonEnvironmentRenderTexture"; _nonEnvironmentRenderTexture.Create(); // Create the final composite render texture. // NOTE: This is used for both RGB or RGBA overlay. _finalRenderTexture = new RenderTexture((int)_imageWidth, (int)_imageHeight, 24, RenderTextureFormat.ARGB32); _finalRenderTexture.filterMode = FilterMode.Point; _finalRenderTexture.name = "CompositeRenderTexture"; _finalRenderTexture.Create(); // Cache the composite render texture's native texture pointer. Per Unity documentation, // calling GetNativeTexturePtr() when using multi-threaded rendering will // synchronize with the rendering thread (which is a slow operation). So, only // call and cache once upon initialization. _nativeTexturePtr = _finalRenderTexture.GetNativeTexturePtr(); break; default: break; } }
/// <summary> /// Set up the VirtualCamera. /// </summary> /// /// <remarks> /// Performs any setup related operations specific to the mode the /// VirtualCamera is associated with. This method will be called once /// per ModeSetupPhase when the specified connection has transitioned /// to the ConnectionState.ModeSetup state. /// </remarks> /// /// <param name="zView"> /// A reference to the zView API Monobehaviour script. /// </param> /// <param name="connection"> /// The connection to perform the VirtualCamera's setup phase for. /// </param> /// <param name="phase"> /// The mode setup phase for the specified connection. /// </param> public abstract void SetUp(ZView zView, IntPtr connection, ZView.ModeSetupPhase phase);