Cov txheej txheem:

Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau: 8 Kauj Ruam
Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau: 8 Kauj Ruam

Video: Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau: 8 Kauj Ruam

Video: Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau: 8 Kauj Ruam
Video: Boeing, Red 6 to Add Augmented Reality Training on T-7 and F-15EX 2024, Hlis ntuj nqeg
Anonim
Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau
Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau
Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau
Augmented Reality Vuforia 7 Av Tshawb Pom Dav Hlau

Vuforia qhov kev muaj tiag SDK rau Kev Sib Koom 3D siv ARCore thiab ARKit txhawm rau txheeb xyuas dav hlau hauv av. Kev qhia hnub no yuav siv lawv ib txwm koom ua ke hauv Unity los ua AR app rau Android lossis IOS. Peb yuav muaj lub tsheb poob saum ntuj mus rau hauv av, thiab nws lub qhov rooj yuav qhib tau thaum peb los ze. Peb tseem yuav dhau mus ua video hauv AR. Txhawm rau ua raws koj yuav xav tau kev sib sau 3D teeb tsa hauv koj lub computer (nws yog dawb). Cov lus qhia no yog rau tag nrho cov pib tshiab yog li peb yuav hla txhua yam hauv kev nthuav dav!

Qhov zoo tshaj plaws txog Vuforia's SLAM yog qhov nyiaj ntawm IOS thiab Android li uas nws txhawb nqa. Ib daim ntawv teev cov cuab yeej tag nrho tuaj yeem pom ntawm no:

library.vuforia.com/articles/Solution/grou…

Kauj Ruam 1: Pib Txoj Haujlwm Tshiab

Pib Txoj Haujlwm Tshiab
Pib Txoj Haujlwm Tshiab

Rub tawm Unity 3D los ntawm no yog tias koj tsis muaj nws:

Nco ntsoov teeb tsa kev txhawb nqa rau Vuforia Augmented Reality thiab Android lossis IOS nyob ntawm seb koj muaj lub cuab yeej twg.

Qhib Kev Sib Koom thiab pib qhov haujlwm Unity tshiab, hu nws txhua yam koj xav tau.

Ua ntej cia tawm app teeb tsa los tsim tawm yog li peb tsis txhob hnov qab. Yog li, txuag qhov tshwm sim thiab hu nws "tseem ceeb".

Mus rau cov ntawv, tsim chaw, thiab hloov koj lub platform tsim rau Android lossis IOS. Nkag mus rau XR teeb tsa hauv cov neeg ua si teeb tsa thiab kos Vuforia Augmented Reality Supported.

Yog tias koj nyob ntawm Android koj yuav tsis tau ua dab tsi ntxiv, tab sis ntawm IOS mus rau lwm qhov chaw thiab nco ntsoov muab qee yam rau koj tus lej cim. Siv hom ntawv "com. YourCompanyName. YourAppName."

Muab txhua yam rau lub koob yees duab siv kev piav qhia thiab hloov lub hom phiaj yam tsawg kawg tsim qauv kom tsawg kawg 9.0.

Kaw tawm ntawm qhov ntawd thiab tam sim no cia txhua yam ntxiv teeb tsa.

Kauj Ruam 2: Cia Teem Vuforia

Cia Peb Teeb Vuforia
Cia Peb Teeb Vuforia

Tam sim no cia txhua yam teeb tsa.

Mus rau gameobject nyob rau sab saum toj ntawv qhia zaub mov thiab nyem ARCamera. Tam sim no rho tawm lub koob yees duab tseem ceeb ntawm koj qhov xwm txheej.

Xaiv ARCamera thiab ntawm sab xis hauv tus kws tshuaj ntsuam nyem rau Qhib Vuforia Configuration. Nyem rau cov ntaub ntawv khaws tseg thiab txheeb xyuas txhua yam vim tias peb tsis siv cov hom phiaj duab ntawm no.

Nyem rau ntawm lub cuab yeej tracker thiab nyem lub cuab yeej taug qab. Hloov kev taug qab los ntawm kev hloov mus rau qhov chaw.

Tam sim no rov qab mus rau qhov khoom ua si tab thiab nyem Vuforia, Av Dav Hlau, thiab Dav Hlau finder. Qhov no yog cov ntawv sau uas pom peb lub dav hlau hauv av.

Qhov kawg uas peb xav tau yog theem dav hlau hauv av, yog li mus rau qhov khoom ua si ntxiv hauv cov ntawv qhia zaub mov saum toj kawg nkaus, thiab nyem Vuforia, Dav Hlau Hauv Paus, thiab xaiv Hauv Paus Plane Stage. Tam sim no txhua yam uas peb menyuam rau qhov no yuav tshwm nyob rau hauv AR.

Kauj Ruam 3: Ntxiv Tsab Ntawv Tshiab

Ntxiv Tsab Ntawv Tshiab
Ntxiv Tsab Ntawv Tshiab
Ntxiv Tsab Ntawv Tshiab
Ntxiv Tsab Ntawv Tshiab

Kev coj tus cwj pwm tsis zoo ntawm lub dav hlau hauv av nrhiav pom no yog tso ib yam khoom tshiab txhua lub sijhawm koj nias ntawm qhov screen. Dab tsi peb xav tau tsuas yog rov ua lub hom phiaj txhua zaus koj nias ntawm qhov screen. Yog li nyem rau hauv koj cov cuab yeej nplaub tshev thiab tsim tsab ntawv C# tshiab. Hu nws "DeployStageOnce" thiab hloov txhua yam nrog cov cai no:

siv System;

siv UnityEngine; siv Vuforia; pej xeem chav DeployStageOnce: MonoBehaviour {pej xeem GameObject AnchorStage; ntiag tug PositionalDeviceTracker _deviceTracker; ntiag tug GameObject _previousAnchor; pej xeem void Pib () {yog (AnchorStage == null) {Debug. Log ("AnchorStage yuav tsum tau teev"); rov qab; } AnchorStage. SetActive (cuav); } pej xeem tsis muaj dab tsi Awake () {VuforiaARController. Instance. RegisterVuforiaStartedCallback (OnVuforiaStarted); } pej xeem void OnDestroy () {VuforiaARController. Instance. UnregisterVuforiaStartedCallback (OnVuforiaStarted); } ntiag tug void OnVuforiaStarted () {_deviceTracker = TrackerManager. Instance. GetTracker (); } pej xeem void OnInteractiveHitTest (HitTestResult tshwm sim) {yog (qhov tshwm sim == null || AnchorStage == null) {Debug. LogWarning ("Hit test tsis raug lossis AnchorStage tsis teeb tsa"); rov qab; } var anchor = _deviceTracker. CreatePlaneAnchor (Guid. NewGuid (). ToString (), tshwm sim); yog (thauj tog rau nkoj! = null) {AnchorStage.transform.parent = anchor.transform; AnchorStage.transform.localPosition = Vector3.zero; Thauj tog rau nkoj.transform.localRotation = Quaternion.identity; AnchorStage. SetActive (muaj tseeb); } yog (_previousAnchor! = null) {Ua kom puas (_previousAnchor); } _previousAnchor = thauj tog rau nkoj; }}

Txhawm rau kom ntseeg tau tias tsab ntawv no tau siv peb yuav tsum tau hu rau OnInteractiveHitTest () ua haujlwm kom rov qab mus rau Kev Sib Koom thiab nyem lub dav hlau finder game yam khoom. Hloov hom los ntawm Tsis Siv Neeg rau Sib Tham. Luag tsab ntawv peb nyuam qhuav ua rau lub dav hlau finder cov khoom ua si. Tshem tawm tsab ntawv ContentPositioningBehavior. Koj yuav pom qhov chaw rau qhov khoom ua si ntawm DeployStageOnce tsab ntawv, rub lub dav hlau nrhiav mus rau hauv, thiab pom cov ntawv no, xaiv OnInteractiveHitTest ua haujlwm los ntawm sab saum toj ntawm daim ntawv. Tam sim no peb txoj haujlwm yuav raug hu thaum twg tus neeg siv nyem rau ntawm qhov screen!

Kauj Ruam 4: Cia Peb Ntxiv Tsheb

Cia Peb Ntxiv Tsheb
Cia Peb Ntxiv Tsheb

Rub tawm lub tsheb dawb 3D qauv ntawm no (Nco ntsoov kom tau txais.obj version):

www.turbosquid.com/3d-models/max-exterior-…

Tsis tas li, rub lub suab no vim tias peb tab tom yuav ua nws thaum lub tsheb tsoo hauv av:

freesound.org/people/PaulMorek/sounds/1967…

Unzip ob qho ntawm cov ntaub ntawv thiab rub lawv mus rau hauv koj cov khoom muaj nqis.

Nyem rau ntawm lub tsheb thiab saib mus rau sab xis, hloov Siv Cov Khoom Siv Nkag Mus Siv Cov Khoom Siv Sab Nraud (Txoj Cai) los ntawm cov ntawv qhia zaub mov nco rau saum. Tam sim no peb yuav tuaj yeem hloov xim ntawm txhua yam khoom siv hauv tsheb.

Luag lub tsheb mus rau theem dav hlau hauv av ua rau nws yog menyuam yaus. Hloov qhov teev rau.035 ntawm x, y, thiab z.

Tam sim no hla dhau txhua lub tsheb me nyuam cov khoom ua si thiab hloov lawv cov ntaub ntawv rau xim twg koj xav tau.

Ntxiv lub cev tiv thaiv nruj rau lub tsheb lub hauv paus cov khoom ua si thiab tseem ntxiv lub thawv sib tsoo, ntsuas nws kom nws npog tag nrho lub tsheb. Tsis tas li ntxiv lub thawv sib tsoo rau theem dav hlau hauv av thiab ntsuas nws yog li nws ob peb zaug dav dua li theem dav hlau hauv av. Txoj kev no peb tuaj yeem tso lub tsheb tawm saum ntuj thiab nws yuav tsoo hauv av siv kev sib sau ua ke hauv lub tshuab physics.

Kauj Ruam 5: Muab Lub Tsheb Mus Rau Ntuj

Muab tsheb tso rau saum Ntuj
Muab tsheb tso rau saum Ntuj

Ntxiv cov khoom siv hluav taws xob rau lub tsheb lub hauv paus cov khoom ua si, rub lub tsheb sib tsoo lub suab rau hauv nws lub suab kaw.

Tam sim no peb yuav tsum ua tsab ntawv uas yuav tso lub tsheb mus rau saum huab cua thaum tus neeg siv nias ntawm lub vijtsam thiab tom qab ntawd ua suab nrov nrov thaum lub tsheb tsoo hauv av. Yog li, nyem rau hauv cov cuab yeej nplaub tshev thiab tsim tsab ntawv C# tshiab thiab hu nws "CarController."

Hloov tag nrho cov cai nyob ntawd nrog qhov no:

siv System. Collections;

siv System. Collections. Generic; siv UnityEngine; pej xeem chav CarController: MonoBehaviour {ntiag tug bool soundPlayed = tsis tseeb; // Hloov tshiab yog hu ua ib zaug ib zaug tsis muaj qhov hloov tshiab () {yog (! SoundPlayed && transform.localPosition.y <.05f) {soundPlayed = true; StartCoroutine (DelayPlaySound ()); }} pej xeem void MoveCar () {transform.localPosition += tshiab Vector3 (0, 10, 0); transform.eulerAngles += tshiab Vector3 (5, 20, 5); soundPlayed = tsis tseeb; } IEnumerator DelayPlaySound () {yield return new WaitForSeconds (.2f); GetComponent (). Play (); }}

Ntxiv MoveCar ua haujlwm rau OnInteractiveHitTest kev tshwm sim zoo li hauv daim duab saum toj no. Tam sim no nws yuav raug hu thaum tus neeg siv nyem rau ntawm qhov screen.

Kauj Ruam 6: Lambo Qhov Rooj

Lambo Qhov Rooj
Lambo Qhov Rooj

Yog li yog tias koj nthuav lub tsheb cov khoom ua si thiab pom lub qhov rooj, koj yuav pom tias ob lub qhov rooj yog ib lub qhov ntxaij. Yog tias peb xav qhib qhov rooj peb qhov kev xaiv tsuas yog yuav yog Lambo qhov rooj uas qhib ntsug. Txhawm rau ua txoj haujlwm no peb yuav tsum xub hloov lawv cov pivot.

Ua qhov khoom ua si khoob uas yog menyuam yaus ntawm lub tsheb. Luag lub qhov rooj nkag thiab ua rau lawv yog menyuam yaus ntawm qhov khoom ua si tshiab no. Tsiv tus niam txiv qhov khoom ua si mus rau qhov chaw pivot yuav tsum yog, ntawm lub qhov rooj. Tam sim no txav tus menyuam lub qhov rooj rov mus rau qhov chaw. Tam sim no thaum peb tig lub qhov rooj niam txiv, lub ntsiab lus piv rau qhov chaw raug.

Peb tab tom ua tsab ntawv uas qhib lub qhov rooj thaum koj los ze rau lub tsheb tab sis ua ntej peb ua qhov ntawd peb xav tau ib txoj hauv kev "ua rau" qhov xwm txheej. Ntxiv ib lub thawv sib tsoo rau koj lub qhov rooj niam txiv qhov khoom ua si thiab ntsuas nws kom nws mus rau txoj kev me me hla lub tsheb hauv ob qho kev qhia. Kos "isTrigger". Tam sim no ntxiv lub thawv sib tsoo rau lub koob yees duab tseem ceeb thiab ntsuas kom tsim nyog. Kuj xyuas "isTrigger". Ntxiv Rigid Body tivthaiv rau koj lub koob yees duab thiab tsis khij "useGravity". Nrog koj lub koob yees duab xaiv, hloov nws daim ntawv rau "MainCamera" nyob rau sab saum toj ntawm tus kws tshuaj xyuas.

Ntxiv tsab ntawv tshiab hu ua "LamboDoorBehavior" thiab ntxiv cov cai hauv qab no. Luag tsab ntawv mus rau koj lub qhov rooj niam txiv.

siv System. Collections;

siv System. Collections. Generic; siv UnityEngine; pej xeem chav LamboDoorBehavior: MonoBehaviour {ntiag ntab currAngle = 0; ntiag tug ntab DesireAngle = 0; // Hloov tshiab yog hu ua ib zaug ib zaug tsis muaj qhov hloov tshiab () {currAngle = Mathf. LerpAngle (currAngle, DesireAngle, Time.deltaTime * 3f); transform.localEulerAngles = tshiab Vector3 (currAngle, 0, 0); } pej xeem tsis muaj dab tsi OpenDoors () {wantedAngle = 60f; } pej xeem void CloseDoors () {DesAngle = 0; } void OnTriggerEnter (Collider col) {if (col. CompareTag ("MainCamera")) {OpenDoors (); }} void OnTriggerExit (Collider col) {yog (col. CompareTag ("MainCamera")) {CloseDoors (); }}}

Tsab ntawv no yuav ua rau koj lub qhov rooj qhib qeeb thaum koj kaw lawv hauv AR los ntawm kev siv Lerp () ua haujlwm hauv kev sib koom ua ke uas cuam tshuam ntawm ob lub ntsiab lus (lossis hauv qhov no ob lub kaum).

Kauj Ruam 7: Ua yeeb yaj kiab hauv AR

Ua si Video hauv AR
Ua si Video hauv AR
Ua si Video hauv AR
Ua si Video hauv AR

Qhov kawg peb yuav tsum tau ua yog tau txais cov vis dis aus ua si hauv AR.

Txoj cai nyem rau ntawm ib qho khoom ua si uas yog menyuam yaus ntawm koj lub tsheb thiab tsim cov khoom 3D, Quad. Qhov no yuav ua kom ntseeg tau tias lub quad yog menyuam ntawm koj lub tsheb. Txoj hauj lwm thiab hloov kho qhov quad no xws li nws haum rau sab hauv ntawm koj lub tsheb thiab zoo li nws yuav tsum nyob ntawd. Nov yog qhov peb yuav ua cov vis dis aus rau.

Ntxiv ib qho video player tivthaiv rau koj plaub. Hloov qhov chaw mus rau URL thiab nrhiav qhov txuas nyuaj mus rau. MP4 cov ntaub ntawv lossis rub cov vis dis aus tso rau hauv koj cov khoom ntiag tug thiab tom qab ntawd rub qhov clip rau hauv qhov khoob. Yog tias koj xav tau kwj hauv cov vis dis aus los ntawm URL, Instragram yog qhov zoo. Txoj cai nyem rau ntawm Instagram video hauv Google Chrome thiab nyem tshuaj xyuas. Nrhiav qhov faib uas muaj cov vis dis aus thiab luam qhov txuas los ntawm qhov ntawd (Kuv muaj txoj hauv kev no kos duab saum toj no).

Nco ntsoov xyuas lub voj yog tias koj xav kom nws ua si ntau dua ib zaug. Ntxiv cov khoom siv hluav taws xob rau cov khoom ua si no thiab hloov pauv qhov tso tawm mus rau lub hauv paus ntawm cov vis dis aus. Luag hauv koj lub suab tsim tshiab los rau hauv qhov ntawd.

Thaum kawg peb tau ua tiav!

Kauj Ruam 8: Tso App rau Koj Lub Xov Tooj

Tso App rau Koj Lub Xov Tooj!
Tso App rau Koj Lub Xov Tooj!

Yog tias koj tab tom tsim rau Android koj tuaj yeem tsuas yog mus ua ntaub ntawv thiab ntaus tsim thiab khiav nrog koj lub xov tooj ntsaws.

Yog tias koj tab tom tsim tawm rau iPhone lossis iPad, nco ntsoov rub Xcode los ntawm lub khw app. Tsis tas li, sau npe rau tus lej tsim dawb kua los ntawm www.apple.developer.com. Mus rau cov ntawv thiab ntaus tsim. Qhib cov ntawv uas tau tsim los ntawm Xcode thiab ntsaws rau hauv koj lub xov tooj. Xaiv koj pab pawg txhim kho thiab ntaus lub pob ua si.

Koj yuav tsum tau txav lub koob yees duab ib puag ncig me ntsis tab sis muab nws thib ob thiab coj mus rhaub qhov screen thiab koj yuav tsum pom koj lub tsheb poob saum ntuj mus rau hauv av! Tam sim no koj tuaj yeem taug kev sab hauv thiab saib koj cov vis dis aus ua si hauv lub dashboard!

Muaj kev lom zem thiab qhia rau kuv paub yog tias koj muaj lus nug hauv cov lus!

Pom zoo: