private IEnumerator Start()
        {
            SetUnityStreamingAssetsPath(Application.streamingAssetsPath);

            int textureHeight, textureWidth;

            //if (Meta.Internal.HandPhysics.CppMetaPhysicsManager.Instance.usePMD)      // Disabled for use with prototyping physics simulation
            if (usePMD)
            {
                currentNativeTexture = pmdPointCloudTexture;
                textureHeight        = 224;
                textureWidth         = 171;
            }
            else
            {
                currentNativeTexture = depthPointCloudTexture;
                textureHeight        = 320;
                textureWidth         = 240;
            }
            currentNativeTexture.CreateTextureAndPassToPlugin(textureHeight, textureWidth);

            width  = (uint)textureHeight;
            height = (uint)textureWidth;

            // create a list to hold the game objects
            meshObjects = new List <GameObject>();

            // attach the meshes to the game objects.
            CreateGameObjects();

            ApplyTexture(currentNativeTexture);

            yield return(StartCoroutine("CallPluginAtEndOfFrames"));
        }
        /// <summary>
        /// </summary>
        private void ApplyTexture(NativeDepthTextureHandle currentNativeTexture)
        {
            GetComponent <Renderer>().material.SetTexture(_depthShaderProperty, currentNativeTexture.tex);
            GetComponent <MeshRenderer>().material.mainTexture = currentNativeTexture.tex;

            for (int i = 0; i < meshObjects.Count; ++i)
            {
                meshObjects[i].GetComponent <MeshRenderer>().material = GetComponent <Renderer>().material;
            }
        }
예제 #3
0
 /// <summary>   Applies the texture described by currentNativeTexture. </summary>
 /// <param name="currentNativeTexture"> The current native texture handle. </param>
 private void ApplyTexture(NativeDepthTextureHandle currentNativeTexture)
 {
     _depthOcclusionGO.GetComponent <Renderer>().material.SetTexture(_depthTextureShaderProperty, currentNativeTexture.tex);
     _depthOcclusionGO.GetComponent <Renderer>().material.SetFloat(_depthHeightShaderProperty, _sensorMetaData.height);
     _depthOcclusionGO.GetComponent <Renderer>().material.SetFloat(_depthWidthShaderProperty, _sensorMetaData.width);
     _depthOcclusionGO.GetComponent <Renderer>().material.SetFloat(_depthFocalLengthXShaderProperty, _sensorMetaData.focalLengthX);
     _depthOcclusionGO.GetComponent <Renderer>().material.SetFloat(_depthFocalLengthYShaderProperty, _sensorMetaData.focalLengthY);
     _depthOcclusionGO.GetComponent <Renderer>().material.SetFloat(_depthPrincipalPointXShaderProperty, _sensorMetaData.principalPointX);
     _depthOcclusionGO.GetComponent <Renderer>().material.SetFloat(_depthPrincipalPointYShaderProperty, _sensorMetaData.principalPointY);
     _depthOcclusionGO.GetComponent <MeshRenderer>().material.mainTexture = currentNativeTexture.tex;
     for (int i = 0; i < meshObjects.Count; ++i)
     {
         meshObjects[i].GetComponent <MeshRenderer>().material = _depthOcclusionGO.GetComponent <Renderer>().material;
         meshObjects[i].GetComponent <MeshRenderer>().enabled  = false;
     }
     _meshesDisabled = true;
 }