The post process distortion effect added on the virtual object. Enable/disable this script will turn on/off the distortion effect, leave it to disabled it's distortion is not crucial to your application.
Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    IEnumerator LoadScene()
    {
        if (!GameManager.Instance.resetGame)
        {
            //等待服务器数据到位
            yield return(StartCoroutine(GetGameUserData()));
        }
        else
        {
            //reset game!!
        }
        GamePlayer.Me.Create();
        GamePlayer.Me.instance.SetPlayer(playerBody.transform);
        //加载基础场景
        //生成tango管理器
        ResourcesManager.Instance.LoadGameObject("Prefabs/Tango/Tango Seivice");         //临时代码,这部分以后要变成class create的模式,现在为了便于调试,这个上面起作用的类是tangoserviece
                #if !UNITY_EDITOR
        while (PermissionTango == false)
        {
            yield return(null);
        }
                #endif
        GameObject cloudObj = ResourcesManager.Instance.LoadGameObject("Prefabs/Tango/Tango Point Cloud");         //临时代码,这部分以后要变成class create的模式,现在为了便于调试

        //生成tango镜头
        TangoARPoseController tarPoseCon = Camera.main.gameObject.AddComponent <TangoARPoseController>();
        tarPoseCon.m_useAreaDescriptionPose    = true;
        tarPoseCon.m_syncToARScreen            = true;
        TangoService.Instance.m_poseController = tarPoseCon;

        TangoManager.Instance.m_pointCloud = cloudObj.GetComponent <TangoPointCloud> ();
        TangoManager.Instance.m_pointCloud.m_useAreaDescriptionPose = true;
        //texture Method
        TangoService.Instance.m_tangoApplication.m_videoOverlayUseTextureMethod      = true;
        TangoService.Instance.m_tangoApplication.m_videoOverlayUseYUVTextureIdMethod = false;
        TangoService.Instance.m_tangoApplication.m_videoOverlayUseByteBufferMethod   = false;

                #if UNITY_EDITOR
        TangoService.Instance.m_tangoApplication.m_doSlowEmulation = true;
        //TangoService.Instance.m_tangoApplication.m_emulationEnvironment =
        TangoService.Instance.m_tangoApplication.m_emulationVideoOverlaySimpleLighting = true;
                #endif
        //AreaDescriptions
        TangoService.Instance.m_tangoApplication.m_enableAreaDescriptions = true;
        //mode 2
        TangoService.Instance.m_tangoApplication.m_enableDriftCorrection       = false;
        TangoService.Instance.m_tangoApplication.m_areaDescriptionLearningMode = false;
        TangoARScreen arScreen = Camera.main.gameObject.GetComponent <TangoARScreen> ();
        arScreen.m_occlusionShader = Shader.Find("Tango/PointCloud (Occlusion)");
        ARCameraPostProcess postProcess = Camera.main.gameObject.AddComponent <ARCameraPostProcess> ();
        postProcess.m_postProcessMaterial = ResourcesManager.Instance.LoadAsset <Material> ("Common\\TangoGizmos\\Materials\\ar_post_process");
        postProcess.enabled = false;
        TangoEnvironmentalLighting tel = Camera.main.gameObject.AddComponent <TangoEnvironmentalLighting> ();
        tel.m_enableEnvironmentalLighting = true;

        //OnSceneLoaded();
        UIManager.Instance.Open(UIID.CatHandbook);
        //更新下载状态
        CatSceneManager.Instance.UpdateLoadingState(100, 100);
    }
Ejemplo n.º 2
0
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_camera              = GetComponent <Camera>();
        m_tangoApplication    = FindObjectOfType <TangoApplication>();
        m_arCameraPostProcess = gameObject.GetComponent <ARCameraPostProcess>();

        if (m_tangoApplication != null)
        {
            m_tangoApplication.OnDisplayChanged += _OnDisplayChanged;
            m_tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (m_tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled              = true;
                renderer.material.shader      = m_occlusionShader;
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
 /// <summary>
 /// Unity Start() callback, we set up some initial values here.
 /// </summary>
 public void Start()
 {
     m_currentFPS          = 0;
     m_framesSinceUpdate   = 0;
     m_currentTime         = 0.0f;
     m_fpsText             = "FPS = Calculating";
     m_tangoApplication    = FindObjectOfType <TangoApplication>();
     m_tangoPose           = FindObjectOfType <TangoARPoseController>();
     m_arCameraPostProcess = FindObjectOfType <ARCameraPostProcess>();
     m_tangoServiceVersion = TangoApplication.GetTangoServiceVersion();
 }
 /// <summary>
 /// Update AR screen material with camera texture size data
 /// (and distortion parameters if using distortion post-process filter).
 /// </summary>
 /// <param name="mat">Material to update.</param>
 /// <param name="arPostProcess">ARCameraPostProcess script that handles distortion for this material instance
 /// (null if none).</param>
 /// <param name="intrinsics">Tango camera intrinsics for the color camera.</param>
 private static void _MaterialUpdateForIntrinsics(Material mat, ARCameraPostProcess arPostProcess, TangoCameraIntrinsics intrinsics)
 {
     if (arPostProcess != null)
     {
         // ARCameraPostProcess should take care of setting everything up for all materials involved.
         arPostProcess.SetupIntrinsic(intrinsics, mat);
     }
     else
     {
         // If not handling distortion, all the material needs to know is camera image dimensions.
         mat.SetFloat("_Width", (float)intrinsics.width);
         mat.SetFloat("_Height", (float)intrinsics.height);
     }
 }
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_screenSpaceMesh = new Mesh();
        m_camera          = GetComponent <Camera>();

        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        m_arCameraPostProcess = gameObject.GetComponent <ARCameraPostProcess>();
        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }

            // Pass YUV textures to shader for process.
            YUVTexture textures = tangoApplication.GetVideoOverlayTextureYUV();
            m_screenMaterial.SetTexture("_YTex", textures.m_videoOverlayTextureY);
            m_screenMaterial.SetTexture("_UTex", textures.m_videoOverlayTextureCb);
            m_screenMaterial.SetTexture("_VTex", textures.m_videoOverlayTextureCr);
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled = true;

                // Set the renderpass as background renderqueue's number minus one. YUV2RGB shader executes in
                // Background queue which is 1000.
                // But since we want to write depth data to Z buffer before YUV2RGB shader executes so that YUV2RGB
                // data ignores Ztest from the depth data we set renderqueue of PointCloud as 999.
                renderer.material.renderQueue = BACKGROUND_RENDER_QUEUE - 1;
                renderer.material.SetFloat("point_size", POINTCLOUD_SPLATTER_UPSAMPLE_SIZE);
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
    //Unity Start() callback, we set up some initial values here.
    public void Start()
    {
        m_currentFPS        = 0;
        m_framesSinceUpdate = 0;
        m_currentTime       = 0.0f;
        m_fpsText           = "FPS = Calculating";

        m_tangoApplication    = FindObjectOfType <TangoApplication>();
        m_tangoPose           = FindObjectOfType <TangoARPoseController>();
        m_arCameraPostProcess = FindObjectOfType <ARCameraPostProcess>();
        m_tangoServiceVersion = TangoApplication.GetTangoServiceVersion();


        //show screenshot icon after a screenshot
        screenshotPic = GameObject.Find("screenshotPic");
        this.screenshotPic.SetActive(false);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// Unity Start() callback, we set up some initial values here.
    /// </summary>
    public void Start()
    {
        m_currentFPS          = 0;
        m_framesSinceUpdate   = 0;
        m_currentTime         = 0.0f;
        m_fpsText             = "FPS = Calculating";
        m_tangoApplication    = FindObjectOfType <TangoApplication>();
        m_tangoPose           = FindObjectOfType <TangoARPoseController>();
        m_arCameraPostProcess = FindObjectOfType <ARCameraPostProcess>();
        m_tangoServiceVersion = TangoApplication.GetTangoServiceVersion();

        m_tangoApplication.Register(this);

        #region Cfd
        _cfdManager = new CfdSceneManagerV2();
        _cfdManager.DefaultMaterial     = defaultMaterial;
        _cfdManager.VertexColorMaterial = vertexColorMaterial;
        _cfdManager.CfdShader           = shader;
        _cfdManager.Start();
        #endregion
    }
Ejemplo n.º 8
0
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_camera = GetComponent <Camera>();

        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        tangoApplication.OnDisplayChanged += _OnDisplayChanged;
        m_arCameraPostProcess              = gameObject.GetComponent <ARCameraPostProcess>();
        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }

            CommandBuffer buf = VideoOverlayProvider.CreateARScreenCommandBuffer();
            m_camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, buf);
            m_camera.AddCommandBuffer(CameraEvent.BeforeGBuffer, buf);
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled              = true;
                renderer.material.shader      = m_occlusionShader;
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        m_arCameraPostProcess = gameObject.GetComponent<ARCameraPostProcess>();
        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);

            // Pass YUV textures to shader for process.
            m_textures = m_tangoApplication.GetVideoOverlayTextureYUV();
            m_screenMaterial.SetTexture("_YTex", m_textures.m_videoOverlayTextureY);
            m_screenMaterial.SetTexture("_UTex", m_textures.m_videoOverlayTextureCb);
            m_screenMaterial.SetTexture("_VTex", m_textures.m_videoOverlayTextureCr);
        }

        if (m_enableOcclusion) 
        {
            TangoPointCloud pointCloud = FindObjectOfType<TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent<Renderer>();
                renderer.enabled = true;

                // Set the renderpass as background renderqueue's number minus one. YUV2RGB shader executes in 
                // Background queue which is 1000.
                // But since we want to write depth data to Z buffer before YUV2RGB shader executes so that YUV2RGB 
                // data ignores Ztest from the depth data we set renderqueue of PointCloud as 999.
                renderer.material.renderQueue = BACKGROUND_RENDER_QUEUE - 1;
                renderer.material.SetFloat("point_size", POINTCLOUD_SPLATTER_UPSAMPLE_SIZE);
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Unity Start() callback, we set up some initial values here.
    /// </summary>
    public void Start()
    {
        m_currentFPS = 0;
        m_framesSinceUpdate = 0;
        m_currentTime = 0.0f;
        m_fpsText = "FPS = Calculating";
        m_tangoApplication = FindObjectOfType<TangoApplication>();
        m_tangoPose = FindObjectOfType<TangoARPoseController>();
        m_arCameraPostProcess = FindObjectOfType<ARCameraPostProcess>();
        m_tangoServiceVersion = TangoApplication.GetTangoServiceVersion();

        m_tangoApplication.Register(this);
    }
Ejemplo n.º 11
0
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_camera = GetComponent<Camera>();

        TangoApplication tangoApplication = FindObjectOfType<TangoApplication>();
        tangoApplication.OnDisplayChanged += _OnDisplayChanged;
        m_arCameraPostProcess = gameObject.GetComponent<ARCameraPostProcess>();
        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }

            CommandBuffer buf = VideoOverlayProvider.CreateARScreenCommandBuffer();
            m_camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, buf);
            m_camera.AddCommandBuffer(CameraEvent.BeforeGBuffer, buf);
        }

        if (m_enableOcclusion) 
        {
            TangoPointCloud pointCloud = FindObjectOfType<TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent<Renderer>();
                renderer.enabled = true;
                renderer.material.shader = m_occlusionShader;
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }