?不論你是否曾有過相關(guān)經(jīng)驗(yàn),只要跟隨本文的步驟,你就可以成功地創(chuàng)建你自己的AR應(yīng)用。
官方教程Ground Plane in Unity | Vuforia Library
這個(gè)功能很棒,但是要求也很不友好,只能支持部分移動(dòng)設(shè)備,具體清單如下:
01.Vuforia的地面識(shí)別功能僅支持的設(shè)備清單:
?Recommended Devices | Vuforia Library
IOS Devices
Device Name |
Comments |
---|---|
iPhone SE (2nd & 3rd?generation) |
|
iPhone 8, iPhone 8 Plus |
|
iPhone X, iPhone XR, iPhone XS, iPhone XS Max |
|
iPhone 11, iPhone 11 Pro, iPhone 11 Pro Max |
|
iPhone 12 mini, iPhone 12, iPhone 12 Pro, iPhone 12 Pro Max |
The iPhone 12 Pro and iPhone 12 Pro Max support the?Vuforia Creator App |
iPhone 13 mini, iPhone 13, iPhone 13 Pro, iPhone 13 Pro Max | The iPhone 13 Pro and iPhone 13 Pro Max support the?Vuforia Creator App |
iPhone 14, iPhone 14 Plus, iPhone 14 Pro, iPhone 14 Pro Max | The iPhone 14 Pro and iPhone 14 Pro Max support the?Vuforia Creator App |
iPhone 15, iPhone 15 Plus, iPhone 15 Pro, iPhone 15 Pro Max | The iPhone 15 Pro and iPhone 15 Pro Max support the?Vuforia Creator App |
iPad Mini (5th & 6th generation) |
|
iPad Air 3, iPad Air 4, iPad Air 5 |
|
iPad?(5th through 10th generation) | |
iPad Pro iPad Pro 9.7”, iPad Pro 10.5”, iPad Pro 11” (1st through 4th generation), iPad Pro 12.9” (3rd?through 6th generation) |
The iPad Pro 11” (through 4th generation) and iPad Pro 12.9” (3rd through 6th?generation) support the?Vuforia Creator App |
Android Devices
Device Name |
Comments |
---|---|
Samsung Galaxy A20e SM-A202F, SM-A202K |
|
Samsung Galaxy A32 SM-A325F, SM-A325M, SM-A325N |
|
Samsung Galaxy A52s 5G SM-A528B, SM-A528N |
|
Samsung Galaxy S10e |
|
Samsung Galaxy S10/S10 5G |
|
Samsung Galaxy S10+ |
|
Samsung Galaxy S21/S21 5G SM-G991B, SM-G991N, SM-G991U, SM-G991U1, SM-G991W, SM-G9910 |
|
Samsung Galaxy S21+ SM-G996B, SM-G996N, SM-G996U, SM-G996U1, SM-G996W, SM-G9960 |
|
Samsung Galaxy S21 Ultra SM-G998B, SM-G998N, SM-G998U, SM-G998U1, SM-G998W, SM-G9980 |
|
Samsung Galaxy S22 SM-S901B, SM-S901E, SM-S901N, SM-S901U, SM-S901U1, SM-S901W, SM-S9010 |
|
Samsung Galaxy S22+ SM-S906B, SM-S906E, SM-S906N, SM-S906U, SM-S906U1, SM-S906W, SM-S9060 |
|
Samsung Galaxy S22 Ultra SM-S908B, SM-S908E, SM-S908N, SM-S908U, SM-S908U1, SM-S908W, SM-S9080 |
|
Samsung Galaxy S23 SM-S9110, SM-S911B, SM-S911N, SM-S911U, SM-S911U1, SM-S911W |
|
Samsung Galaxy S23+ SM-S9160, SM-S916B, SM-S916N, SM-S916U, SM-S916U1, SM-S916W |
|
Samsung Galaxy S23 Ultra SM-S9180, SM-S918B, SM-S918N, SM-S918U, SM-S918U1, SM-S918W |
|
Samsung Galaxy Tab S5e SM-T720, SM-T725, SM-T725C, SM-T725N |
|
Samsung Galaxy Tab S6 Lite SM-P610, SM-P615 |
|
Galaxy Tab S7/S7 5G SM-T870, SM-T875, SM-T875N, SM-T878U |
|
Galaxy Tab S7 Plus SM-T970, SM-T975, SM-T976B |
|
Galaxy Tab S8/S8 5G SM-X700, SM-X706 |
|
Galaxy Tab S8 Plus/S8 Plus 5G SM-X800, SM-X806 |
|
Galaxy Tab S8 Ultra/S8 Ultra 5G SM-X900, SM-X906 |
|
Google Pixel 5/5a 5G | |
Google Pixel 6/6a/6 Pro | |
Google Pixel 7/7a/7 Pro |
UWP Devices
Device Name |
Comments |
---|---|
Microsoft Surface Surface Pro 8, Surface Pro X, Surface Pro 7, Surface Pro 6, Surface Go, Surface Go 2 |
Eyewear Devices
Device Name |
Comments |
---|---|
Microsoft HoloLens 2 |
All features supported except for Ground Plane. For equivalent functionality, please use SDK provided by OEM. Area Target Capture API is not supported on this platform. *HoloLens 1 is no longer supported by Vuforia Engine 10.9+ |
Magic Leap Magic Leap 2 |
All features supported except for Ground Plane. For equivalent functionality, please use SDK provided by OEM. Area Target Capture API is not supported on this platform. *Magic Leap 1 is no longer supported by Vuforia Engine 10.10+ |
Vuzix M400 |
Supported features:?ImageTargets,?CylinderTarget,?Multi Targets,?VuMark. Extended Tracking not supported (no?Device Tracking). |
RealWear HMT-1, HMT-1Z1 |
Supported features:?ImageTargets,?CylinderTarget,?Multi Targets,?VuMark. Extended Tracking not supported (no?Device Tracking). |
02.平面識(shí)別的目的意義:
實(shí)現(xiàn)自動(dòng)識(shí)別環(huán)境空間的平面,然后便于后續(xù)業(yè)務(wù)邏輯的實(shí)現(xiàn),例如拖拽模型到地面、平面,打乒乓球等,類似pokemon GO游戲
?03.實(shí)現(xiàn)步驟
確保你安裝了Vuforia 的SDK在Unity 中,具體請(qǐng)看【Vuforia+Unity】AR01實(shí)現(xiàn)單張多張圖片識(shí)別產(chǎn)生對(duì)應(yīng)數(shù)字內(nèi)容-CSDN博客
?然后我們可以自己搭建,也可以直接基于官方示例搭建!
3.1自己搭建
01首先創(chuàng)建三樣?xùn)|西
這個(gè)類型需要三個(gè)東西:ARcamera,Ground Plane Stage,還有Plane Finder
創(chuàng)建一個(gè)帶有Vuforia插件普通空項(xiàng)目,創(chuàng)建一個(gè)ARcamera,創(chuàng)建一個(gè)Ground Plane Stage,創(chuàng)建一個(gè)Plane Finder
02 把識(shí)別平面后要放在平面上的數(shù)字內(nèi)容模型,放在Ground Plane Stage下
接下來你需要把你所想要展現(xiàn)的場(chǎng)景和物品拖到Ground Plane Stage下
最簡(jiǎn)單的地面識(shí)別已經(jīng)搭建完成!需要其他功能,請(qǐng)?jiān)诖嘶A(chǔ)上繼續(xù)開發(fā)!比如觸發(fā)回調(diào),地面被識(shí)別時(shí)、物體被放置時(shí)等等!
OVER !
3.2 直接用官方案例即可
vuforia - Asset Store (unity.com)傳送門
官方還贈(zèng)送了一個(gè)腳本,這個(gè)腳本在Plane Finder的"Content Positioning Behaviour"腳本中被回調(diào):
意思是,當(dāng)物體被放置在平面上后調(diào)用"Product Placement"腳本中物體的旋轉(zhuǎn)功能函數(shù)
?ProductPlacement 這個(gè)物體身上腳本的理解:
腳本:"Product Placement"(產(chǎn)品放置)和"Touch Handler"(觸摸處理)。
"Product Placement"腳本有以下字段:
- Augmentation Object(增強(qiáng)對(duì)象):"Chair"(椅子)和"Chair Shadow"(椅子陰影)被分配到這個(gè)字段。
- Control Indicators(控制指示器):此處引用了"Translation Indicator"(平移指示器)和"Rotation Indicator"(旋轉(zhuǎn)指示器)。
- Augmentation Size(增強(qiáng)大小):這是一個(gè)滑動(dòng)條,"Product Size"(產(chǎn)品大?。┑闹禐?.65。
"Touch Handler"腳本有以下字段:
- Augmentation Object(增強(qiáng)對(duì)象):"Chair (Transform)"(椅子(變換))被分配到這個(gè)字段。
- Enable Pinch Scaling(啟用捏合縮放):這是一個(gè)復(fù)選框,目前處于未選中狀態(tài)。
總的來說,這個(gè)設(shè)置似乎是用于控制在場(chǎng)景中的增強(qiáng)現(xiàn)實(shí)對(duì)象(椅子)的放置和縮放(使用觸摸手勢(shì))。"Translation Indicator"(平移指示器)和"Rotation Indicator"(旋轉(zhuǎn)指示器)可能是用戶操作對(duì)象的視覺提示。
04? 相關(guān)設(shè)置和深入理解
首先是Plane Finder,這個(gè)是識(shí)別地面的主要組件,他身上有3個(gè)腳本組件
?Plane Finder三個(gè)腳本的理解(這部分可以跳過,僅供查閱)
Anchor Input Listener Behaviour(腳本)
用來返回?cái)z像機(jī)射線射擊到的平面,被用來確定用戶觸摸或點(diǎn)擊檢測(cè)到的平面上的點(diǎn)
Plane Finder Behaviour(腳本):
此組件負(fù)責(zé)在實(shí)際環(huán)境中尋找平面。其模式被設(shè)置為"AUTOMATIC",這意味著它將無需用戶交互地持續(xù)嘗試尋找平面。"Plane indicator"屬性是一個(gè)自定義的可視元素,用于顯示檢測(cè)到平面的位置。此外,這個(gè)組件處理兩種hit測(cè)試:
Interactive Hit Test:它接受來自"ContentPositioningBehaviour"的代理函數(shù)"PositionContentAtPlaneAnchor",可能被用來在用戶與其交互時(shí),將內(nèi)容放置在平面上的特定點(diǎn)。
Automatic Hit Test:它接受來自"ProductPlacement"的代理函數(shù)"OnAutomaticHitTest",這可能被用來無需用戶交互就能自動(dòng)在檢測(cè)到的平面上放置產(chǎn)品或物體。
"Content Positioning Behaviour"腳本組件
腳本是Vuforia引擎中的一個(gè)組件,主要負(fù)責(zé)在增強(qiáng)現(xiàn)實(shí)(AR)環(huán)境中定位和放置內(nèi)容。這個(gè)腳本通常與"Plane Finder"組件一起使用,以在實(shí)際的環(huán)境平面(如桌面或地面)上定位和放置虛擬對(duì)象。
主要特性包括:
-
定位和放置:當(dāng)用戶選擇一個(gè)位置(通常是通過觸摸屏幕來選擇),該腳本會(huì)在那個(gè)位置創(chuàng)建一個(gè)錨點(diǎn),并將相關(guān)的虛擬內(nèi)容放置在那里。這個(gè)過程通常被稱為"hit testing"。
-
轉(zhuǎn)換:一旦虛擬內(nèi)容被放置,用戶可以通過手勢(shì)來移動(dòng)和旋轉(zhuǎn)它。
-
錨點(diǎn):為了保持虛擬內(nèi)容的穩(wěn)定性,該腳本使用了所謂的"錨點(diǎn)"。錨點(diǎn)是AR系統(tǒng)用來確保虛擬內(nèi)容保持在正確位置的一種工具,即使設(shè)備的相機(jī)移動(dòng)或旋轉(zhuǎn)。這個(gè)錨點(diǎn)自動(dòng)添加,當(dāng)我們創(chuàng)建了Ground Plane Stage
總的來說,"Content Positioning Behaviour"腳本在AR應(yīng)用中起著非常重要的作用,它使得虛擬內(nèi)容能夠以一種直觀和穩(wěn)定的方式放置和交互在真實(shí)世界中。
在這個(gè)腳本下面有個(gè)高級(jí)選項(xiàng),里面是當(dāng)平面被識(shí)別后,數(shù)字內(nèi)容被用戶放在平面上后就會(huì)觸發(fā)
"on Content Placed(Gameobject)" 是一個(gè)事件,這個(gè)事件將在內(nèi)容(即GameObject)被放置在場(chǎng)景中時(shí)觸發(fā)。你可以在這個(gè)事件中添加方法,當(dāng)事件觸發(fā)時(shí),這些方法會(huì)被自動(dòng)執(zhí)行。
舉個(gè)例子,如果你創(chuàng)建了一個(gè)AR應(yīng)用,并且用戶可以在實(shí)際環(huán)境中放置虛擬物體,那么當(dāng)用戶放置這些虛擬物體時(shí),“on Content Placed(Gameobject)" 就會(huì)被觸發(fā)。在這個(gè)事件里,你可能會(huì)加入一些自定義的行為或者效果,比如播放一個(gè)聲音或動(dòng)畫,來告訴用戶虛擬物體已經(jīng)成功被放置。
你可以通過點(diǎn)擊 "+" 按鈕來添加自定義的方法,也可以通過 "-" 按鈕來刪除已經(jīng)添加的方法。這個(gè)事件的功能十分靈活,你可以根據(jù)你自己的需求來定制。
其他相關(guān)博客
關(guān)于自己創(chuàng)建Vuforia地面識(shí)別Demo不如原生樣例(GroundPlane Sample)識(shí)別的好的解決辦法_vuforia平面識(shí)別ground plane-CSDN博客
關(guān)于Vuforia插件(3D物體識(shí)別和地面識(shí)別)的一些測(cè)試記錄_unity vuforia object-CSDN博客文章來源:http://www.zghlxwxcb.cn/news/detail-836875.html
Vuforia的各種Target的簡(jiǎn)單介紹(包括地面識(shí)別)_ar中的target是什么-CSDN博客文章來源地址http://www.zghlxwxcb.cn/news/detail-836875.html
到了這里,關(guān)于【Vuforia+Unity】AR04-地面、桌面平面識(shí)別功能的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!