1. 程式人生 > >AR增強現實

AR增強現實

目錄

1.在untiy安裝路徑下安裝Vuforia Augmented Reality Support(注意此版本要和unity版本相對應,下載連結https://unity3d.com/cn/get-unity/download/archive?_ga=2.257321475.946888592.1538620679-388170339.1536122659)

2.LicenseKey獲取及註冊:https://developer.vuforia.com/targetmanager/licenseManager/licenseListing 

3. ARCamera

4.圖片上傳及簡單識別案例

5.匯入資源(http://www.sikiedu.com/my/course/133/material)

6.製作動畫

7.修改人物的生成

8.生成特效

9.生成陰影

10.未待完續


1.在untiy安裝路徑下安裝Vuforia Augmented Reality Support(注意此版本要和unity版本相對應,下載連結https://unity3d.com/cn/get-unity/download/archive?_ga=2.257321475.946888592.1538620679-388170339.1536122659)

2.LicenseKey獲取及註冊:https://developer.vuforia.com/targetmanager/licenseManager/licenseListing
 

3. ARCamera

4.圖片上傳及簡單識別案例

將生成的安裝包匯入Editor下面

 

5.匯入資源(http://www.sikiedu.com/my/course/133/material

 

6.製作動畫

7.修改人物的生成

       將ImageTarget中的Default Trackable EventHandle 程式碼用 Ctrl+D複製一份並命名為My Default Trackable EventHandle,並更改函式OntrackingFound和OntrackingLost。再用此程式碼替換以前ImageTarget中的Default Trackable EventHandle 程式碼。

  public GameObject aiXiPrefab;
  protected virtual void OnTrackingFound()
    {//找到了需要識別的物體
        GameObject aiXi = Instantiate(aiXiPrefab);
        aiXi.transform.position = transform.position;
        aiXi.transform.parent = transform;
    }
    protected virtual void OnTrackingLost()
    {//丟失了需要識別的物體
        Destroy(GameObject.Find("AiXi(Clone)"));
    }

8.生成特效

    public GameObject aiXiPrefab;
    public GameObject bloodPrefab;
    public GameObject tonadoPrefab;
    protected virtual void OnTrackingFound()
    {//找到了需要識別的物體
        GameObject aiXi = Instantiate(aiXiPrefab);
        aiXi.transform.position = transform.position;
        aiXi.transform.parent = transform;

        GameObject blood = Instantiate(bloodPrefab,transform .position ,Quaternion .identity );
        blood.transform.parent = transform;
        Destroy(blood, 5f);

        GameObject tonado = Instantiate(tonadoPrefab, transform.position, Quaternion.identity);
        tonado.transform.parent = transform;
        Destroy(tonado, 5f);
    }
    protected virtual void OnTrackingLost()
    {//丟失了需要識別的物體
        Destroy(GameObject.Find("AiXi(Clone)"));
        Destroy(GameObject.Find("RFX_Blood_Puddle(Clone)"));
        Destroy(GameObject.Find("RFX_Tonado_Flame(Clone)"));
    }

 

 

9.生成陰影

新建Texture資料夾,並在此資料夾下新建Render Texture並命名為ARShadow

選中MainCamera,點選選單欄GameObject-Align With View

設定層級關係,讓MainCamera只渲染AiXi,不渲染Plane

將ARShadow材質給Plane,調整影子

調整他們之間的關係如下:

10.未完待續