void Start() { m_depthManager = Application.Instance.KinectDepthManager; m_frameManager = Application.Instance.KinectFrameManager; m_meshCollider = GetComponent <MeshCollider>(); float depthAspect = m_frameManager.DepthWidthDownsampled / m_frameManager.DepthHeightDownsampled; transform.parent.localPosition = new Vector3(-ReefHelper.DisplayHeight * depthAspect / 2, ReefHelper.DisplayHeight / 2); m_depthManager.OnActivationChanged += (x) => { SetActive(x); }; }
void Start() { m_frameManager = Application.Instance.KinectFrameManager; m_camera = Application.Instance.MainCamera; // downsample to lower resolution m_kinectDepthMesh = new DepthMesh(m_frameManager.DepthWidthDownsampled, m_frameManager.DepthHeightDownsampled); float depthAspect = m_frameManager.DepthWidthDownsampled / m_frameManager.DepthHeightDownsampled; Vector2 meshSize = new Vector2(ReefHelper.DisplayHeight * depthAspect, ReefHelper.DisplayHeight); depthOffset = new Vector3(-ReefHelper.DisplayHeight * depthAspect / 2, ReefHelper.DisplayHeight / 2); m_kinectDepthMesh.SetOffset(new Vector2(0.5f, 0.5f)); m_kinectDepthMesh.Init(meshSize, false); maxDepth = m_frameManager.MaxReliableDistance; worldDepth = Application.Instance.FarClipPlaneDistance * DepthScale / maxDepth; }
void Start() { m_frameManager = Application.Instance.KinectFrameManager; m_depthManager = Application.Instance.KinectDepthManager; m_pRenderer = GetComponent <Renderer>(); m_pMeshFilter = GetComponent <MeshFilter>(); m_camera = Application.Instance.MainCamera; m_pTextureMixMaterial = new Material(Resources.Load("Shaders/KinectDepthColorMixer") as Shader); m_pKinectDepthColorRT = new RenderTexture(m_frameManager.DepthFrameWidth, m_frameManager.DepthFrameHeight, 0, RenderTextureFormat.ARGB32); m_pColorToDepth = new Vector2[m_frameManager.DepthFrameWidth / m_pColorDownsampleSize * m_frameManager.DepthFrameHeight / m_pColorDownsampleSize]; GameObject ob = GameObject.CreatePrimitive(PrimitiveType.Plane); ob.transform.SetParent(m_camera.transform); float depthAspect = m_frameManager.DepthWidthDownsampled / m_frameManager.DepthHeightDownsampled; m_pKinectVideoPlane = ob.AddComponent <VideoPlane>(); m_pKinectVideoPlane.Init(Depth); m_pKinectVideoPlane.SetWidth(ReefHelper.DisplayHeight * depthAspect); m_pKinectVideoPlane.SetVideoTexture(m_pKinectDepthColorRT); m_pTextureMixMaterial.SetTexture("_ColorTex", m_frameManager.GetColorTexture()); m_pTextureMixMaterial.SetTexture("_DepthTex", m_frameManager.GetDepthTexture()); m_pTextureMixMaterial.SetFloat("_DownsampleSize", m_pColorDownsampleSize); ReleaseBuffers(); DepthSpacePoint[] depthPoints = m_frameManager.GetDepthCoordinates(); if (depthPoints != null) { m_pDepthComputeBuffer = new ComputeBuffer(m_frameManager.GetColorSpacePointBuffer().Length, sizeof(float) * 2); m_pTextureMixMaterial.SetBuffer("DepthCoords", m_pDepthComputeBuffer); } m_depthManager.OnActivationChanged += (x) => { SetActive(x); }; }