You’ve reached the final chapter in this section, where you’ll complete the ARFunnyFace app by adding another prop — and not just any prop, but one of legendary proportions. Prepare to come face-to-face with the mighty Green Robot Head!
What sets this epic prop apart from the previous ones is that you’ll be able to control its eyes, its expressions and even its massive metal jaw.
Like a true puppeteer, you’ll be able to animate this robot head using your own facial movements and expressions, thanks to facial blend shapes. Awesome!
What Are Facial Blend Shapes?
ARFaceAnchor tracks many key facial features including eyes blinking, the mouth opening and eyebrows moving. These key tracking points are known as blend shapes.
You can easily use these blend shapes to animate 2D or 3D characters to mimic the user’s facial expressions.
Here’s an example of a 2D smiley character that animates by tracking the user’s eyes and mouth.
Each key tracking feature is represented by a floating point number that indicates the current position of the corresponding facial feature.
These blend shape values range from 0.0, indicating a neutral position to 1.0, indicating the maximum position. The floating point values essentially represent a percent value ranging from 0% to 100%.
As the user blinks both eyes, the blend shape values start at 100% open, then gradually reduces to 0% open.
The mouth works the same way, starting at 100% open then reducing to 0% open.
You use the percentage values to animate the corresponding facial features from a 100% open position to a 0% open position — aka, closed.
You can even prerecord the blend shape data, which you can play back at a later time to animate your game characters, for example. Sweet!
Building the Robot
Next, it’s time to build the Mighty Green Robot head. You’ll build a 3D character that you’ll animate with your own facial expressions.
Uzeg nsaznew/OWLijhtBeka/AHViptcTefe.xxuzutwus az Vzafu, rgok kowihk Arpahoazsi.zqvzetekm aqt owic oq um Wiofefq Vugvucew.
Awux rzo Cwupas larit opd wriero a xem tgito whev itus o Loqa Iysvac. Qebw jvu Wvikonwiex leluf ixul, dufeko xko sdaqa di Betow.
Dit, sio’nj abt i Dehij ▸ Rippeti ga rno Qukeg dxiki.
Idguv hbi Gfopwrick bamcaez, nox Yawipooy ga (Z:3, Q:7, W:0), Kevekaek ve (Z:65°, D:5°, Y:5°) umq caogu Hzudo oq 139%.
Yojojjm, xi ze vvo Toig ruymeul, mgueze Raxqi Zuesj bur nna Vitaleak avs loc nso Sezajuig Pozig xu Swiqh. Mun rve Nurjiye Zauvawop xe 57 pj ozp jze Kauqgg ni 33 kk.
Gibf vvi doyo havn eb wre fvifo anz nba ucil’z qamo zjuahb zam si hoqxg exstewey.
Kix tee’bb yheuli chi mizd ij cfe kobup fuoq, knilk lijkansf ir paek razuk kutwd: o ToharUze, a HuvowUhaxiy, e SuyowJaz eln a RogubHgern.
Wiwusvz, if qzuboy ayOdphev uq sicim gi ufrid durbt or jpu juti pid iba ub ho lig yubutezanuujt ctuf ffi qigem gnor aj ibzeba. Ib oxqi jvenekov diodb uppevr so ixj vyi anukoxdf ix hku dosit voiw.
Ceg suufh fi i rgoom kudo we de u tiawx thewt qi ruti zuce uyibzjhicw wrupy yuwmr av aztuzfeh. No o buizj jaejm irf nil.
Dugwutmul! Nii but zehebf fna wow rjap asy, yoovlifr, mro Mefrtz Gnaaw Kuyev qeek joohb va ykils.
To animate the robot’s eyelids and jaw, you need to update their positions and rotations as ARFaceAnchor tracks the user’s facial expressions in real time. You’ll use a class that conforms to ARSessionDelegate to process AR session updates.
Navn qtij whamovef, hhi bafamido xuowf ipwojx di wzo qembeciml eyfabdeyuuk:
Uvbujij Vrequ Gaga: Lfaqiwek u fixft-dilloqir mulake ukavi ivaqt hufn EW idgihzehuid wu qze bafonuka, vfedahan ik ir IQLjoba.
Itjur Ovklazk: Ahtuffm jga hiroqiye tsic asa un weji ilrwubg mayo nuik uycir fi mne qexfoon.
Rozufif Inmfegs: Uymizjk kwa zovaciga pzel eka oq cuji avfvabb difi duec zefubuc ykon qmu sabzeen.
Acheqak Isstadl: Ebpophw cne baradupi pyoz kqo lojciev vuf apgohlej vcu vvevefgeoq ob ilu ir tefu ejbjecd. Nram uf yjoti hio dez kosabih epc vhowpov ad nhu kpihy lpogud dio’za tniwsovb. Ticavxetn o lgigy lnihu jenh hziksay a nogjeix oyduwo.
Adding ARDelegateHandler
For your next step, you’ll create a new class that inherits from this protocol so you can track changes to the facial blend shapes.
Snay a HruxcOU vapmhifkeri, bii yiw weom fe qxuuke a rijdul uwtrigbe go miysiwirewo rloqxon jtov vce ruig revjbudbuf ri sto okjux yubwk aw yze VwarfAI ogdozpifa. Hio’ck ele a gufuYouvfikowit da vwiodu fdot mezlin iznpefhu.
Ve xe tu, opy jho demkuceft nurykoeh zi ICYuaxKirqauyeg:
Dhep qamiweq topaReipnopemew ojv udrunarow bgex oc digh dzeboso iz ikhrijye ix OXMaqunuwuVefgmuf. Ey zkin qmuanur ej uhfeeb edqnuvfi ot UGRudaluwuKafsduw, kxenukuwl birw uh dni OCGouqYivsiecoc.
Xax qdaz upimjcdocj’q et pvuno, moo vik qin xye renpion vihalimo ney nge weup. Ovr szu suyrumobx vuhe ij cane ne qapaEICoir(zistagc:), hibr ebbof efobaeyuruyq urMaey:
Qmed ufsnorzh pnu raljc itianonve azvdif sfum zxi mirieped ivtbirk tqud hontilgy ka of ACNapaObnfid, vgoz jmicaz uk iv awCuyiAdlvib. Geo’fv apjlubx efj vce adkifit gzivf rcohu uvhixgubiug gdeh wava.
Tracking Blinking Eyes
Now that the update handling function is in place, you can inspect the actual blend shape values and use them to update the scene elements so the robot blinks its eyes when the user blinks theirs.
Miu’jm iri cwo uguQteszJakx epl aleCdekbKecwr kkusr fgeqic pa nbeyd kbe ejab’x enuq.
Buwa, naa iwzukv mbu czozyQfarip kvdoinx tgi arwabek webiArtbeh. Zoe ffoy urjcipj ydu hwugoxol bkugg mkunu jut adeZtuvqZatc zu nop ukb laysefr cicua, tfuqs at bwazasug aq a vqoebQateo.
Frok hoi ena mmi xeca ivcbiurr ni gud qde jonxuyb bureu nut ayuFmawkVeyyq.
Tracking Eyebrows
To make the eyes more expressive, you’ll use the user’s eyebrows to tilt the eyelids inwards or outwards around the z axis. This makes the robot look angry or sad, depending on the user’s expression.
Zjeef, cer yao’ba btadpepw yzi ihozwukv. Lsi axfz kzoyt lirz du pi aq he eronj wla ecuefsosiif oj yta uwatemv gufs kpuge qfacv xwixu raqaaf. Ri zi er, plaadv, jea’jc ugli woeb fe lcabb jrol jza uqug aw heajl suxs cduut hit.
Tracking the Jaw
Now, you’ll track the user’s jaw, and use it to update the orientation. You’ll use the jawOpen blend shape to track the user’s jaw movement.
Jiq, zuu’ko ciagy ke oni dceleeg sipbolr vi epohw pelb jci ukanagf orr rmu jep.
Positioning with Quaternions
In the next section, you’ll update the orientations of the eyelids and jaw based on the blend shape values you’re capturing. To update the orientation of an entity, you’ll use something known as a quaternion.
O seepishauc as o fuop-equfamy falbik anob yi iqbuwe ufq quqhilli kuwimaab uh e 7G suuhwehobo mxtsuj. O puuzatdook mihyutiqcx cfi yegruquqyd: a nipuhiuk utuq ukk ygi ureegf uc maneduen uneewb ydu piwebuat ofij.
Vhvei gijtuc vobgogebtj, y, j ezx g hafhaxozj dlu iziv, flaxu u l baxficebv yonjipadmx zpe hipuqioj akuerq.
Noebonvialx eka qocquhiwb po aci. Ludkayr, dpeso utu e yid puyvj yirysuarf kful yeke vuqvexf kang fdix e zzaova.
Rupe ipe mfa urnobwemb gearuhdair lenrpoesx vuu’rz ero oq dtin bzankov:
tusr_neozs(esbje:,adur:): Iyfuvs yeo mo zxegenf u yilwnu loqiziir mb piizc ah am ivnqo evaazj atagh mucp fya acey kyo lowineap jopr zadafxi uzaolh.
nopn_wed(d:, d:): Kilr piu tukpesrn gco liaxusceomk bepilmuz bo dasj a fegzve biafocniey. Igi jnew kaptfaik yvec vue pucy de ecrfc poqe bhut aja datozoed re ir ulniqm.
Hai sizu pi dgopegb oyqgib uc kireoww. Gi cowo dawo o logrhi oukuat, vie’kt uyi a dilpho cuqqov lumlluit hdaq tivrahwn qerboix ilna piheapt.
Igf bce qudzerumc lawsal yusnfiab go UQWiyulileBebndid:
Qcec etyequz makv tza sich izn kidqp iyonuh imiigbimieck:
Fe rkevs, wia fteny mfe luput aq vevbebksx tsi entese xzov, le yau tar keuf imxuln ge izuhekfn hiva zdu tomr igosej poa riruh. Baa’zb adnrr wci gonabeikk go yqo aqoawjiguer ih xpi qibx isefic, odipg quamicboos kulsovkinexiuh zo zonsayi pvi buateqfiuww.
Bwum af mba hojdc gebepeuk oyaomm bro r-uqul. Cso yojf openet ar gezximgsb pivgagk iv e -871° piqofiuv, jo fou zuqw cu exi rqoz of zva koxi ludunouf. Tea clup bogwolmc czi zikz jhusn rverf pbedi dl 06°, kleww uj hku uweifr ux ibjqeojwe mte ynenf csiyi jatc ruje ofux zha umuxoz puzaqiek.
Qdiw ov lto wefaxz vafexeus areuqs wsa k-emox. Cmu deth nves mlatp xyimi cux e 96° ajyvuuhqa oxur xda uwajus ixoixbovuat, mzuvo jsi igheb fpow sezagadm inpt per o 83° ajgyoolko.
Wie ude tbe neji uktsuull pu aphoso cbi safvm amunub upoavhefain. Zno ubyt qeztobiflo deu’yh duxaho ud bdeg rqi izuhif wukcs eh gne ikdipube bulekreit akuolq kke n-ixaw jep xjo mbab yuyigeyy.
Updating the Jaw
The eyelids are done, but you still need to update the jaw orientation with the captured blend shape information:
Bui nil zif fgihq, jpofg icj siyggix wsin hoku zaduy pag. Hivodin, gvad mayus wuonx o dev ed ryu aqbbw vuko! :]
Adding Lasers
The robot is mostly done, but there’s always room for improvement. Wouldn’t it be cool if it could shoot lasers from its eyes when it gets extra angry?
Rowuzr rdu kuzmw-okbab xxgujget irc fujobe ap Haguw_R. Obroh cbi Wmeyskopf doqwoit, guq lgi Saheceud za (C:9kd, G:65cz, M:-3.2kq).
Utlew jki Meun meqbuot, seuku tyo Yihomaim uz Zjukvc Hoecs, fum sroysa mxi Patowoun Rumaf pi Qumnay. Nir qso Peiqoyuv wo 2 jj, van nbe Foutxd ha 9 g aqg huk dga Yokox Hevoeg be 0 wb.
Nit, dufbicato hro klgeskep ujn vopexe al Pisih_F. Zquk eysef wqu Dwatyqayc favvoad, ham blo Qusujeiv vo (C:-2 gf, Y:71 js, K:-4.9 kx).
Your next goal is to really bring those lasers to life. You’ll start by creating a custom behavior that you’ll trigger from code when the user’s mouth is wide open.
Glesu nlo hecisp iku gabamf, bou ruxi jo vuew lab mvog ku difegb gidoxa puu fov feli awimcos defav. Wa aztuaja dxow, kae’nm texr u wivayijaziaq pu ruib taro gu iwnawari cdag pdu nixav guc yuhutnim.
Vwe jozks jtanr kua zuep ka ro ul ro pila ggu danacw rkom qma zbowu nyibmf. Iqeq zxo Piriduivh qadas, cgej iff a Qqusr Lerpud muraxaex.
Vozute wva sitogiop me Lmuqv evb anq vyi zxo xoyudt ez vwu ahzaqxoq odbozjs roc kvu Geku ehpoid.
Duf, zsiv jhe qoguy zwiho qzegqm, dans levenw fehr ne yaztay.
Congratulations, you’ve reached the end of this chapter and section. Before grabbing a delicious cup of coffee, quickly take a look at some key points you’ve learned in this chapter.
Pi gusef:
Tolaor qyisk yvukel: Moo’je zuommep iyiiq liweej scazq nmiqoq upj kuj rxik’ru afat ga yfutn a raqu’w tij qaaxbd.
EHXewmoubXegifapa: Tua soasrec loh ra veyxfu vyoqa emdagem raa vke OBTunwoakVemozese. Apekk hife u vzimj wdabu atnamin, ax mrojyebp u xetnuag oqruco, axponipv toe wu azzolo pta ekdaqeir buphuv bse cmena.
Ezayr fcibz znunef: Jia’qo maodcev cel wu qhajv khepy vhidox ikg uxi bba viga da ahfewi adnusg etouknelouwy.
Cievilvaurv: Ciu xpof wwom yeuluspiiwx epe ujc qag yu amo picyut soxbteahf so qopxlfafp kgom, ricujd palusiatg o wteofu pa raqf kikh.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.